My Project
XFileHelper.h
1 #pragma once
2 #include "modelheaders.h"
3 #include "ParaXRefObject.h"
4 
5 #define PARAX_MAX_NUMBER_OF_TEXTURECOORDS 0x2
6 
8 #define PARAX_MAX_NUMBER_OF_COLOR_SETS 0x2
9 
10 namespace ParaEngine
11 {
12  // ---------------------------------------------------------------------------
17  : public runtime_error
18  {
19  public:
21  explicit DeadlyImportError(const std::string& pErrorText)
22  : runtime_error(pErrorText)
23  {
24  }
25  private:
26  };
27 
28  namespace XFile
29  {
30 
32  struct Face
33  {
34  uint16 mIndices[3];
35  };
36 
38  struct TexEntry
39  {
40  std::string mName;
41  bool mIsNormalMap; // true if the texname was specified in a NormalmapFilename tag
42 
43  TexEntry() { mIsNormalMap = false; }
44  TexEntry(const std::string& pName, bool pIsNormalMap = false)
45  : mName(pName), mIsNormalMap(pIsNormalMap)
46  { /* done */
47  }
48  };
49 
51  struct Material
52  {
53  std::string mName;
54  bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
55  LinearColor mDiffuse;
56  float mSpecularExponent;
57  Vector3 mSpecular;
58  Vector3 mEmissive;
59  std::vector<TexEntry> mTextures;
60 
61  int32 sceneIndex;
62 
63  Material() { mIsReference = false; sceneIndex = -1; }
64  };
65 
67  struct BoneWeight
68  {
69  unsigned int mVertex;
70  float mWeight;
71  };
72 
74  struct Bone
75  {
76  std::string mName;
77  std::vector<BoneWeight> mWeights;
78  Matrix4 mOffsetMatrix;
79  };
80 
82  struct Mesh
83  {
84  std::vector<Vector3> mPositions;
85  std::vector<Face> mPosFaces;
86  std::vector<Vector3> mNormals;
87  std::vector<Face> mNormFaces;
88  unsigned int mNumTextures;
89  std::vector<Vector2> mTexCoords[PARAX_MAX_NUMBER_OF_TEXTURECOORDS];
90  unsigned int mNumColorSets;
91  std::vector<LinearColor> mColors[PARAX_MAX_NUMBER_OF_COLOR_SETS];
92 
93  std::vector<unsigned int> mFaceMaterials;
94  std::vector<Material> mMaterials;
95 
96  std::vector<Bone> mBones;
97 
98  Mesh() { mNumTextures = 0; mNumColorSets = 0; }
99  };
100 
102  struct Node
103  {
104  std::string mName;
105  Matrix4 mTrafoMatrix;
106  Node* mParent;
107  std::vector<Node*> mChildren;
108  std::vector<Mesh*> mMeshes;
109 
110  Node() { mParent = NULL; }
111  Node(Node* pParent) { mParent = pParent; }
112  ~Node()
113  {
114  for (unsigned int a = 0; a < mChildren.size(); a++)
115  delete mChildren[a];
116  for (unsigned int a = 0; a < mMeshes.size(); a++)
117  delete mMeshes[a];
118  }
119  };
120 
121 
123  struct Scene
124  {
125  Node* mRootNode;
126 
127  ParaXHeaderDef m_header;
128 
129  std::vector<Mesh*> mGlobalMeshes; // global meshes found outside of any frames
130  std::vector<Material> mGlobalMaterials; // global materials found outside of any meshes.
131  std::vector<ParaXRefObject> m_XRefObjects;
132  Scene() { mRootNode = NULL; }
133  ~Scene()
134  {
135  delete mRootNode;
136  for (unsigned int a = 0; a < mGlobalMeshes.size(); a++)
137  delete mGlobalMeshes[a];
138  }
139  };
140 
141  } // end of namespace XFile
142 }
143 
144 
Helper structure analogue to aiScene.
Definition: XFileHelper.h:123
different physics engine has different winding order.
Definition: EventBinding.h:32
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Helper structure to represent a bone weight.
Definition: XFileHelper.h:67
ParaX header definition: this header is shared by all ParaEngine model files.
Definition: modelheaders.h:31
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
Helper structure to represent an XFile mesh.
Definition: XFileHelper.h:82
Helper structure to represent a bone in a mesh.
Definition: XFileHelper.h:74
Helper structure to represent a XFile frame.
Definition: XFileHelper.h:102
Helper structure representing a texture filename inside a material and its potential source...
Definition: XFileHelper.h:38
FOR IMPORTER PLUGINS ONLY: Simple exception class to be thrown if an unrecoverable error occurs while...
Definition: XFileHelper.h:16
Helper structure representing a XFile mesh face.
Definition: XFileHelper.h:32
A linear, 32-bit/component floating point RGBA color.
Definition: ParaColor.h:12
DeadlyImportError(const std::string &pErrorText)
Constructor with arguments.
Definition: XFileHelper.h:21
int32 sceneIndex
the index under which it was stored in the scene&#39;s material list
Definition: XFileHelper.h:61
Helper structure representing a XFile material.
Definition: XFileHelper.h:51