My Project
XFileParser.h
1 #pragma once
2 #include "XFileDataObject.h"
3 
4 namespace ParaEngine
5 {
6  struct ParaXHeaderDef;
7 
8  namespace XFile
9  {
10  struct Node;
11  struct Mesh;
12  struct Scene;
13  struct Material;
14  }
15 
20  {
21  public:
22  friend class XFileDataObject;
23 
27  XFileParser(const char* pBuffer, int32 nSize);
28 
30  ~XFileParser();
31 
35  XFile::Scene* GetImportedData(bool bGiveupDataOwnerhip=false);
36 
37  XFileDataObjectPtr CreateEnumObject();
38  protected:
39  void ParseHeader();
40  void ParseFile();
41  void ParseDataObjectTemplate();
42 
43  void ParseDataObjectFrame(XFile::Node *pParent);
44  void ParseDataObjectTransformationMatrix(Matrix4& pMatrix);
45  void ParseDataObjectMesh(XFile::Mesh* pMesh);
46  void ParseDataObjectMeshNormals(XFile::Mesh* pMesh);
47  void ParseDataObjectMeshTextureCoords(XFile::Mesh* pMesh);
48  void ParseDataObjectMeshVertexColors(XFile::Mesh* pMesh);
49  void ParseDataObjectMeshMaterialList(XFile::Mesh* pMesh);
50  void ParseDataObjectMaterial(XFile::Material* pMaterial);
51  void ParseDataObjectTextureFilename(std::string& pName);
52  void ParseDataObjectParaXHeader(ParaXHeaderDef& pName);
53  bool ParseUnknownDataObject();
54 
56  void FindNextNoneWhiteSpace();
57 
59  std::string GetNextToken();
60  bool IsEndOfFile();
64  void readHeadOfDataObject(std::string* poName = NULL);
65 
67  void CheckForClosingBrace();
68 
70  void CheckForSemicolon();
71 
73  void CheckForSeparator();
74 
76  void TestForSeparator();
77 
79  void GetNextTokenAsString(std::string& poString);
80 
81  void ReadUntilEndOfLine();
82  void ReadToEndOfDataObject();
83 
84  uint16 ReadBinWord();
85  uint32 ReadBinDWord();
86  uint32 ReadInt();
87 
88  float ReadFloat();
89  Vector2 ReadVector2();
90  Vector3 ReadVector3();
91  Vector3 ReadRGB();
92  LinearColor ReadRGBA();
93 
94  void ReadCharArray(char* sOutput, int nCount);
95 
97  void ThrowException(const std::string& pText);
98 
102  void FilterHierarchy(XFile::Node* pNode);
103 
104  protected:
105  uint32 mMajorVersion, mMinorVersion;
108  // counter for number arrays in binary format
109  uint32 mBinaryNumCount;
110 
111  const char* P;
112  const char* End;
113 
115  uint32 mLineNumber;
116 
119  };
120 }
121 
122 
Helper structure analogue to aiScene.
Definition: XFileHelper.h:123
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: minilua.c:352
XFile::Scene * mScene
Imported data.
Definition: XFileParser.h:118
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
The XFileParser reads a XFile either in text or binary form and builds a temporary data structure out...
Definition: XFileParser.h:19
bool mIsBinaryFormat
true if the file is in binary, false if it's in text form
Definition: XFileParser.h:106
Standard 2-dimensional vector.
Definition: ParaVector2.h:16
ParaX header definition: this header is shared by all ParaEngine model files.
Definition: modelheaders.h:31
data object in binary format
Definition: XFileDataObject.h:10
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 XFile frame.
Definition: XFileHelper.h:102
uint32 mMinorVersion
version numbers
Definition: XFileParser.h:105
A linear, 32-bit/component floating point RGBA color.
Definition: ParaColor.h:12
uint32 mBinaryFloatSize
float size in bytes, either 4 or 8
Definition: XFileParser.h:107
uint32 mLineNumber
Line number when reading in text format.
Definition: XFileParser.h:115
Helper structure representing a XFile material.
Definition: XFileHelper.h:51