bsp viewer
[tar-legacy.git] / MCDV / gamelump.hpp
1 #pragma once
2 #include "generic.hpp"
3
4 #include <vector>
5 #include <fstream>
6
7 #include <glm\glm.hpp>
8 #include <glm\gtc\matrix_transform.hpp>
9 #include <glm\gtc\type_ptr.hpp>
10
11 namespace bsp {
12 #pragma pack(push, 1)
13
14 struct dgamelump_header {
15 int lumpCount;
16 };
17
18 struct dgamelump {
19 int id;
20 unsigned short flags;
21 unsigned short version;
22 int offset;
23 int length;
24 };
25
26 #pragma pack(pop)
27
28 //Don't read as (char*)
29
30 struct staticprop {
31 int version; //Version of prop
32 std::string mdlName; //Name of prop
33
34 //V4+
35 glm::vec3 Origin;
36 glm::vec3 angle;
37 unsigned short PropType; //Index into mdl name dict
38 unsigned short FirstLeaf; //Leaf index
39 unsigned short LeafCount;
40 unsigned char solid;
41 unsigned char flags;
42 int skin; //Skin number
43 float fademindist;
44 float fademaxdist;
45 glm::vec3 lightingorigin;
46
47 //V5+
48 float forcedFadeScale;
49
50 //V6 & V7
51 unsigned short MinDXLevel;
52 unsigned short MaxDXLevel;
53
54 //V8+
55 unsigned char MinCPULevel;
56 unsigned char MaxCPULevel;
57 unsigned char MinGPULevel;
58 unsigned char MaxGPULevel;
59
60 //V7+
61 unsigned char diffuseModulation[4]; // Color and alpha modulation
62
63 //V10+
64 float unkown;
65
66 //V9+
67 int DisableDX360; //Actually a boolean, but reads incorrectly that way
68
69 //V11+
70 float uniformscale;
71 };
72
73 std::vector<dgamelump> readGameLumps(std::ifstream* reader, bsp::lumpHeader info) {
74
75
76 dgamelump_header dgHeader;
77
78 reader->seekg(info.lumpOffset);
79 reader->read((char*)&dgHeader, sizeof(dgHeader));
80
81 std::vector<dgamelump> lumps;
82 for (int i = 0; i < dgHeader.lumpCount; i++) {
83 dgamelump lump;
84 reader->read((char*)&lump, sizeof(lump));
85 lumps.push_back(lump);
86 }
87
88 return lumps;
89 }
90 }