Nuclide
Software Development Kit for id Tech
materials.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2024 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
18
19void Materials_Init(void);
20
21/* legacy material compatibility */
22
24typedef struct
25{
26 string id;
27 string matclass;
29
33
35
36/* FIXME: world.... sigh, we should box this into a worldspawn class */
38
39// Impact types
40typedef enum
41{
61
62typedef enum
63{
75
76
77/* q3 bsp base flags */
78#define SURF_NODAMAGE 0x1i // never give falling damage
79#define SURF_SLICK 0x2i // effects game physics
80#define SURF_SKY 0x4i // lighting from environment map
81#define SURF_LADDER 0x8i // climb this surface
82#define SURF_NOIMPACT 0x10i // don't make missile explosions
83#define SURF_NOMARKS 0x20i // don't leave missile marks
84#define SURF_Q3FLESH 0x40i // make flesh sounds and effects
85#define SURF_NODRAW 0x80i // don't generate a drawsurface at all
86#define SURF_HINT 0x100i // make a primary bsp splitter
87#define SURF_SKIP 0x200i // completely ignore, allowing non-closed brushes
88#define SURF_NOLIGHTMAP 0x400i // surface doesn't need a lightmap
89#define SURF_POINTLIGHT 0x800i // generate lighting info at vertexes
90#define SURF_METALSTEPS 0x1000i // clanking footsteps
91#define SURF_NOSTEPS 0x2000i // no footstep sounds
92#define SURF_NONSOLID 0x4000i // don't collide against curves with this set
93#define SURF_LIGHTFILTER 0x8000i // act as a light filter during q3map -light
94#define SURF_ALPHASHADOW 0x10000i // do per-pixel light shadow casting in q3map
95#define SURF_NODLIGHT 0x20000i // don't dlight even if solid (solid lava, skies)
96#define SURF_DUST 0x40000i // leave a dust trail when walking on this surface
97
98/* behaviour surfaceflags */
99#define SURF_LEAKSTEAM 0x00080000i /* when shot, the material emits steam */
100#define SURF_LEAKWATER 0x00100000i /* when shot, the material emits water */
101#define SURF_RESERVED1 0x00200000i
102#define SURF_RESERVED2 0x00400000i
103#define SURF_RESERVED3 0x00800000i
104#define SURF_RESERVED4 0x01000000i
105#define SURF_RESERVED5 0x02000000i
106#define SURF_RESERVED6 0x04000000i
107#define SURF_PENETRATE 0x08000000i
108
109/* old TW material surfaceflags (need to be masked) */
110#define SURF_MASK 0x0FFFFFFFi
111#define SURF_ALIEN 0x10000000i
112#define SURF_BLOODYFLESH 0x20000000i
113#define SURF_FOLIAGE 0x30000000i
114#define SURF_COMPUTER 0x40000000i
115#define SURF_DIRT 0x50000000i
116#define SURF_VENT 0x60000000i
117#define SURF_GRATE 0x70000000i
118#define SURF_METAL 0x80000000i
119#define SURF_GLASS 0x90000000i
120#define SURF_SAND 0xA0000000i
121#define SURF_SLOSH 0xB0000000i
122#define SURF_SNOW 0xC0000000i
123#define SURF_TILE 0xD0000000i
124#define SURF_WOOD 0xE0000000i
125#define SURF_CONCRETE 0xF0000000i
126
127const int CONTENTBIT_NONE = 0x00000000i;
128
129const int CONTENTBIT_SOLID = 0x00000001i
130; /* SOLID_BSP */
131const int CONTENTBIT_UNUSED1 = 0x00000002i
132;
133const int CONTENTBIT_UNUSED2 = 0x00000004i
134;
135const int CONTENTBIT_LAVA = 0x00000008i;
136 /* surfaceParm lava */
137
138const int CONTENTBIT_SLIME = 0x00000010i;
139 /* surfaceParm slime */
140const int CONTENTBIT_WATER = 0x00000020i;
141 /* surfaceParm water */
142const int CONTENTBIT_UNUSED3 = 0x00000040i
143;
144const int CONTENTBIT_GRENADECLIP = 0x00000080i
145; /* surfaceParm grenadeclip */
146
147const int CONTENTBIT_UNUSED4 = 0x00000100i;
148const int CONTENTBIT_UNUSED5 = 0x00000200i;
149const int CONTENTBIT_UNUSED6 = 0x00000400i
150;
151const int CONTENTBIT_UNUSED7 = 0x00000800i
152;
153
154const int CONTENTBIT_UNUSED8 = 0x00001000i;
155const int CONTENTBIT_UNUSED9 = 0x00002000i;
156const int CONTENTBIT_FTELADDER = 0x00004000i; /* surfaceparm climb */
157const int CONTENTBIT_VEHICLECLIP = 0x00008000i;
158
159const int CONTENTBIT_PLAYERCLIP = 0x00010000i;
160 /* surfaceParm playerclip */
161const int CONTENTBIT_MONSTERCLIP = 0x00020000i;
162 /* surfaceParm monsterclip */
163const int CONTENTBIT_PROJECTILE = 0x00040000i;
164const int CONTENTBIT_UNUSED12 = 0x00080000i;
165
166const int CONTENTBIT_CLUSTERPORTAL = 0x00100000i;
167const int CONTENTBIT_DONOTENTER = 0x00200000i;
168const int CONTENTBIT_BOTCLIP = 0x00400000i
169; /* surfaceParm botclip */
170const int CONTENTBIT_MOVER = 0x00800000i
171;
172
173const int CONTENTBIT_UNUSED13 = 0x01000000i
174;
175const int CONTENTBIT_BODY = 0x02000000i; /* SOLID_BBOX/SLIDEBOX */
176const int CONTENTBIT_CORPSE = 0x04000000i; /* SOLID_CORPSE */
177const int CONTENTBIT_UNUSED14 = 0x08000000i;
178
179const int CONTENTBIT_UNUSED15 = 0x10000000i;
180const int CONTENTBIT_Q2LADDER = 0x20000000i; /* Q2BSP climbables */
181const int CONTENTBIT_UNUSED16 = 0x40000000i;
182const int CONTENTBIT_SKY = 0x80000000i; /* Q1BSP only! */
183
184/* a bit content group */
186
187/* this is used for material-lookups using the external materials.txt file
188 * method used in Half-Life. In that environment we have to strip any
189 * prefixes and limit our material-name to 12 chars for everything to be
190 * identified correctly */
191string
192Materials_FixName(string old_name)
193{
194 string tex_name = old_name;
195
196 /* strip the first 2 chars when they're frame/random indicators */
197 if (str2chr(tex_name, 0) == '-')
198 tex_name = substring(tex_name, 2, -1);
199 else if (str2chr(tex_name, 0) == '+')
200 tex_name = substring(tex_name, 2, -1);
201
202 /* also not allowed */
203 if (str2chr(tex_name, 0) == '~')
204 tex_name = substring(tex_name, 1, -1);
205 else if (str2chr(tex_name, 0) == '{')
206 tex_name = substring(tex_name, 1, -1);
207
208 /* limit to 12 chars! */
209 tex_name = substring(tex_name, 0, 12);
210
211 //NSLog("%s > %s", old_name, tex_name);
212
213 return tex_name;
214}
#define hashtable
Definition: fteextensions.qc:269
impactType_t
Definition: materials.h:41
@ IMPACT_VENT
Definition: materials.h:58
@ IMPACT_DEFAULT
Definition: materials.h:44
@ IMPACT_METAL
Definition: materials.h:53
@ IMPACT_FOLIAGE
Definition: materials.h:50
@ IMPACT_WOOD
Definition: materials.h:59
@ IMPACT_ALIEN
Definition: materials.h:45
@ IMPACT_COMPUTER
Definition: materials.h:46
@ IMPACT_CONCRETE
Definition: materials.h:47
@ IMPACT_SLOSH
Definition: materials.h:55
@ IMPACT_GRATE
Definition: materials.h:52
@ IMPACT_GLASS
Definition: materials.h:51
@ IMPACT_TILE
Definition: materials.h:57
@ IMPACT_EXPLOSION
Definition: materials.h:43
@ IMPACT_SNOW
Definition: materials.h:56
@ IMPACT_SAND
Definition: materials.h:54
@ IMPACT_MELEE
Definition: materials.h:42
@ IMPACT_DIRT
Definition: materials.h:48
@ IMPACT_FLESH
Definition: materials.h:49
const int CONTENTBIT_SOLID
Definition: materials.h:129
const int CONTENTBIT_PLAYERCLIP
Definition: materials.h:159
const int CONTENTBIT_UNUSED4
Definition: materials.h:147
const int CONTENTBIT_UNUSED7
Definition: materials.h:151
hlmaterials_lut * g_hlmlut
Definition: materials.h:30
var int g_hlmlut_count
Definition: materials.h:31
const int CONTENTBIT_UNUSED2
Definition: materials.h:133
const int CONTENTBIT_LAVA
Definition: materials.h:135
var bool g_materialsAreLegacy
Definition: materials.h:34
const int CONTENTBIT_UNUSED13
Definition: materials.h:173
const int CONTENTBIT_UNUSED12
Definition: materials.h:164
const int CONTENTBIT_UNUSED14
Definition: materials.h:177
const int CONTENTBIT_UNUSED15
Definition: materials.h:179
const int CONTENTBIT_UNUSED9
Definition: materials.h:155
const int CONTENTBIT_WATER
Definition: materials.h:140
string materials_file
Definition: materials.h:37
const int CONTENTBIT_UNUSED1
Definition: materials.h:131
hashtable g_hashMaterials
Definition: materials.h:17
const int CONTENTBIT_BOTCLIP
Definition: materials.h:168
const int CONTENTBIT_BODY
Definition: materials.h:175
const int CONTENTBIT_MONSTERCLIP
Definition: materials.h:161
const int CONTENTBIT_FTELADDER
Definition: materials.h:156
const int CONTENTBIT_DONOTENTER
Definition: materials.h:167
const int CONTENTBIT_NONE
Definition: materials.h:127
const int CONTENTBIT_MOVER
Definition: materials.h:170
const int CONTENTBIT_UNUSED5
Definition: materials.h:148
const int CONTENTBIT_CLUSTERPORTAL
Definition: materials.h:166
const int CONTENTBIT_UNUSED6
Definition: materials.h:149
string Materials_FixName(string old_name)
Definition: materials.h:192
var int g_hlmaterial_entries
Definition: materials.h:32
const int CONTENTBIT_UNUSED16
Definition: materials.h:181
const int CONTENTBIT_Q2LADDER
Definition: materials.h:180
const int CONTENTBIT_UNUSED3
Definition: materials.h:142
const int CONTENTBIT_SLIME
Definition: materials.h:138
const int CONTENTBIT_UNUSED8
Definition: materials.h:154
const int CONTENTBIT_CORPSE
Definition: materials.h:176
const int CONTENTBIT_PROJECTILE
Definition: materials.h:163
const int CONTENTBIT_VEHICLECLIP
Definition: materials.h:157
const int CONTENTBIT_GRENADECLIP
Definition: materials.h:144
materialType_t
Definition: materials.h:63
@ GSMATERIAL_METAL
Definition: materials.h:66
@ GSMATERIAL_NONE
Definition: materials.h:73
@ GSMATERIAL_WOOD
Definition: materials.h:65
@ GSMATERIAL_ROCK
Definition: materials.h:72
@ GSMATERIAL_TILE
Definition: materials.h:69
@ GSMATERIAL_CINDER
Definition: materials.h:68
@ GSMATERIAL_GLASS_UNBREAKABLE
Definition: materials.h:71
@ GSMATERIAL_GLASS
Definition: materials.h:64
@ GSMATERIAL_COMPUTER
Definition: materials.h:70
@ GSMATERIAL_FLESH
Definition: materials.h:67
void Materials_Init(void)
Initialize our material backbone.
Definition: materials.qc:187
const int CONTENTBIT_SKY
Definition: materials.h:182
const int CONTENTBITS_MONSTER
Definition: materials.h:185
hlmaterial to classname mapper table
Definition: materials.h:25
string id
Definition: materials.h:26
string matclass
Definition: materials.h:27