My Project
MDXModel.h
1 #pragma once
2 
3 #include "skeleton.h"
4 #include "geoset.h"
5 #include "texture.h"
6 #include "material.h"
7 #include "sequence.h"
8 #include "ModelUtils.h"
9 #include "GeosetAnim.h"
10 #include "utils.h"
11 
12 namespace ParaEngine
13 {
14 extern void *malloc_func(const size_t size);
15 extern void free_func(void* ptr);
16 extern DWORD FromMPQ1(char*szFichier, char*& buffer);
17 extern DWORD FromMPQ(char*szFichier, char*& buffer);
18 
19 
20 struct camera
21 {
22  char cName[80];
23  float posx;
24  float posy;
25  float posz;
26  float cFOV;
27  float farClip;
28  float nearClip;
29  float targetx;
30  float targety;
31  float targetz;
32 };
33 
34 class CCameras
35 {
36 #define MAX_CAMERAS 32
37 public:
38  int mNumCameras;
39  camera* mCameras;
40  BOOL mLoaded;
41 
42  CCameras() : mNumCameras(NULL),mLoaded(false), mCameras(NULL) { }
43  ~CCameras();
44 
45  void Read (TypePointer inP, int inSize);
46  void Render (void);
47 public:
48  void Cleanup();
49 };
50 
51 struct SceneState;
52 struct ParaXFile;
53 class ShadowVolume;
54 struct LightParams;
61 class CMDXModel
62 {
63 public:
64  CMDXModel(void);
65  ~CMDXModel(void);
66 
67  bool Load(const char* inName);
68 
69  bool LoadFromX(const char* inName);
70  bool SaveToX(const char* inName, bool bText);
71 
72  void InitDeviceObjects();
73  void DeleteDeviceObjects();
74 
75  void AdvanceTime( double dTimeDelta );
76  void Render(SceneState* sceneState);
77 
78  void UpdateAnim(int animNum);
79  int GetAnimNum(const char* animName);
80  void PreviousAnim();
81  void NextAnim();
82  void SetModelColor(float r,float g,float b);
83  void SetModelColor(D3DXCOLOR modelcolor);
84  D3DXCOLOR* GetModelColor(){return &modelColor;};
85  void SetBlendingTime(float fTime);
86  void BuildShadowVolume(ShadowVolume * pShadowVolume, LightParams* pLight, D3DXMATRIX* mxWorld);
87 
95  float ComputeBoundingBox(D3DXVECTOR3 *pMin, D3DXVECTOR3 *pMax );
96 
97 public:
98  CSkeleton skeleton;
99  CGeoset geosets;
100  CMaterialMap materialMap;
101  CTexture texture;
102  CSequence sequences;
103  CCameras cameras;
104 
105  AnimInfo currentAnimInfo;
106  AnimInfo nextAnimInfo;
107  float fBlendingTime; // blending time in seconds
108 
109  // shadow cap
110  int m_nUseShadowCap; // value >0, if enforcing the model to use caps in its shadow volume, default is 0
111  // index of the default animation
112  int nDefaultStandIndex;
113  int nDefaultWalkIndex;
114 protected:
115 private:
116  long dataSize;
117  static char* mdxData;
118  static ParaXFile* xData;
119  D3DXCOLOR modelColor;
120 
121  void ParseXFileData(ID3DXFileData *pData);
122  bool BuildFromX();
123 
124 public:
125  // Set/get the current Animation info
126  void SetCurrentAnimInfo(AnimInfo* ai){currentAnimInfo = *ai;};
127  void GetCurrentAnimInfo(AnimInfo* ai){*ai = currentAnimInfo;};
128 };
129 }
An X file model must contain only one geoset which is a collection of geochunks.
Definition: Geoset.h:25
ShadowVolume is a structure for storing shadow volume geometries.
Definition: ShadowVolume.h:39
It's used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
Each x file model must has a skeleton(including static object) A skeleton contains a collection of bo...
Definition: Bone.h:317
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: utils.h:13
Definition: MDXModel.h:20
LightParams is a structure for which a shadow volume is built.
Definition: ShadowVolume.h:8
Definition: Material.h:75
Model textures are managed separately with the paraengine asset manager's texture pool...
Definition: Texture.h:32
this is intermediary structure for parsing Para X file.
Definition: ParaEngineXFileDef.h:287
Definition: MDXModel.h:34
Definition: ModelUtils.h:7
This is the ParaX mesh and animation file format model.
Definition: MDXModel.h:61
A collection of animation sequences.
Definition: Sequence.h:26