1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
/*
* PARSEC HEADER (OBJECT)
* Generic Object Structures V1.80
*
* Copyright (c) Markus Hadwiger 1995-2001
* All Rights Reserved.
*/
#ifndef _OD_STRUC_H_
#define _OD_STRUC_H_
#ifdef PARSEC_SERVER
// forward decls --------------------------------------------------------------
//
class E_Distributable;
#endif // PARSEC_SERVER
// defines a texture map (size is 32 bytes) -----------------------------------
//
struct TextureMap {
dword Geometry; // code for geometry of texture
word Width; // log2( width in pixels )
word Height; // log2( height in pixels )
word Flags; // flag word
byte LOD_small; // smallest LOD level (power of two)
byte LOD_large; // largest LOD level (power of two)
dword CompFormat; // impl.-dependent compressed format spec
char* BitMap; // pointer to bitmap (8 bit per texel)
word* TexPalette; // pointer to color look up table for texture
const char* TexMapName; // pointer to texture name
dword TexelFormat; // texel format
};
// single texfont char (size is 8 bytes) --------------------------------------
//
struct texchar_s {
short tex_u; // u coordinate in texture
short tex_v; // v coordinate in texture
short tex_id; // id of texture (relative to texfont)
signed char tex_ulead; // u offset to first real column
signed char tex_ustep; // u advance after drawing this char
};
// entire texfont descriptor (size is 16 bytes) -------------------------------
//
struct texfont_s {
dword flags;
byte height; // height of chars (must be equal for all)
byte numtextures; // may have been split up into several textures
short numtexchars; // number of chars in this font
texchar_s* texchars; // table of chars
TextureMap* texmap; // corresponding font textures (array)
};
// single entry (frame) in table of textures ----------------------------------
//
struct texfrm_s {
int deltatime; // delta time to next entry (frame)
TextureMap* texmap; // texture map for this frame
};
// single entry (frame) in table of 2-D (image) transformations ---------------
//
struct xfofrm_s {
int deltatime; // delta time to next entry (frame)
imgtrafo_s* imgtrafo; // image transformation for this frame
};
// texture animation descriptor (size is 32 bytes) ----------------------------
//
struct texanim_s {
texfrm_s* tex_table; // table of textures
dword tex_end; // end index
dword tex_start; // start index
dword tex_rep; // repeat index
xfofrm_s* xfo_table; // table of 2-D (image) transformations
dword xfo_end; // end index
dword xfo_start; // start index
dword xfo_rep; // repeat index
};
// single entry (frame) in color animation table (size is 8 bytes) ------------
//
struct colfrm_s {
int deltatime; // delta time to next entry (frame)
colrgba_s color; // color for this frame
};
// how to combine the color sources in color animations -----------------------
//
enum {
COLANIM_SOURCENOCOMBINE = 0x0000, // no source color combination
COLANIM_SOURCEADD = 0x0001, // add source colors
COLANIM_SOURCEMUL = 0x0002, // multiply source colors
COLANIM_SOURCE_MASK = 0x0003
};
// color animation descriptor (size is 16 bytes) ------------------------------
//
struct colanim_s {
colfrm_s* col_table0; // color source 0
colfrm_s* col_table1; // color source 1
word col_end0; // table 0 end index (length-1)
word col_end1; // table 1 end index (length-1)
dword col_flags; // COLANIM_xx
};
// how to combine the source color with the face color ------------------------
//
enum {
FACE_ANIM_BASEIGNORE = 0x0000, // ignore base (face) color
FACE_ANIM_BASEADD = 0x0001, // add anim to base color
FACE_ANIM_BASEMUL = 0x0002, // multiply base color by anim
FACE_ANIM_BASE_MASK = 0x0003
};
// instance data for current state of face animation (size is 32 bytes) -------
//
struct FaceAnimState {
// base info
texanim_s* TexAnim; // texture animation
colanim_s* ColAnim; // color animation
dword ColFlags; // FACE_ANIM_xx
colrgba_s ColOutput; // animated output color
// state info
word tex_pos; // current position in texture table
short tex_time; // time left until next advance in table
word xfo_pos; // current position in trafo table
short xfo_time; // time left until next advance in table
word col_pos0; // current position in color source 0
short col_time0; // time left until next advance in table
word col_pos1; // current position in color source 1
short col_time1; // time left until next advance in table
};
// extended face info flags ---------------------------------------------------
//
enum {
FACE_EXT_NONE = 0x0000, // no animations at all
FACE_EXT_ANIMATETEXTURES = 0x0001, // enable texture animation
FACE_EXT_TRANSFORMTEXTURES = 0x0002, // enable texture xfo animation
FACE_EXT_ANIMATECOLORS = 0x0004, // enable color animation
FACE_EXT_ONESHOT = 0x0010, // one-shot animation
FACE_EXT_ONESHOTRESTORE = 0x0020, // restore previous shader
FACE_EXT_DISABLED = 0x8000 // temporarily disabled
};
// optional extended face information (size is 8 bytes) -----------------------
//
struct FaceExtInfo {
dword Flags; // FACE_EXT_xx
dword StateId; // index into GenObject::FaceAnimStates[]
};
// face shading flags ---------------------------------------------------------
//
enum {
FACE_SHADING_DEFAULT = 0x0000,
FACE_SHADING_FACECOLOR = 0x0001, // use face color (direct/indexed)
FACE_SHADING_USECOLORINDEX = 0x0002, // indexed instead of direct color
FACE_SHADING_TEXIPOLATE = 0x0004, // texture may be interpolated
FACE_SHADING_ENABLETEXTURE = 0x0010, // shader uses texture
FACE_SHADING_CONSTANTCOLOR = 0x0020, // shade with constant color
FACE_SHADING_NOVERTEXALPHA = 0x0040, // shader must ignore vertex alpha
FACE_SHADING_NODEPTHCMP = 0x0100, // disable depth compare
FACE_SHADING_NODEPTHWRITE = 0x0200, // disable depth write
FACE_SHADING_DRAW_SORTED = 0x0400, // draw in depth order
FACE_SHADING_DRAW_LAST = 0x0800, // draw last (overlay)
FACE_SHADING_NOBACKCULLING = 0x1000, // turn off backface culling
FACE_SHADING_BACK_FIRST = 0x2000 // draw backfaces, then frontfaces
};
// defines a single object-face (size is 128 bytes) ---------------------------
//
struct Face {
TextureMap* TexMap; // pointer to texture description
FaceExtInfo* ExtInfo; // optional extended face info
dword ColorRGB; // RGB color for direct color display
dword ColorIndx; // colorindex for palette mapped display
dword FaceNormalIndx; // index of vertex which is the surface normal
Xmatrx TexXmatrx; // matrix for texture placement
dword _mtxscratch1; // scratchpad for matrix code
Xmatrx CurTexXmatrx; // current transformation screen -> texture
word ShadingIter; // shader to use for this face (iter_xx)
word ShadingFlags; // shading flags (FACE_SHADING_xx)
dword VisibleFrame; // ==CurVisibleFrame if face touched this frame
};
// polygon flags --------------------------------------------------------------
//
enum {
POLYFLAG_DEFAULT = 0x0000, // vertex indexes only
POLYFLAG_CORNERCOLORS = 0x0001, // RGBA color array follows
POLYFLAG_WEDGEINDEXES = 0x0002 // wedge index array follows
};
// defines a single object-polygon (size is 16 bytes) -------------------------
//
struct Poly {
dword NumVerts; // number of vertices (no surface normal!)
dword FaceIndx; // index of face this polygon belongs to
dword* VertIndxs; // list of vertexindexes comprising the polygon
dword Flags; // POLYFLAG_xx
};
// node structure for bsp tree nodes (size is 16 bytes) -----------------------
//
struct BSPNode {
dword Polygon; // index of polygon contained in this node
dword Contained; // index of first node in the same plane (list)
dword FrontTree; // index of root-node of front-subtree
dword BackTree; // index of root-node of back-subtree
};
// vertex animation callback function type ------------------------------------
//
struct GenObject;
typedef int (*vtxanim_fpt)( GenObject *gobj, dword animid );
// instance data for current state of vertex animation (size is 128 bytes) ----
//
struct VtxAnimState {
// base info
dword NumVerts; // number of vertices with normals
dword NumPolyVerts; // number of vertices without normals
dword NumNormals; // number of face normals
dword VertexBase; // base index for vertex subarray
dword NumPolys; // number of polygons
dword PolyBase; // base index for polygon subarray
dword NumFaces; // number of faces
dword FaceBase; // base index for face subarray
dword NumWedges; // number of wedges
dword WedgeBase; // base index for wedge subarray
vtxanim_fpt AnimCallback; // callback function
// state info
Xmatrx CurrentXmatrx; // current transformation matrix
dword StateInfo[ 9 ]; // custom animation state info
};
// allow pointer to particle cluster to be declared ---------------------------
//
struct objectbase_pcluster_s;
typedef objectbase_pcluster_s ObjPartCluster;
// forward declaration --------------------------------------------------------
//
struct CustomObject;
// wedge data flags -----------------------------------------------------------
//
enum {
WEDGEFLAG_ENABLE_TEXCOORDS = 0x0001
};
// structure of generic graphical object for specific lod ---------------------
//
struct GenLodObject {
dword NumVerts; // number of vertices with normals
dword NumPolyVerts; // number of vertices without normals
dword NumNormals; // number of face normals
Vertex3* VertexList; // list of all vertices in object space
Vertex3* X_VertexList; // vertices transformed into view space
SPoint* S_VertexList; // vtxs converted to screen coordinates
dword NumPolys; // number of polygons in this object
Poly* PolyList; // list of polygons in this object
dword NumFaces; // number of faces in this object
Face* FaceList; // list of all faces
dword* VisPolyList; // indexes of currently visible polys
dword* SortedPolyList; // poly indexes sorted on attributes
void* AuxList; // ...
BSPNode* BSPTree; // pointer to root of bsp tree
CullBSPNode* AuxBSPTree; // auxiliary bsp tree
void* AuxObject; // object for api-optimized rendering
dword NumWedges; // wedges==subvertices on attributes
word NumLayers; // number of texcoordinates per wedge
word WedgeFlags; // WEDGEFLAG_xx
dword* WedgeVertIndxs; // vertices corresponding to wedges
Vector3* WedgeNormals; // vertex/wedge normals
colrgba_s* WedgeColors; // vertex/wedge colors
TexCoord2* WedgeTexCoords; // vertex/wedge texture coordinates
colrgba_s* WedgeLighted; // temp storage for lighted wedges
colrgba_s* WedgeSpecular; // temp storage for specular colors
colrgba_s* WedgeFogged; // temp storage for fogged wedges
word ActiveFaceAnims; // active face anim state subrange
word ActiveVtxAnims; // active vertex anim state subrange
};
// object lod descriptor (size is 16 bytes) -----------------------------------
//
struct GenLodInfo {
dword Flags;
geomv_t MagTreshold; // switching thresholds with hysteresis
geomv_t MinTreshold; // (small->large, large->small)
GenLodObject* LodObject; // actual geometry for this lod
};
// structure of generic graphical object --------------------------------------
//
struct GenObject {
GenObject* NextObj; // next object in list; _if_ the list
GenObject* PrevObj; // is doubly linked: previous object
GenObject* NextVisObj; // pointer to next obj in visible list
dword ObjectNumber; // unique number of this objectinstance
dword HostObjNumber; // number this object has on its host
dword ObjectType; // type this object belongs to
dword ObjectClass; // class this object belongs to
size_t InstanceSize; // size of instance of this object class
dword NumVerts; // number of vertices with normals
dword NumPolyVerts; // number of vertices without normals
dword NumNormals; // number of face normals
Vertex3* VertexList; // list of all vertices in object space
Vertex3* X_VertexList; // vertices transformed into view space
SPoint* S_VertexList; // vtxs converted to screen coordinates
dword NumPolys; // number of polygons in this object
Poly* PolyList; // list of polygons in this object
dword NumFaces; // number of faces in this object
Face* FaceList; // list of all faces
dword NumVisPolys; // number of polygon indexes in vislist
dword* VisPolyList; // indexes of currently visible polys
dword* SortedPolyList; // poly indexes sorted on attributes
void* AuxList; // ...
geomv_t BoundingSphere; // radius of bounding sphere
geomv_t BoundingSphere2; // radius squared of bounding sphere
Vertex3 BoundingBox[ 2 ]; // min-max vertices of bounding box
BSPNode* BSPTree; // pointer to root of bsp tree
ObjPartCluster* AttachedPClusters; // list of attached particle clusters
CustomObject* NotifyCustmObjects; // customobj list for callback_notify()
dword VisibleFrame; // ==CurVisibleFrame if object visible
CullBSPNode* AuxBSPTree; // auxiliary bsp tree
dword CullMask; // last cull mask set by culling code
void* AuxObject; // object for api-optimized rendering
dword NumWedges; // wedges==subvertices on attributes
word NumLayers; // number of texcoordinates per wedge
word WedgeFlags; // WEDGEFLAG_xx
dword* WedgeVertIndxs; // vertices corresponding to wedges
Vector3* WedgeNormals; // vertex/wedge normals
colrgba_s* WedgeColors; // vertex/wedge colors
TexCoord2* WedgeTexCoords; // vertex/wedge texture coordinates
colrgba_s* WedgeLighted; // temp storage for lighted wedges
colrgba_s* WedgeSpecular; // temp storage for specular colors
colrgba_s* WedgeFogged; // temp storage for fogged wedges
word CurrentLod; // currently active detail level
word NumLodObjects; // number of available detail levels
GenLodInfo* LodObjects; // detail level descriptors
word NumFaceAnims; // number of face anim states (maximum)
word ActiveFaceAnims; // active state subrange (from start)
FaceAnimState* FaceAnimStates; // face anim states (must be instanced!)
word NumVtxAnims; // number of vtx anim states (maximum)
word ActiveVtxAnims; // active state subrange (from start)
VtxAnimState* VtxAnimStates; // vtx anim states (must be instanced!)
dword _mtxscratch1; // scratchpad for matrix code
Xmatrx ObjPosition; // location and orientation in worldsp.
dword _mtxscratch2; // scratchpad for matrix code
Xmatrx CurrentXmatrx; // current objspace -> viewspace xform
#ifdef PARSEC_SERVER
E_Distributable* pDist; // pointer to the E_Distributable attached to this engine object
#endif // PARSEC_SERVER
};
#endif // _OD_STRUC_H_
|