]> git.xonotic.org Git - xonotic/darkplaces.git/blob - model_vbsp.h
model: Recognize Valve BSP format. Add file format headers.
[xonotic/darkplaces.git] / model_vbsp.h
1 /*
2 Copyright (C) 2021 David Knapp (Cloudwalk)
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #include "qtypes.h"
22 #include "qdefs.h"
23
24 /*
25  * The Valve BSP format, used by Source engine, has some interesting
26  * advantages, but makes it quite messy.
27  *
28  * Notably, it supports version numbers for its lumps. Some games may introduce
29  * new features to a lump and increment its version number while leaving the
30  * VBSP version number the same.
31  */
32
33 // Content flags
34 #define HL2CONTENTS_NONE 0
35 #define HL2CONTENTS_SOLID 0x1
36 #define HL2CONTENTS_WINDOW 0x2
37 #define HL2CONTENTS_AUX 0x4
38 #define HL2CONTENTS_GRATE 0x8
39 #define HL2CONTENTS_SLIME 0x10
40 #define HL2CONTENTS_WATER 0x20
41 #define HL2CONTENTS_MIST 0x40
42 #define HL2CONTENTS_OPAQUE 0x80
43 #define HL2CONTENTS_TESTFOGVOLUME 0x100
44 #define HL2CONTENTS_TEAM1 0x800
45 #define HL2CONTENTS_TEAM2 0x1000
46 #define HL2CONTENTS_IGNORE_NODRAW_OPAQUE 0x2000
47 #define HL2CONTENTS_MOVEABLE 0x4000
48 #define HL2CONTENTS_AREAPORTAL 0x8000
49 #define HL2CONTENTS_PLAYERCLIP 0x10000
50 #define HL2CONTENTS_MONSTERCLIP 0x20000
51 #define HL2CONTENTS_CURRENT_0 0x40000
52 #define HL2CONTENTS_CURRENT_90 0x80000
53 #define HL2CONTENTS_CURRENT_180 0x100000
54 #define HL2CONTENTS_CURRENT_270 0x200000
55 #define HL2CONTENTS_CURRENT_UP 0x400000
56 #define HL2CONTENTS_CURRENT_DOWN 0x800000
57 #define HL2CONTENTS_ORIGIN 0x1000000
58 #define HL2CONTENTS_MONSTER 0x2000000
59 #define HL2CONTENTS_DEBRIS 0x4000000
60 #define HL2CONTENTS_DETAIL 0x8000000
61 #define HL2CONTENTS_TRANSLUCENT 0x10000000
62 #define HL2CONTENTS_LADDER 0x20000000
63 #define HL2CONTENTS_HITBOX 0x40000000
64
65 // Lumps
66
67 #define HL2HEADER_LUMPS 64
68
69 #define HL2LUMP_ENTITIES 0
70 #define HL2LUMP_PLANES 1
71 #define HL2LUMP_TEXDATA 2
72 #define HL2LUMP_VERTEXES 3
73 #define HL2LUMP_VISIBILITY 4
74 #define HL2LUMP_NODES 5
75 #define HL2LUMP_TEXINFO 6
76 #define HL2LUMP_FACES 7
77 #define HL2LUMP_LIGHTING 8
78 #define HL2LUMP_OCCLUSION 9
79 #define HL2LUMP_LEAFS 10
80 #define HL2LUMP_FACEIDS 11
81 #define HL2LUMP_EDGES 12
82 #define HL2LUMP_SURFEDGES 13
83 #define HL2LUMP_MODELS 14
84 #define HL2LUMP_WORLDLIGHTS 15
85 #define HL2LUMP_LEAFFACES 16
86 #define HL2LUMP_LEAFBRUSHES 17
87 #define HL2LUMP_BRUSHES 18
88 #define HL2LUMP_BRUSHSIDES 19
89 #define HL2LUMP_AREAS 20
90 #define HL2LUMP_AREAPORTALS 21
91 // These are unused in VBSP 20
92 #define HL2LUMP_PORTALS 22 // VBSP 19
93 #define HL2LUMP_PROPCOLLISION 22 // VBSP 21+
94 #define HL2LUMP_CLUSTERS 23 // VBSP 19
95 #define HL2LUMP_PROPHULLS 23 // VBSP 21+
96 #define HL2LUMP_PORTALVERTS 24 // VBSP 19
97 #define HL2LUMP_PROPHULLVERTS 24 // VBSP 21+
98 #define HL2LUMP_CLUSTERPORTALS 25 // VBSP 19
99 #define HL2LUMP_PROPTRIS 25 // VBSP 21+
100 // End unused
101 #define HL2LUMP_DISPINFO 26
102 #define HL2LUMP_ORIGINALFACES 27
103 #define HL2LUMP_PHYSDISP 28 // VBSP 20+ only
104 #define HL2LUMP_PHYSCOLLIDE 29
105 #define HL2LUMP_VERTNORMALS 30
106 #define HL2LUMP_VERTNORMALINDICES 31
107 #define HL2LUMP_DISP_LIGHTMAP_ALPHAS 32
108 #define HL2LUMP_DISP_VERTS 33
109 #define HL2LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS 34
110 #define HL2LUMP_GAME_LUMP 35
111 #define HL2LUMP_LEAFWATERDATA 36
112 #define HL2LUMP_PRIMITIVES 37
113 #define HL2LUMP_PRIMVERTS 38
114 #define HL2LUMP_PRIMINDICES 39
115 #define HL2LUMP_PAKFILE 40
116 #define HL2LUMP_CLIPPORTALVERTS 41
117 #define HL2LUMP_CUBEMAPS 42
118 #define HL2LUMP_TEXDATA_STRING_DATA 43
119 #define HL2LUMP_TEXDATA_STRING_TABLE 44
120 #define HL2LUMP_OVERLAYS 45
121 #define HL2LUMP_LEAFMINDISTTOWATER 46
122 #define HL2LUMP_FACE_MACRO_TEXTURE_INFO 47
123 #define HL2LUMP_DISP_TRIS 48
124 #define HL2LUMP_PHYSCOLLIDESURFACE 49 // VBSP 19 and 20
125 #define HL2LUMP_PROP_BLOB 49 // VBSP 21+
126 // Everything from here is VBSP 20+ only
127 #define HL2LUMP_WATEROVERLAYS 50
128 #define HL2LUMP_LEAF_AMBIENT_INDEX_HDR 51
129 #define HL2LUMP_LEAF_AMBIENT_INDEX 52
130 #define HL2LUMP_LIGHTING_HDR 53
131 #define HL2LUMP_WORLDLIGHTS_HDR 54
132 #define HL2LUMP_LEAF_AMBIENT_LIGHTING_HDR 55
133 #define HL2LUMP_LEAF_AMBIENT_LIGHTING 56
134 #define HL2LUMP_XZIPPAKFILE 57
135 #define HL2LUMP_FACES_HDR 58
136 #define HL2LUMP_MAP_FLAGS 59
137 #define HL2LUMP_OVERLAY_FADES 60
138 #define HL2LUMP_OVERLAY_SYSTEM_LEVELS 61
139 // VBSP 21+
140 #define HL2LUMP_PHYSLEVEL 62
141 #define HL2LUMP_DISP_MULTIBLEND 63
142
143 typedef struct hl2lump_s
144 {
145         int32_t fileofs, filelen;
146         int32_t version;
147         int32_t id;
148 } hl2lump_t;
149
150 typedef struct hl2dheader_s
151 {
152         int32_t id;
153         int32_t version;
154         hl2lump_t lumps[HL2HEADER_LUMPS];
155         int32_t revision;
156 } hl2dheader_t;