My Project
ParaEngineXFileDef.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
6 {
7  DWORD nFaceVertexIndices;
8  DWORD faceVertexIndices[3];
9 };
10 
11 struct ParaXTexUV
12 {
13  DWORD nTextureCoords;
14  D3DXVECTOR2* vertices;
15 public:
16  ParaXTexUV()
17  {
18  vertices = NULL;
19  }
20  ~ParaXTexUV()
21  {
22  if(vertices)
23  delete [] vertices;
24  }
25 };
26 
28 {
29  D3DXCOLOR faceColor;
30  FLOAT power;
31  D3DXCOLOR specularColor;
32  D3DXCOLOR emissiveColor;
33  char * TextureFilename;
34 public:
36  {
37  TextureFilename = NULL;
38  }
39  ~ParaXMaterial()
40  {
41  if(TextureFilename)
42  delete []TextureFilename;
43  }
44 };
45 
47 {
48  DWORD nMaterials;
49  DWORD nFaceIndexes;
50  DWORD* faceIndexes;
51  vector <ParaXMaterial*> materials;
52 public:
54  {
55  faceIndexes = NULL;
56  }
58  {
59  if(faceIndexes)
60  delete [] faceIndexes;
61 
62  {
63  vector< ParaXMaterial* >::iterator itCurCP, itEndCP = materials.end();
64 
65  for( itCurCP = materials.begin(); itCurCP != itEndCP; ++ itCurCP)
66  {
67  delete (*itCurCP);
68  }
69  materials.clear();
70  }
71  }
72 };
73 
74 struct ParaXMesh
75 {
76  DWORD nVertices;
77  D3DXVECTOR3* vertices;
78  DWORD nFaces;
79  ParaXMeshFace* faces;
80 public:
81  ParaXMesh()
82  {
83  faces = NULL;
84  vertices = NULL;
85  }
86  ~ParaXMesh()
87  {
88  if(vertices)
89  delete [] vertices;
90  if(faces)
91  delete [] faces;
92  }
93 };
94 
95 struct ParaXNorm
96 {
97  DWORD nNormals;
98  D3DXVECTOR3* normals;
99  DWORD nFaces;
100  ParaXMeshFace* faces;
101 public:
102  ParaXNorm()
103  {
104  normals = NULL;
105  faces = NULL;
106  }
107  ~ParaXNorm()
108  {
109  if(normals)
110  delete [] normals;
111  if(faces)
112  delete [] faces;
113  }
114 };
115 
117 {
118  char transformNodeName[80];
119  int transformNodeID;
120  DWORD nWeights;
121  DWORD* vertexIndices;
122  FLOAT* weights;
123  D3DXMATRIX matrixOffset;
124 public:
126  {
127  vertexIndices = NULL;
128  weights = NULL;
129  }
130  ~ParaXSkinWeight()
131  {
132  if(vertexIndices)
133  delete [] vertexIndices;
134  if(weights)
135  delete [] weights;
136  }
137 };
138 
139 struct FrameBind
140 {
141 // we allow each vertex to bind to at most BIND_BONE_NUM bones at a time
142 // if more than three bones are available, we will select the three with the highest weight
143 #define BIND_BONE_NUM 3
144 
145  int nFrameIndex;
146  float fWeight;
147 };
148 
149 
151 {
152  ParaXMesh mesh;
153  ParaXNorm norm;
154  ParaXTexUV uvs;
155  int nParentFrame;
156  ParaXMeshMaterialList matList;
157 
158 public:
159  list <ParaXSkinWeight*> listWeights;
160 
161  ParaXGeoChunk()
162  {
163  nParentFrame = 0;
164  }
165  ~ParaXGeoChunk()
166  {
167  list< ParaXSkinWeight* >::iterator itCurCP, itEndCP = listWeights.end();
168 
169  for( itCurCP = listWeights.begin(); itCurCP != itEndCP; ++ itCurCP)
170  {
171  delete (*itCurCP);
172  }
173  listWeights.clear();
174  }
175 };
177 {
178  int frameNum;
179  int numKeySize;
180  FLOAT key[3];
181  bool comparekey(const ParaXKeyFrame3* key1)
182  {
183  if ((key[0] != key1->key[0]) ||
184  (key[1] != key1->key[1]) ||
185  (key[2] != key1->key[2]))
186  {
187  return false;
188  }
189  return true;
190  }
191 };
192 
194 {
195  int frameNum;
196  int numKeySize;
197  FLOAT key[4];
198  bool comparekey(const ParaXKeyFrame4* key1)
199  {
200  if ((key[0] != key1->key[0]) ||
201  (key[1] != key1->key[1]) ||
202  (key[2] != key1->key[2]) ||
203  (key[3] != key1->key[3]) )
204  {
205  return false;
206  }
207  return true;
208  }
209 };
210 
212 {
213  char name[80];
214  D3DXMATRIX matrix;
215  D3DXMATRIX offsetMatrix; // for bones
216  int parentID;
217 
218  enum MotionType{
219  KGTR=0,
220  KGRT,
221  KGSC,
222  MAX_MOTION
223  };
224  //key frames count
225  struct Animation
226  {
227  int timeOffset;
228  int keyFrameSize[MAX_MOTION];
229  void* keyFrames[MAX_MOTION];
230  public:
231  Animation()
232  {
233  timeOffset = 0;
234  for(int i=0;i<MAX_MOTION;i++)
235  {
236  keyFrameSize[i]=0;
237  keyFrames[i]=NULL;
238  }
239  }
240 
241  ~Animation()
242  {
243  for(int i=0;i<MAX_MOTION;i++)
244  {
245  if(keyFrames[i])
246  delete [] keyFrames[i];
247  }
248  }
249  };
250  list <Animation*> animations;
251 
252 public:
253  ParaXFrame()
254  {
255  D3DXMatrixIdentity(&offsetMatrix);
256  }
257  ~ParaXFrame()
258  {
259  list< Animation* >::iterator itCurCP, itEndCP = animations.end();
260 
261  for( itCurCP = animations.begin(); itCurCP != itEndCP; ++ itCurCP)
262  {
263  delete (*itCurCP);
264  }
265  animations.clear();
266  }
267 };
268 struct ParaXAnim
269 {
270  char* name;
271  DWORD from;
272  DWORD to;
273  int nextAnim;
274  FLOAT moveSpeed;
275  D3DXVECTOR3 minEntent;
276  D3DXVECTOR3 maxEntent;
277  FLOAT boundsRadius;
278 public:
279  ParaXAnim(){name = NULL;}
280  ~ParaXAnim(){
281  if(name)
282  delete [] name;
283  }
284 };
285 
287 struct ParaXFile
288 {
289 public:
290  vector <ParaXGeoChunk*> geoChunks;
291  vector <ParaXFrame*> frames;
292  vector <ParaXAnim*> anims;
293 public:
294  // return the index
295  int GetFrameByName(const char * name)
296  {
297  vector< ParaXFrame* >::iterator itCurCP, itEndCP = frames.end();
298 
299  int i=0;
300  for( itCurCP = frames.begin(); itCurCP != itEndCP; ++ itCurCP)
301  {
302  if( strcmp((*itCurCP)->name, name) == 0)
303  return i;
304  i++;
305  }
306  return -1;
307  }
308 
309  ParaXFile()
310  {
311  }
312 
313  ~ParaXFile()
314  {
315  {
316  vector< ParaXGeoChunk* >::iterator itCurCP, itEndCP = geoChunks.end();
317 
318  for( itCurCP = geoChunks.begin(); itCurCP != itEndCP; ++ itCurCP)
319  {
320  delete (*itCurCP);
321  }
322  geoChunks.clear();
323  }
324  {
325  vector< ParaXFrame* >::iterator itCurCP, itEndCP = frames.end();
326 
327  for( itCurCP = frames.begin(); itCurCP != itEndCP; ++ itCurCP)
328  {
329  delete (*itCurCP);
330  }
331  frames.clear();
332  }
333  {
334  vector< ParaXAnim* >::iterator itCurCP, itEndCP = anims.end();
335 
336  for( itCurCP = anims.begin(); itCurCP != itEndCP; ++ itCurCP)
337  {
338  delete (*itCurCP);
339  }
340  anims.clear();
341  }
342 
343  }
344 };
345 }
Definition: ParaEngineXFileDef.h:74
Definition: ParaEngineXFileDef.h:268
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: ParaEngineXFileDef.h:193
Definition: ParaEngineXFileDef.h:176
Definition: ParaEngineXFileDef.h:5
this is intermediary structure for parsing Para X file.
Definition: ParaEngineXFileDef.h:287
Definition: ParaEngineXFileDef.h:27
Definition: ParaEngineXFileDef.h:150
Definition: ParaEngineXFileDef.h:46
Definition: ParaEngineXFileDef.h:11
Definition: ParaEngineXFileDef.h:211
Definition: ParaEngineXFileDef.h:116
Definition: ParaEngineXFileDef.h:95
Definition: ParaEngineXFileDef.h:139
Definition: ParaEngineXFileDef.h:225