diff --git a/code/LWOFileData.h b/code/LWOFileData.h index 0a278dc7d..aed288ec3 100644 --- a/code/LWOFileData.h +++ b/code/LWOFileData.h @@ -118,6 +118,7 @@ namespace LWO { #define AI_LWO_PTCH AI_IFF_FOURCC('P','T','C','H') #define AI_LWO_MBAL AI_IFF_FOURCC('M','B','A','L') #define AI_LWO_BONE AI_IFF_FOURCC('B','O','N','E') +#define AI_LWO_SUBD AI_IFF_FOURCC('S','U','B','D') /* polygon tags */ #define AI_LWO_SURF AI_IFF_FOURCC('S','U','R','F') diff --git a/code/LWOLoader.cpp b/code/LWOLoader.cpp index 51ab3d814..633efccfe 100644 --- a/code/LWOLoader.cpp +++ b/code/LWOLoader.cpp @@ -149,15 +149,17 @@ void LWOImporter::InternReadFile( const std::string& pFile, DefaultLogger::get()->info("LWO file format: LWOB (<= LightWave 5.5)"); mIsLWO2 = false; + mIsLXOB = false; LoadLWOBFile(); } - // New lightwave format else if (AI_LWO_FOURCC_LWO2 == fileType) { + mIsLXOB = false; DefaultLogger::get()->info("LWO file format: LWO2 (>= LightWave 6)"); } // MODO file format else if (AI_LWO_FOURCC_LXOB == fileType) { + mIsLXOB = true; DefaultLogger::get()->info("LWO file format: LXOB (Modo)"); } // we don't know this format @@ -727,9 +729,6 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length) switch (type) { // read unsupported stuff too (although we wont process it) - case AI_LWO_BONE: - DefaultLogger::get()->warn("LWO2: Encountered unsupported primitive chunk (BONE)"); - break; case AI_LWO_MBAL: DefaultLogger::get()->warn("LWO2: Encountered unsupported primitive chunk (METABALL)"); break; @@ -740,6 +739,8 @@ void LWOImporter::LoadLWO2Polygons(unsigned int length) // These are ok with no restrictions case AI_LWO_PTCH: case AI_LWO_FACE: + case AI_LWO_BONE: + case AI_LWO_SUBD: break; default: @@ -1144,6 +1145,18 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length) // Get the index of the envelope envelope.index = ReadVSizedIntLWO2(mFileBuffer); + // It looks like there might be an extra U4 right after the index, + // at least in modo (LXOB) files: we'll ignore it if it's zero, + // otherwise it represents the start of a subchunk, so we backtrack. + if (mIsLXOB) + { + uint32_t extra = GetU4(); + if (extra) + { + mFileBuffer -= 4; + } + } + // ... and read all subchunks while (true) { diff --git a/code/LWOLoader.h b/code/LWOLoader.h index d70a275d7..43ed2039a 100644 --- a/code/LWOLoader.h +++ b/code/LWOLoader.h @@ -363,6 +363,9 @@ protected: /** true if the file is a LWO2 file*/ bool mIsLWO2; + /** true if the file is a LXOB file*/ + bool mIsLXOB; + /** Temporary list of layers from the file */ LayerList* mLayers; diff --git a/contrib/ConvertUTF/ConvertUTF.h b/contrib/ConvertUTF/ConvertUTF.h index e26491536..05e800ad8 100644 --- a/contrib/ConvertUTF/ConvertUTF.h +++ b/contrib/ConvertUTF/ConvertUTF.h @@ -19,7 +19,8 @@ * for internal or external distribution as long as this notice * remains attached. */ - +#ifndef CONVERTUTF_H +#define CONVERTUTF_H /* --------------------------------------------------------------------- Conversions between UTF32, UTF-16, and UTF-8. Header file. @@ -147,3 +148,4 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); #endif /* --------------------------------------------------------------------- */ +#endif // CONVERTUTF_H