My Project
modelheaders.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
5 
6 /* Specifies packing alignment for ParaEngine model file structures as seen in the file.*/
7 #pragma pack(push,1)
8 
9 enum ParaXModelType{
10  PARAX_MODEL_ANIMATED=0,
11  PARAX_MODEL_STATIC,
12  PARAX_MODEL_DX_STATIC, // directX's X file
13  PARAX_MODEL_INVALID,
14  PARAX_MODEL_BMAX, // block max model with vertex color.
15  PARAX_MODEL_UNKNOWN
16 };
17 
18 enum ParaXModelFormat{
19  // this has to be 1 for the rest bitfield to take effect. if this is 0, all model format are ignored.
20  PARAX_FORMAT_USEFORMAT = 1,
21  // vertex has normal
22  PARAX_FORMAT_NORMAL = 2,
23  // vertex has second UV set
24  PARAX_FORMAT_UV2 = 4,
25  // Maybe add whether using advanced effect like normal and environment mapping etc.
26 };
27 
32  char id[4];
33  unsigned char version[4];
35  DWORD type;
36  DWORD IsAnimated;
37  Vector3 minExtent;
38  Vector3 maxExtent;
40  DWORD nModelFormat;
41 public:
43  memcpy(id, "para", 4);
44  version[0] = 1;
45  version[1] = 0;
46  version[2] = 0;
47  version[3] = 1;
48  type = PARAX_MODEL_ANIMATED;
49  IsAnimated = 0;
50  minExtent = Vector3::ZERO;
51  maxExtent = Vector3::ZERO;
52  nModelFormat = 0;
53  }
54 };
55 static_assert(sizeof(ParaXHeaderDef) == 44, "compiler breaks packing rules");
56 
58 struct ModelHeader {
59  char id[4];
60  uint8 version[4];
61  uint32 nameLength;
62  uint32 nameOfs;
63  uint32 type;
64 
65  uint32 nGlobalSequences;
66  uint32 ofsGlobalSequences;
67  uint32 nAnimations;
68  uint32 ofsAnimations;
69  uint32 nC;
70  uint32 ofsC;
71  uint32 nD;
72  uint32 ofsD;
73  uint32 nBones;
74  uint32 ofsBones;
75  uint32 nF;
76  uint32 ofsF;
77 
78  uint32 nVertices;
79  uint32 ofsVertices;
80  uint32 nViews;
81  uint32 ofsViews;
82 
83  uint32 nColors;
84  uint32 ofsColors;
85 
86  uint32 nTextures;
87  uint32 ofsTextures;
88 
89  uint32 nTransparency; // H
90  uint32 ofsTransparency;
91  uint32 nI; // always unused ?
92  uint32 ofsI;
93  uint32 nTexAnims; // J
94  uint32 ofsTexAnims;
95  uint32 nTexReplace;
96  uint32 ofsTexReplace;
97 
98  uint32 nTexFlags;
99  uint32 ofsTexFlags;
100  uint32 nY;
101  uint32 ofsY;
102 
103  uint32 nTexLookup;
104  uint32 ofsTexLookup;
105 
106  uint32 nTexUnitLookup; // L
107  uint32 ofsTexUnitLookup;
108  uint32 nTransparencyLookup; // M
109  uint32 ofsTransparencyLookup;
110  uint32 nTexAnimLookup;
111  uint32 ofsTexAnimLookup;
112 
113  float floats[14];
114 
115  uint32 nBoundingTriangles;
116  uint32 ofsBoundingTriangles;
117  uint32 nBoundingVertices;
118  uint32 ofsBoundingVertices;
119  uint32 nBoundingNormals;
120  uint32 ofsBoundingNormals;
121 
122  uint32 nAttachments; // O
123  uint32 ofsAttachments;
124  uint32 nAttachLookup; // P
125  uint32 ofsAttachLookup;
126  uint32 nQ; // Q
127  uint32 ofsQ;
128  uint32 nLights; // R
129  uint32 ofsLights;
130  uint32 nCameras; // S
131  uint32 ofsCameras;
132  uint32 nT;
133  uint32 ofsT;
134  uint32 nRibbonEmitters; // U
135  uint32 ofsRibbonEmitters;
136  uint32 nParticleEmitters; // V
137  uint32 ofsParticleEmitters;
138 
139 };
140 
143  uint32 type;
144  uint32 flags;
145  uint32 nameLen;
146  uint32 nameOfs;
147 };
148 
151 {
153  DWORD nType;
154  DWORD nVertexBytes;
155  DWORD nVertices;
156  DWORD ofsVertices;
157 };
159 struct Indice0Def{
160  DWORD nIndices;
161  DWORD ofsIndices;
162 };
163 
164 // block B - animations
166  uint32 animID;
167  uint32 timeStart;
168  uint32 timeEnd;
169 
170  float moveSpeed;
171 
172  uint32 loopType;
173  uint32 flags;
174  uint32 d1;
175  uint32 d2;
176  uint32 playSpeed; // note: this can't be play speed because it's 0 for some models
177 
178  Vector3 boxA, boxB;
179  float rad;
180 
181  int16 s[2];
182 };
183 
184 
185 // sub-block in block E - animation data
187  int16 type; // interpolation type (0=none, 1=linear, 2=hermite)
188  int16 seq; // global sequence id or -1
189  uint32 nRanges;
190  uint32 ofsRanges;
191  uint32 nTimes;
192  uint32 ofsTimes;
193  uint32 nKeys;
194  uint32 ofsKeys;
195 };
196 static_assert(sizeof(AnimationBlock) == 28, "compiler breaks packing rules");
197 
198 // block E - bones
199 struct ModelBoneDef {
200  int32 animid;
201  uint32 flags;
202  int16 parent; // parent bone index
203  int16 boneid; // id of a known (predefined) bone. this can be 0 or -1 which means unknown bones.
204  AnimationBlock translation;
205  AnimationBlock rotation;
206  union {
207  AnimationBlock scaling;
208  uint32 ofsStaticMatrix;
209  };
210 
211  union {
212  Vector3 pivot;
213  // this is only used when (flags & 0x80000000) > 0
214  struct {
215  uint32 nBoneName;
216  uint32 nOffsetMatrix;
217  uint32 nOffsetPivot;
218  };
219  };
220 };
221 
223  AnimationBlock trans, rot, scale;
224 };
225 
226 struct ModelVertex {
227  Vector3 pos;
228  uint8 weights[4];
229  uint8 bones[4];
230  Vector3 normal;
231  Vector2 texcoords;
232  DWORD color0; // always 0,0 if they are unused
233  DWORD color1;
234 };
235 
236 struct ModelView {
237  uint32 nIndex, ofsIndex; // Vertices in this model (index into vertices[])
238  uint32 nTris, ofsTris; // indices
239  uint32 nProps, ofsProps; // additional vtx properties
240  uint32 nSub, ofsSub; // materials/renderops/submeshes
241  uint32 nTex, ofsTex; // material properties/textures
242  int32 lod; // LOD bias?
243 };
244 
245 
247 struct ModelGeoset {
248  uint16 id; // mesh part id
249  uint16 d2; //
250  uint16 vstart; // first vertex
251  uint16 vcount; // num vertices
252  uint16 istart; // first index
253  uint16 icount; // num indices
254  union{
255  struct {
256  uint16 d3; // first vertex
257  uint16 d4; // num vertices
258  };
259  int32 m_nVertexStart; // 32bits vertex start used in bmax model
260  };
261  uint16 d5; //
262  uint16 d6; // root bone
263  Vector3 v;
264 
265  void SetVertexStart(int32 nStart){
266  m_nVertexStart = nStart;
267  }
268  int32 GetVertexStart() { return m_nVertexStart; }
269 };
270 
273  // probably the texture units
274  // size always >=number of materials it seems
275  uint16 flags; // Flags
276  uint16 order; // ?
277  uint16 op; // Material this texture is part of (index into mat)
278  uint16 op2; // Always same as above?
279  int16 colorIndex; // color or -1
280  uint16 flagsIndex; // more flags...
281  uint16 texunit; // Texture unit (0 or 1)
282  uint16 d4; // ? (seems to be always 1)
283  uint16 textureid; // Texture id (index into global texture list)
284  uint16 texunit2; // copy of texture unit value?
285  uint16 transid; // transparency id (index into transparency list)
286  uint16 texanimid; // texture animation id
287 };
288 
289 // block X - render flags
291  uint16 flags;
292  uint16 blend;
293 };
294 
295 // block G - color defs
297  AnimationBlock color;
298  AnimationBlock opacity;
299 };
300 
301 // block H - transp defs
303  AnimationBlock trans;
304 };
305 
307  int16 type;
308  int16 bone;
309  Vector3 pos;
310  AnimationBlock ambColor;
311  AnimationBlock ambIntensity;
312  AnimationBlock color;
313  AnimationBlock intensity;
314  AnimationBlock attStart;
315  AnimationBlock attEnd;
316  AnimationBlock unk1;
317 };
318 
320  int32 id;
321  float fov, farclip, nearclip;
322  AnimationBlock transPos;
323  Vector3 pos;
324  AnimationBlock transTarget;
325  Vector3 target;
326  AnimationBlock rot;
327 };
328 
329 
331  float mid;
332  uint32 colors[3];
333  float sizes[3];
334  int16 d[10];
335  float unk[3];
336  float scales[3];
337  float slowdown;
338  float rotation;
339  float f2[16];
340 };
341 
343  int32 id;
344  int32 flags;
345  Vector3 pos;
346  int16 bone;
347  int16 texture;
348  int32 nZero1;
349  int32 ofsZero1;
350  int32 nZero2;
351  int32 ofsZero2;
352  int16 blend;
353  int16 type;
354  int16 s1;
355  int16 s2;
356  int16 cols;
357  int16 rows;
358  AnimationBlock params[10];
360  AnimationBlock unk;
361 };
362 
363 
365  int32 id;
366  int32 bone;
367  Vector3 pos;
368  int32 nTextures;
369  int32 ofsTextures;
370  int32 nUnknown;
371  int32 ofsUnknown;
372  AnimationBlock color;
373  AnimationBlock opacity;
374  AnimationBlock above;
375  AnimationBlock below;
376  float res, length, unk;
377  int16 s1, s2;
378  AnimationBlock unk1;
379  AnimationBlock unk2;
380 };
381 
382 
383 struct ModelBlockQ {
384  char id[4];
385  int32 dbid;
386  int32 bone;
387  Vector3 pos;
388  int16 type;
389  int16 seq;
390  uint32 nRanges;
391  uint32 ofsRanges;
392  uint32 nTimes;
393  uint32 ofsTimes;
394 };
395 
396 
398  int32 id;
399  int32 bone;
400  Vector3 pos;
401  AnimationBlock unk;
402 };
403 #pragma pack(pop)
404 
407 {
408  Bone_Unknown = 0,//
409 
410  Bone_Root,
411  Bone_Pelvis,
412  Bone_Spine,
413  Bone_L_Thigh,
414  Bone_L_Calf,
415  Bone_L_Foot,
416  Bone_R_Thigh,
417  Bone_R_Calf,
418  Bone_R_Foot,
419 
420  Bone_L_Clavicle,
421  Bone_L_UpperArm,
422  Bone_L_Forearm,
423  Bone_L_Hand,
424  Bone_R_Clavicle,
425  Bone_R_UpperArm,
426  Bone_R_Forearm,
427  Bone_R_Hand,
428 
429  Bone_Head,
430  Bone_Neck,
431  Bone_L_Toe0,
432  Bone_R_Toe0,
433 
434  Bone_R_Finger0,
435  Bone_L_Finger0,
436 
437  Bone_Spine1,
438  Bone_Spine2,
439  Bone_Spine3,
440 
441  Bone_forehand,
442  Bone_L_eyelid,
443  Bone_R_eyelid,
444  Bone_L_eye,
445  Bone_R_eye,
446  Bone_B_eyelid,
447  Bone_upper_lip,
448  Bone_L_lip,
449  Bone_R_lip,
450  Bone_B_lip,
451  Bone_chin,
452 
453  Bone_R_Finger01,
454  Bone_L_Finger01,
455  Bone_R_Finger1,
456  Bone_L_Finger1,
457  Bone_R_Finger11,
458  Bone_L_Finger11,
459  Bone_R_Finger2,
460  Bone_L_Finger2,
461  Bone_R_Finger21,
462  Bone_L_Finger21,
463 
464  MAX_KNOWN_BONE_NODE,
465 };
466 }
ParaX vertices definition.
Definition: modelheaders.h:150
DWORD type
ParaXModelType.
Definition: modelheaders.h:35
Definition: modelheaders.h:397
uint32 flags
1 for non-looping
Definition: modelheaders.h:173
different physics engine has different winding order.
Definition: EventBinding.h:32
DWORD nModelFormat
bit wise of ParaXModelFormat. default to 0
Definition: modelheaders.h:40
DWORD nType
0 stand for ModelVertex
Definition: modelheaders.h:153
Definition: modelheaders.h:302
Definition: modelheaders.h:199
Definition: modelheaders.h:226
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
One material + render operation.
Definition: modelheaders.h:247
Definition: modelheaders.h:296
Definition: modelheaders.h:342
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
KNOWN_BONE_NODES
all known bones
Definition: modelheaders.h:406
ParaX header definition: this header is shared by all ParaEngine model files.
Definition: modelheaders.h:31
A texture unit (sub of material)
Definition: modelheaders.h:272
Definition: modelheaders.h:222
Definition: modelheaders.h:383
Definition: modelheaders.h:319
Definition: modelheaders.h:330
old texture definition for md2 file
Definition: modelheaders.h:142
old header for md2 file
Definition: modelheaders.h:58
Definition: modelheaders.h:306
Definition: modelheaders.h:364
Definition: modelheaders.h:236
Definition: modelheaders.h:290
Definition: modelheaders.h:165
ParaX indice for view 0.
Definition: modelheaders.h:159
Definition: modelheaders.h:186