27 #ifndef WINTERMUTE_XFILE_LOADER_H 28 #define WINTERMUTE_XFILE_LOADER_H 30 #include "common/str.h" 31 #include "common/stack.h" 35 enum XTokenType : uint16 {
36 XTOKEN_ERROR = 0xffff,
42 XTOKEN_INTEGER_LIST = 6,
43 XTOKEN_FLOAT_LIST = 7,
54 XTOKEN_SEMICOLON = 20,
71 #define XMAX_NAME_LEN 120 72 #define XMAX_STRING_LEN 500 76 char _textVal[XMAX_STRING_LEN];
93 uint32 _numFaceVertexIndices;
94 uint32 _faceVertexIndices[4];
120 uint32 _numFaceIndexes;
121 uint32 *_faceIndexes{};
124 delete[] _faceIndexes;
129 uint32 _nOriginalVertices;
139 uint32 _nMaxSkinWeightsPerVertex;
140 uint32 _nMaxSkinWeightsPerFace;
145 char _transformNodeName[XMAX_NAME_LEN];
146 uint32 _numVertexIndices;
147 uint32 *_vertexIndices{};
150 float _matrixOffset[16];
153 delete[] _vertexIndices;
173 uint32 _numFaceNormals;
178 delete[] _faceNormals;
183 uint32 _numVertexColors;
187 delete[] _vertexColors;
192 uint32 _numTextureCoords;
196 delete[] _textureCoords;
215 char _filename[XMAX_NAME_LEN];
219 uint32 _animTicksPerSecond;
240 uint32 _positionquality;
247 float _frameMatrix[16];
274 kXClassAnimTicksPerSecond,
275 kXClassFrameTransformMatrix,
279 kXClassMeshVertexColors,
280 kXClassMeshTextureCoords,
281 kXClassMeshMaterialList,
282 kXClassVertexDuplicationIndices,
284 kXClassTextureFilename,
285 kXClassSkinMeshHeader,
290 kXClassAnimationOptions,
305 XClassType _classType{};
313 switch (_classType) {
314 case kXClassAnimTicksPerSecond:
317 case kXClassAnimationKey:
320 case kXClassAnimation:
323 case kXClassAnimationOptions:
326 case kXClassAnimationSet:
329 case kXClassDeclData:
335 case kXClassFrameTransformMatrix:
341 case kXClassMaterial:
347 case kXClassMeshMaterialList:
350 case kXClassMeshNormals:
353 case kXClassMeshVertexColors:
356 case kXClassMeshTextureCoords:
359 case kXClassSkinMeshHeader:
362 case kXClassSkinWeights:
365 case kXClassVertexDuplicationIndices:
368 case kXClassTextureFilename:
382 const int kCabBlockSize = 0x8000;
383 const int kCabInputmax = kCabBlockSize + 12;
387 byte *_decompBuffer{};
391 uint32 _listNbElements;
402 bool load(byte *buffer, uint32 bufferSize);
410 FORCEINLINE
bool readChar(
char &c);
411 FORCEINLINE
void rewindBytes(uint32 size);
412 bool readBytes(
void *data, uint32 size);
413 bool readLE16(uint16 *data);
414 bool readLE32(uint32 *data);
415 bool readBE32(uint32 *data);
417 FORCEINLINE
bool getInteger(uint32 &value);
418 FORCEINLINE
bool getFloat(
float &value);
419 FORCEINLINE
bool getString(
char *str, uint maxLen);
420 FORCEINLINE
bool skipSemicolonComma();
422 FORCEINLINE
bool isSpace(
char c);
423 FORCEINLINE
bool isOperator(
char c);
424 FORCEINLINE
bool isSeparator(
char c);
425 FORCEINLINE
bool isPrimitiveType(XTokenType token);
426 FORCEINLINE
bool isGuid();
427 FORCEINLINE
bool isName();
428 FORCEINLINE
bool isFloat();
429 FORCEINLINE
bool isInteger();
430 FORCEINLINE
bool isString();
431 FORCEINLINE
bool isKeyword(
const char *keyword, uint len);
432 FORCEINLINE XTokenType getKeywordToken();
433 FORCEINLINE XTokenType checkToken();
434 XTokenType getToken();
437 bool decompressMsZipData();
441 bool parseTemplate();
442 bool parseTemplateParts();
443 bool parseTemplateOptionInfo();
444 bool parseTemplateMembersList();
447 bool parseObject(
XObject *
object);
448 bool parseChildObjects(
XObject *
object);
449 bool parseObjectParts(
XObject *
object);
462 bool getChild(uint
id,
XFileData &child) {
464 if (id < _xobject->_children.size()) {
465 child._xobject = _xobject->_children[id];
466 if (child._xobject->_targetObject) {
467 child._xobject = child._xobject->_targetObject;
468 child._reference =
true;
476 bool getChildren(uint &num) {
478 num = _xobject->_children.size();
486 name = _xobject->_name;
492 bool getType(XClassType &classType) {
494 classType = _xobject->_classType;
507 #define GET_OBJECT_FUNC(objectName) \ 508 objectName *get ## objectName() { \ 510 return static_cast<objectName *>(_xobject->_object); \ 545 bool getChild(uint
id,
XFileData &child) {
547 if (id < _file->_xobjects.size()) {
548 child._xobject = _file->_xobjects[id];
555 bool getChildren(uint &num) {
557 num = _file->_xobjects.size();
Definition: xfile_loader.h:200
Definition: xfile_loader.h:128
Definition: xfile_loader.h:214
Definition: xfile_loader.h:170
Definition: xfile_loader.h:536
Definition: xfile_loader.h:228
Definition: xfile_loader.h:87
Definition: xfile_loader.h:262
Definition: xfile_loader.h:92
Definition: xfile_loader.h:225
Definition: xfile_loader.h:103
Definition: xfile_loader.h:243
Definition: xfile_loader.h:377
Definition: xfile_loader.h:81
Definition: xfile_loader.h:97
Definition: xfile_loader.h:111
Definition: xfile_loader.h:158
Definition: xfile_loader.h:182
Definition: xfile_loader.h:191
Definition: xfile_loader.h:118
Definition: xfile_loader.h:218
Definition: xfile_loader.h:144
Definition: xfile_loader.h:222
Definition: xfile_loader.h:74
Definition: xfile_loader.h:297
Definition: xfile_loader.h:250
Definition: xfile_loader.h:452
Definition: achievements_tables.h:27
Definition: xfile_loader.h:238