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];
100 uint32 _numFaceVertexIndices;
101 uint32 _faceVertexIndices[4];
127 uint32 _numFaceIndexes;
128 uint32 *_faceIndexes{};
131 delete[] _faceIndexes;
136 uint32 _nOriginalVertices;
146 uint32 _nMaxSkinWeightsPerVertex;
147 uint32 _nMaxSkinWeightsPerFace;
152 char _transformNodeName[XMAX_NAME_LEN];
153 uint32 _numVertexIndices;
154 uint32 *_vertexIndices{};
157 float _matrixOffset[16];
160 delete[] _vertexIndices;
180 uint32 _numFaceNormals;
185 delete[] _faceNormals;
190 uint32 _numVertexColors;
194 delete[] _vertexColors;
199 uint32 _numTextureCoords;
203 delete[] _textureCoords;
222 char _filename[XMAX_NAME_LEN];
226 uint32 _animTicksPerSecond;
247 uint32 _positionquality;
254 float _frameMatrix[16];
281 kXClassAnimTicksPerSecond,
282 kXClassFrameTransformMatrix,
286 kXClassMeshVertexColors,
287 kXClassMeshTextureCoords,
288 kXClassMeshMaterialList,
289 kXClassVertexDuplicationIndices,
291 kXClassTextureFilename,
292 kXClassSkinMeshHeader,
297 kXClassAnimationOptions,
312 XClassType _classType{};
320 switch (_classType) {
321 case kXClassAnimTicksPerSecond:
324 case kXClassAnimationKey:
327 case kXClassAnimation:
330 case kXClassAnimationOptions:
333 case kXClassAnimationSet:
336 case kXClassDeclData:
342 case kXClassFrameTransformMatrix:
348 case kXClassMaterial:
354 case kXClassMeshMaterialList:
357 case kXClassMeshNormals:
360 case kXClassMeshVertexColors:
363 case kXClassMeshTextureCoords:
366 case kXClassSkinMeshHeader:
369 case kXClassSkinWeights:
372 case kXClassVertexDuplicationIndices:
375 case kXClassTextureFilename:
389 const int kCabBlockSize = 0x8000;
390 const int kCabInputmax = kCabBlockSize + 12;
394 byte *_decompBuffer{};
398 uint32 _listNbElements;
409 bool load(byte *buffer, uint32 bufferSize);
417 FORCEINLINE
bool readChar(
char &c);
418 FORCEINLINE
void rewindBytes(uint32 size);
419 bool readBytes(
void *data, uint32 size);
420 bool readLE16(uint16 *data);
421 bool readLE32(uint32 *data);
422 bool readBE32(uint32 *data);
424 FORCEINLINE
bool getInteger(uint32 &value);
425 FORCEINLINE
bool getFloat(
float &value);
426 FORCEINLINE
bool getString(
char *str, uint maxLen);
427 FORCEINLINE
bool skipSemicolonComma();
429 FORCEINLINE
bool isSpace(
char c);
430 FORCEINLINE
bool isOperator(
char c);
431 FORCEINLINE
bool isSeparator(
char c);
432 FORCEINLINE
bool isPrimitiveType(XTokenType token);
433 FORCEINLINE
bool isGuid();
434 FORCEINLINE
bool isName();
435 FORCEINLINE
bool isFloat();
436 FORCEINLINE
bool isInteger();
437 FORCEINLINE
bool isString();
438 FORCEINLINE
bool isKeyword(
const char *keyword, uint len);
439 FORCEINLINE XTokenType getKeywordToken();
440 FORCEINLINE XTokenType checkToken();
441 XTokenType getToken();
444 bool decompressMsZipData();
448 bool parseTemplate();
449 bool parseTemplateParts();
450 bool parseTemplateOptionInfo();
451 bool parseTemplateMembersList();
454 bool parseObject(
XObject *
object);
455 bool parseChildObjects(
XObject *
object);
456 bool parseObjectParts(
XObject *
object);
469 bool getChild(uint
id,
XFileData &child) {
471 if (id < _xobject->_children.size()) {
472 child._xobject = _xobject->_children[id];
473 if (child._xobject->_targetObject) {
474 child._xobject = child._xobject->_targetObject;
475 child._reference =
true;
483 bool getChildren(uint32 &num) {
485 num = _xobject->_children.size();
493 name = _xobject->_name;
499 bool getType(XClassType &classType) {
501 classType = _xobject->_classType;
514 #define GET_OBJECT_FUNC(objectName) \ 515 objectName *get ## objectName() { \ 517 return static_cast<objectName *>(_xobject->_object); \ 552 bool getChild(uint
id,
XFileData &child) {
554 if (id < _file->_xobjects.size()) {
555 child._xobject = _file->_xobjects[id];
562 bool getChildren(uint32 &num) {
564 num = _file->_xobjects.size();
Definition: xfile_loader.h:207
Definition: xfile_loader.h:135
Definition: xfile_loader.h:221
Definition: xfile_loader.h:177
Definition: xfile_loader.h:543
Definition: xfile_loader.h:235
Definition: xfile_loader.h:81
Definition: xfile_loader.h:94
Definition: xfile_loader.h:269
Definition: xfile_loader.h:99
Definition: xfile_loader.h:232
Definition: xfile_loader.h:110
Definition: xfile_loader.h:250
Definition: xfile_loader.h:384
Definition: xfile_loader.h:104
Definition: xfile_loader.h:118
Definition: xfile_loader.h:165
Definition: xfile_loader.h:189
Definition: xfile_loader.h:198
Definition: xfile_loader.h:125
Definition: xfile_loader.h:225
Definition: xfile_loader.h:151
Definition: xfile_loader.h:229
Definition: xfile_loader.h:74
Definition: xfile_loader.h:304
Definition: xfile_loader.h:257
Definition: xfile_loader.h:459
Definition: xfile_loader.h:87
Definition: achievements_tables.h:27
Definition: xfile_loader.h:245