My Project
XFileCharModelExporter.h
1 #pragma once
2 #include "XFileExporter.h"
3 #include "XFileDataObject.h"
4 #include "ParaXModel.h"
5 namespace ParaEngine
6 {
7  struct UUID_t
8  {
9  unsigned long Data1;
10  unsigned short Data2;
11  unsigned short Data3;
12  unsigned char Data4[8];
13  };
14 #pragma region +[Template UUID define]
15  #define DECLARE_UUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
16  const UUID_t name \
17  = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
18 
19  /* {10000000-0000-0000-0000-123456789000} */
20  DECLARE_UUID(UUID_ParaXHeader,
21  0x10000000, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
22 
23  /* ParaXBody contains array blocks */
24  DECLARE_UUID(UUID_ParaXBody,
25  0x20000000, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
26 
27  DECLARE_UUID(UUID_ModelView,
28  0x10000007, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
29 
30  DECLARE_UUID(UUID_XViews,
31  0x20000005, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
32 
33  DECLARE_UUID(UUID_ModelTextureDef,
34  0x1000000d, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
35 
36  DECLARE_UUID(UUID_XTextures,
37  0x20000002, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
38 
39  DECLARE_UUID(UUID_AnimationBlock,
40  0x10000003, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
41 
42  /* {00000000-0000-0000-0000-123456789000} */
43  DECLARE_UUID(UUID_ModelAttachmentDef,
44  0x10000014, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
45 
46  DECLARE_UUID(UUID_XAttachments,
47  0x20000003, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
48 
49  DECLARE_UUID(UUID_XVertices,
50  0x20000001, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
51 
52  DECLARE_UUID(UUID_XIndices0,
53  0x20000006, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
54 
55  /* {00000000-0000-0000-0000-123456789000} */
56  DECLARE_UUID(UUID_ModelGeoset,
57  0x10000008, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
58 
59  DECLARE_UUID(UUID_XGeosets,
60  0x20000007, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
61 
62  DECLARE_UUID(UUID_XRenderPass,
63  0x20000008, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
64 
65  /* {00000000-0000-0000-0000-123456789000} */
66  DECLARE_UUID(UUID_ModelBoneDef,
67  0x10000004, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
68 
69  DECLARE_UUID(UUID_XBones,
70  0x20000009, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
71 
72  /* {00000000-0000-0000-0000-123456789000} */
73  DECLARE_UUID(UUID_ModelAnimation,
74  0x10000002, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
75 
76  DECLARE_UUID(UUID_XAnimations,
77  0x2000000f, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
78 
79  DECLARE_UUID(UUID_XDWORDArray,
80  0x20000010, 0x0000, 0x0000, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x00);
81 
82 #pragma endregion
83 
85  {
86  string name;
87  string type;
88  string count;
89  XFileTemplateMember_t(string _name, string _type, string _count = "") :name(_name), type(_type), count(_count) {}
90  };
91 
93  {
94  string name;
95  UUID_t uuid;
96  vector<XFileTemplateMember_t> members;
97  bool beExtend;
98  XFileTemplate_t(string _name, UUID_t _uuid, bool _beExtend = false) :name(_name), uuid(_uuid), beExtend(_beExtend) {}
99  void Init(string _name, UUID_t _uuid, bool _beExtend = false)
100  {
101  name = _name;
102  uuid = _uuid;
103  beExtend = _beExtend;
104  }
105  void clear()
106  {
107  name = "";
108  uuid = { 0x00000000, 0x0000, 0x0000,{ 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00 } };
109  beExtend = false;
110  members.clear();
111  }
112  };
113 
114 
115  struct CParaRawData;
117  public XFileExporter
118  {
119  public:
120  XFileCharModelExporter(ofstream& strm, CParaXModel* pMesh);
122 
123  static bool Export(const string& filepath, CParaXModel* pMesh);
124 
125  void ExportParaXModel(ofstream& strm);
126  private:
127 
128  static void InitTemplates();
129 
130  void WriteTemplates(ofstream& strm);
131 
132  void UUIDToBin(UUID_t guid,char* bin);
133 
134  void WriteTemplate(ofstream& strm, const XFileTemplate_t& stTem);
135  void WriteUUID(ofstream& strm, UUID_t guid);
136  void WriteTemplateMember(ofstream& strm, const XFileTemplateMember_t& memeber);
137 
138  XFileDataObjectPtr Translate();
139 
140  void Release(XFileDataObjectPtr pData);
141 
142  DWORD CountIsAnimatedValue();
143 
144  bool WriteParaXHeader(XFileDataObjectPtr pData, const string& strName = "");
145  bool WriteParaXBody(XFileDataObjectPtr pData, const string& strName = "");
146  bool WriteParaXRawData(XFileDataObjectPtr pData, const string& strName = "");
147 
148  bool WriteParaXBodyChild(XFileDataObjectPtr pData, const string& strTemplateName, const string& strName = "");
149 
150  bool WriteXGlobalSequences(XFileDataObjectPtr pData, const string& strName = "");
151  bool WriteXVertices(XFileDataObjectPtr pData, const string& strName = "");
152  bool WriteXTextures(XFileDataObjectPtr pData, const string& strName = "");
153  bool WriteXAttachments(XFileDataObjectPtr pData, const string& strName = "");
154  bool WriteXColors(XFileDataObjectPtr pData, const string& strName = "");
155  bool WriteXTransparency(XFileDataObjectPtr pData, const string& strName = "");
156  bool WriteXViews(XFileDataObjectPtr pData, const string& strName = "");
157  bool WriteXIndices0(XFileDataObjectPtr pData, const string& strName = "");
158  bool WriteXGeosets(XFileDataObjectPtr pData, const string& strName = "");
159  bool WriteXRenderPass(XFileDataObjectPtr pData, const string& strName = "");
160  bool WriteXBones(XFileDataObjectPtr pData, const string& strName = "");
161  bool WriteXTexAnims(XFileDataObjectPtr pData, const string& strName = "");
162  bool WriteXParticleEmitters(XFileDataObjectPtr pData, const string& strName = "");
163  bool WriteXRibbonEmitters(XFileDataObjectPtr pData, const string& strName = "");
164  bool WriteXCameras(XFileDataObjectPtr pData, const string& strName = "");
165  bool WriteXLights(XFileDataObjectPtr pData, const string& strName = "");
166  bool WriteXAnimations(XFileDataObjectPtr pData, const string& strName = "");
167 
173  bool WriteAnimationBlock(AnimationBlock* b, const Animated<Vector3>& anims);
174  bool WriteAnimationBlock(AnimationBlock* b, const AnimatedShort& anims);
175  bool WriteAnimationBlock(AnimationBlock* b, const Animated<float>& anims);
176  bool WriteAnimationBlock(AnimationBlock* b, const Animated<Quaternion>& anims);
177  private:
178  CParaXModel* m_pMesh;
179  CParaRawData* m_pRawData;
180  static vector<XFileTemplate_t> m_vecTemplates;
181  };
182 }
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: XFileCharModelExporter.h:92
Definition: XFileCharModelExporter.h:84
Definition: animated.h:23
Definition: XFileExporter.h:18
Definition: XFileCharModelExporter.h:116
Definition: XFileCharModelExporter.h:7
Definition: ParaXSerializer.h:29
ParaX model is the model file for character animation, etc in the game world.
Definition: ParaXModel.h:30
Definition: modelheaders.h:186