diff --git a/code/MDLLoader.cpp b/code/MDLLoader.cpp index 0adec11d7..6f741bd48 100644 --- a/code/MDLLoader.cpp +++ b/code/MDLLoader.cpp @@ -298,26 +298,31 @@ void MDLImporter::ValidateHeader_Quake1(const MDL::Header* pcHeader) DefaultLogger::get()->warn("Skin width or height are 0"); } } + #ifdef AI_BUILD_BIG_ENDIAN // ------------------------------------------------------------------------------------------------ void FlipQuakeHeader(BE_NCONST MDL::Header* pcHeader) { - ByteSwap::Swap4(& pcHeader->ident); - ByteSwap::Swap4(& pcHeader->version); - ByteSwap::Swap4(& pcHeader->boundingradius); - ByteSwap::Swap4(& pcHeader->flags); - ByteSwap::Swap4(& pcHeader->num_frames); - ByteSwap::Swap4(& pcHeader->num_skins); - ByteSwap::Swap4(& pcHeader->num_tris); - ByteSwap::Swap4(& pcHeader->num_verts); + AI_SWAP4( pcHeader->ident); + AI_SWAP4( pcHeader->version); + AI_SWAP4( pcHeader->boundingradius); + AI_SWAP4( pcHeader->flags); + AI_SWAP4( pcHeader->num_frames); + AI_SWAP4( pcHeader->num_skins); + AI_SWAP4( pcHeader->num_tris); + AI_SWAP4( pcHeader->num_verts); for (unsigned int i = 0; i < 3;++i) { - ByteSwap::Swap4(& pcHeader->scale[i]); - ByteSwap::Swap4(& pcHeader->translate[i]); + AI_SWAP4( pcHeader->scale[i]); + AI_SWAP4( pcHeader->translate[i]); } - ByteSwap::Swap4(& pcHeader->size); - ByteSwap::Swap4(& pcHeader->skinheight); + AI_SWAP4( pcHeader->size); + AI_SWAP4( pcHeader->skinheight); + AI_SWAP4( pcHeader->skinwidth); + AI_SWAP4( pcHeader->synctype); + // ByteSwap::Swap4(& pcHeader->skin); + } #endif // ------------------------------------------------------------------------------------------------ @@ -325,19 +330,19 @@ void MDLImporter::InternReadFile_Quake1( ) { ai_assert(NULL != pScene); - BE_NCONST MDL::Header* pcHeader = (BE_NCONST MDL::Header*)this->mBuffer; + mpcHeader = (BE_NCONST MDL::Header*)this->mBuffer; #ifdef AI_BUILD_BIG_ENDIAN - FlipQuakeHeader(pcHeader); + FlipQuakeHeader(mpcHeader); #endif - ValidateHeader_Quake1(pcHeader); + ValidateHeader_Quake1(mpcHeader); // current cursor position in the file - const unsigned char* szCurrent = (const unsigned char*)(pcHeader+1); + const unsigned char* szCurrent = (const unsigned char*)(mpcHeader+1); // need to read all textures - for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i) + for (unsigned int i = 0; i < (unsigned int)mpcHeader->num_skins;++i) { union{BE_NCONST MDL::Skin* pcSkin;BE_NCONST MDL::GroupSkin* pcGroupSkin;}; pcSkin = (BE_NCONST MDL::Skin*)szCurrent; @@ -360,7 +365,7 @@ void MDLImporter::InternReadFile_Quake1( ) this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float)); } // go to the end of the skin section / the beginning of the next skin - szCurrent += pcHeader->skinheight * pcHeader->skinwidth + + szCurrent += mpcHeader->skinheight * mpcHeader->skinwidth + sizeof(float) * iNumImages; } } @@ -375,11 +380,11 @@ void MDLImporter::InternReadFile_Quake1( ) } // get a pointer to the texture coordinates BE_NCONST MDL::TexCoord* pcTexCoords = (BE_NCONST MDL::TexCoord*)szCurrent; - szCurrent += sizeof(MDL::TexCoord) * pcHeader->num_verts; + szCurrent += sizeof(MDL::TexCoord) * mpcHeader->num_verts; // get a pointer to the triangles BE_NCONST MDL::Triangle* pcTriangles = (BE_NCONST MDL::Triangle*)szCurrent; - szCurrent += sizeof(MDL::Triangle) * pcHeader->num_tris; + szCurrent += sizeof(MDL::Triangle) * mpcHeader->num_tris; VALIDATE_FILE_SIZE(szCurrent); // now get a pointer to the first frame in the file @@ -400,24 +405,25 @@ void MDLImporter::InternReadFile_Quake1( ) BE_NCONST MDL::Vertex* pcVertices = (BE_NCONST MDL::Vertex*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name)); - VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts)); + VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + mpcHeader->num_verts)); #ifdef AI_BUILD_BIG_ENDIAN - for (unsigned int i = 0; inum_verts;++i) + for (unsigned int i = 0; inum_verts;++i) { AI_SWAP4( pcTexCoords[i].onseam ); AI_SWAP4( pcTexCoords[i].s ); AI_SWAP4( pcTexCoords[i].t ); } - for (unsigned int i = 0; inum_tris;++i) + for (unsigned int i = 0; inum_tris;++i) { AI_SWAP4( pcTriangles[i].facesfront); AI_SWAP4( pcTriangles[i].vertex[0]); AI_SWAP4( pcTriangles[i].vertex[1]); AI_SWAP4( pcTriangles[i].vertex[2]); } + #endif @@ -428,8 +434,8 @@ void MDLImporter::InternReadFile_Quake1( ) aiMesh* pcMesh = new aiMesh(); pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - pcMesh->mNumVertices = pcHeader->num_tris * 3; - pcMesh->mNumFaces = pcHeader->num_tris; + pcMesh->mNumVertices = mpcHeader->num_tris * 3; + pcMesh->mNumFaces = mpcHeader->num_tris; pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices]; pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices]; pcMesh->mFaces = new aiFace[pcMesh->mNumFaces]; @@ -447,7 +453,7 @@ void MDLImporter::InternReadFile_Quake1( ) // now iterate through all triangles unsigned int iCurrent = 0; - for (unsigned int i = 0; i < (unsigned int) pcHeader->num_tris;++i) + for (unsigned int i = 0; i < (unsigned int) mpcHeader->num_tris;++i) { pcMesh->mFaces[i].mIndices = new unsigned int[3]; pcMesh->mFaces[i].mNumIndices = 3; @@ -459,22 +465,22 @@ void MDLImporter::InternReadFile_Quake1( ) // read vertices unsigned int iIndex = pcTriangles->vertex[c]; - if (iIndex >= (unsigned int)pcHeader->num_verts) + if (iIndex >= (unsigned int)mpcHeader->num_verts) { - iIndex = pcHeader->num_verts-1; + iIndex = mpcHeader->num_verts-1; DefaultLogger::get()->warn("Index overflow in Q1-MDL vertex list."); } aiVector3D& vec = pcMesh->mVertices[iCurrent]; - vec.x = (float)pcVertices[iIndex].v[0] * pcHeader->scale[0]; - vec.x += pcHeader->translate[0]; + vec.x = (float)pcVertices[iIndex].v[0] * mpcHeader->scale[0]; + vec.x += mpcHeader->translate[0]; - vec.y = (float)pcVertices[iIndex].v[1] * pcHeader->scale[1]; - vec.y += pcHeader->translate[1]; + vec.y = (float)pcVertices[iIndex].v[1] * mpcHeader->scale[1]; + vec.y += mpcHeader->translate[1]; vec.y *= -1.0f; - vec.z = (float)pcVertices[iIndex].v[2] * pcHeader->scale[2]; - vec.z += pcHeader->translate[2]; + vec.z = (float)pcVertices[iIndex].v[2] * mpcHeader->scale[2]; + vec.z += mpcHeader->translate[2]; // read the normal vector from the precalculated normal table MD2::LookupNormalIndex(pcVertices[iIndex].normalIndex,pcMesh->mNormals[iCurrent]); @@ -488,12 +494,12 @@ void MDLImporter::InternReadFile_Quake1( ) if (0 == pcTriangles->facesfront && 0 != pcTexCoords[iIndex].onseam) { - s += pcHeader->skinwidth * 0.5f; + s += mpcHeader->skinwidth * 0.5f; } // Scale s and t to range from 0.0 to 1.0 - pcMesh->mTextureCoords[0][iCurrent].x = (s + 0.5f) / pcHeader->skinwidth; - pcMesh->mTextureCoords[0][iCurrent].y = 1.0f-(t + 0.5f) / pcHeader->skinheight; + pcMesh->mTextureCoords[0][iCurrent].x = (s + 0.5f) / mpcHeader->skinwidth; + pcMesh->mTextureCoords[0][iCurrent].y = 1.0f-(t + 0.5f) / mpcHeader->skinheight; } pcMesh->mFaces[i].mIndices[0] = iTemp+2; @@ -553,21 +559,21 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) ai_assert(NULL != pScene); // the header of MDL 3/4/5 is nearly identical to the original Quake1 header - BE_NCONST MDL::Header* pcHeader = (BE_NCONST MDL::Header*)this->mBuffer; + mpcHeader = (BE_NCONST MDL::Header*)this->mBuffer; #ifdef AI_BUILD_BIG_ENDIAN - FlipQuakeHeader(pcHeader); + FlipQuakeHeader(mpcHeader); #endif - this->ValidateHeader_Quake1(pcHeader); + this->ValidateHeader_Quake1(mpcHeader); // current cursor position in the file - const unsigned char* szCurrent = (const unsigned char*)(pcHeader+1); + const unsigned char* szCurrent = (const unsigned char*)(mpcHeader+1); // need to read all textures - for (unsigned int i = 0; i < (unsigned int)pcHeader->num_skins;++i) + for (unsigned int i = 0; i < (unsigned int)mpcHeader->num_skins;++i) { - const MDL::Skin* pcSkin; - pcSkin = (const MDL::Skin*)szCurrent; - + BE_NCONST MDL::Skin* pcSkin; + pcSkin = (BE_NCONST MDL::Skin*)szCurrent; + AI_SWAP4( pcSkin->group); // create one output image unsigned int iSkip = i ? 0xffffffff : 0; if (5 <= this->iGSFileVersion) @@ -587,30 +593,30 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) } // get a pointer to the texture coordinates BE_NCONST MDL::TexCoord_MDL3* pcTexCoords = (BE_NCONST MDL::TexCoord_MDL3*)szCurrent; - szCurrent += sizeof(MDL::TexCoord_MDL3) * pcHeader->synctype; + szCurrent += sizeof(MDL::TexCoord_MDL3) * mpcHeader->synctype; // NOTE: for MDLn formats "synctype" corresponds to the number of UV coords // get a pointer to the triangles BE_NCONST MDL::Triangle_MDL3* pcTriangles = (BE_NCONST MDL::Triangle_MDL3*)szCurrent; - szCurrent += sizeof(MDL::Triangle_MDL3) * pcHeader->num_tris; + szCurrent += sizeof(MDL::Triangle_MDL3) * mpcHeader->num_tris; #ifdef AI_BUILD_BIG_ENDIAN - for (unsigned int i = 0; isynctype;++i) + for (unsigned int i = 0; isynctype;++i) { AI_SWAP2( pcTexCoords[i].u ); AI_SWAP2( pcTexCoords[i].v ); } - for (unsigned int i = 0; inum_tris;++i) + for (unsigned int i = 0; inum_tris;++i) { - AI_SWAP4( pcTriangles[i].index_xyz[0]); - AI_SWAP4( pcTriangles[i].index_xyz[1]); - AI_SWAP4( pcTriangles[i].index_xyz[2]); - AI_SWAP4( pcTriangles[i].index_uv[0]); - AI_SWAP4( pcTriangles[i].index_uv[1]); - AI_SWAP4( pcTriangles[i].index_uv[2]); + AI_SWAP2( pcTriangles[i].index_xyz[0]); + AI_SWAP2( pcTriangles[i].index_xyz[1]); + AI_SWAP2( pcTriangles[i].index_xyz[2]); + AI_SWAP2( pcTriangles[i].index_uv[0]); + AI_SWAP2( pcTriangles[i].index_uv[1]); + AI_SWAP2( pcTriangles[i].index_uv[2]); } #endif @@ -624,8 +630,8 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) aiMesh* pcMesh = new aiMesh(); pcMesh->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; - pcMesh->mNumVertices = pcHeader->num_tris * 3; - pcMesh->mNumFaces = pcHeader->num_tris; + pcMesh->mNumVertices = mpcHeader->num_tris * 3; + pcMesh->mNumFaces = mpcHeader->num_tris; pcMesh->mFaces = new aiFace[pcMesh->mNumFaces]; // there won't be more than one mesh inside the file @@ -638,18 +644,19 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) pScene->mMeshes[0] = pcMesh; // allocate output storage - pcMesh->mNumVertices = (unsigned int)pcHeader->num_tris*3; + pcMesh->mNumVertices = (unsigned int)mpcHeader->num_tris*3; pcMesh->mVertices = new aiVector3D[pcMesh->mNumVertices]; pcMesh->mNormals = new aiVector3D[pcMesh->mNumVertices]; - if (pcHeader->synctype) + if (mpcHeader->synctype) { pcMesh->mTextureCoords[0] = new aiVector3D[pcMesh->mNumVertices]; pcMesh->mNumUVComponents[0] = 2; } // now get a pointer to the first frame in the file - const MDL::Frame* pcFrames = (const MDL::Frame*)szCurrent; + BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent; + AI_SWAP4(pcFrames->type); // byte packed vertices // BIG TODO: these two snippets are nearly totally identical ... @@ -662,11 +669,11 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) const MDL::Vertex* pcVertices = (const MDL::Vertex*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name)); - VALIDATE_FILE_SIZE(pcVertices + pcHeader->num_verts); + VALIDATE_FILE_SIZE(pcVertices + mpcHeader->num_verts); // now iterate through all triangles unsigned int iCurrent = 0; - for (unsigned int i = 0; i < (unsigned int) pcHeader->num_tris;++i) + for (unsigned int i = 0; i < (unsigned int) mpcHeader->num_tris;++i) { pcMesh->mFaces[i].mIndices = new unsigned int[3]; pcMesh->mFaces[i].mNumIndices = 3; @@ -676,29 +683,29 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) { // read vertices unsigned int iIndex = pcTriangles->index_xyz[c]; - if (iIndex >= (unsigned int)pcHeader->num_verts) + if (iIndex >= (unsigned int)mpcHeader->num_verts) { - iIndex = pcHeader->num_verts-1; + iIndex = mpcHeader->num_verts-1; DefaultLogger::get()->warn("Index overflow in MDLn vertex list"); } aiVector3D& vec = pcMesh->mVertices[iCurrent]; - vec.x = (float)pcVertices[iIndex].v[0] * pcHeader->scale[0]; - vec.x += pcHeader->translate[0]; + vec.x = (float)pcVertices[iIndex].v[0] * mpcHeader->scale[0]; + vec.x += mpcHeader->translate[0]; - vec.y = (float)pcVertices[iIndex].v[1] * pcHeader->scale[1]; - vec.y += pcHeader->translate[1]; + vec.y = (float)pcVertices[iIndex].v[1] * mpcHeader->scale[1]; + vec.y += mpcHeader->translate[1]; vec.y *= -1.0f; - vec.z = (float)pcVertices[iIndex].v[2] * pcHeader->scale[2]; - vec.z += pcHeader->translate[2]; + vec.z = (float)pcVertices[iIndex].v[2] * mpcHeader->scale[2]; + vec.z += mpcHeader->translate[2]; // read the normal vector from the precalculated normal table MD2::LookupNormalIndex(pcVertices[iIndex].normalIndex,pcMesh->mNormals[iCurrent]); pcMesh->mNormals[iCurrent].y *= -1.0f; // read texture coordinates - if (pcHeader->synctype) + if (mpcHeader->synctype) { this->ImportUVCoordinate_3DGS_MDL345(pcMesh->mTextureCoords[0][iCurrent], pcTexCoords,pcTriangles->index_uv[c]); @@ -722,11 +729,11 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) const MDL::Vertex_MDL4* pcVertices = (const MDL::Vertex_MDL4*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name)); - VALIDATE_FILE_SIZE(pcVertices + pcHeader->num_verts); + VALIDATE_FILE_SIZE(pcVertices + mpcHeader->num_verts); // now iterate through all triangles unsigned int iCurrent = 0; - for (unsigned int i = 0; i < (unsigned int) pcHeader->num_tris;++i) + for (unsigned int i = 0; i < (unsigned int) mpcHeader->num_tris;++i) { pcMesh->mFaces[i].mIndices = new unsigned int[3]; pcMesh->mFaces[i].mNumIndices = 3; @@ -736,29 +743,29 @@ void MDLImporter::InternReadFile_3DGS_MDL345( ) { // read vertices unsigned int iIndex = pcTriangles->index_xyz[c]; - if (iIndex >= (unsigned int)pcHeader->num_verts) + if (iIndex >= (unsigned int)mpcHeader->num_verts) { - iIndex = pcHeader->num_verts-1; + iIndex = mpcHeader->num_verts-1; DefaultLogger::get()->warn("Index overflow in MDLn vertex list"); } aiVector3D& vec = pcMesh->mVertices[iCurrent]; - vec.x = (float)pcVertices[iIndex].v[0] * pcHeader->scale[0]; - vec.x += pcHeader->translate[0]; + vec.x = (float)pcVertices[iIndex].v[0] * mpcHeader->scale[0]; + vec.x += mpcHeader->translate[0]; - vec.y = (float)pcVertices[iIndex].v[1] * pcHeader->scale[1]; - vec.y += pcHeader->translate[1]; + vec.y = (float)pcVertices[iIndex].v[1] * mpcHeader->scale[1]; + vec.y += mpcHeader->translate[1]; vec.y *= -1.0f; - vec.z = (float)pcVertices[iIndex].v[2] * pcHeader->scale[2]; - vec.z += pcHeader->translate[2]; + vec.z = (float)pcVertices[iIndex].v[2] * mpcHeader->scale[2]; + vec.z += mpcHeader->translate[2]; // read the normal vector from the precalculated normal table MD2::LookupNormalIndex(pcVertices[iIndex].normalIndex,pcMesh->mNormals[iCurrent]); pcMesh->mNormals[iCurrent].y *= -1.0f; // read texture coordinates - if (pcHeader->synctype) + if (mpcHeader->synctype) { this->ImportUVCoordinate_3DGS_MDL345(pcMesh->mTextureCoords[0][iCurrent], pcTexCoords,pcTriangles->index_uv[c]); diff --git a/code/MDLLoader.h b/code/MDLLoader.h index fa98126b5..e4255d82b 100644 --- a/code/MDLLoader.h +++ b/code/MDLLoader.h @@ -446,6 +446,9 @@ protected: /** Buffer to hold the loaded file */ unsigned char* mBuffer; + + /**Endian converted header of the file. This is espcially important for be targets */ + BE_NCONST MDL::Header *mpcHeader; /** For GameStudio MDL files: The number in the magic word, either 3,4 or 5 * (MDL7 doesn't need this, the format has a separate loader) */ diff --git a/code/MDLMaterialLoader.cpp b/code/MDLMaterialLoader.cpp index 7f3abcdca..96f52732b 100644 --- a/code/MDLMaterialLoader.cpp +++ b/code/MDLMaterialLoader.cpp @@ -114,14 +114,13 @@ aiColor4D MDLImporter::ReplaceTextureWithColor(const aiTexture* pcTexture) // ------------------------------------------------------------------------------------------------ void MDLImporter::CreateTextureARGB8_3DGS_MDL3(const unsigned char* szData) { - const MDL::Header* pcHeader = (const MDL::Header*)this->mBuffer; - VALIDATE_FILE_SIZE(szData + pcHeader->skinwidth * - pcHeader->skinheight); + VALIDATE_FILE_SIZE(szData + mpcHeader->skinwidth * + mpcHeader->skinheight); // allocate a new texture object aiTexture* pcNew = new aiTexture(); - pcNew->mWidth = pcHeader->skinwidth; - pcNew->mHeight = pcHeader->skinheight; + pcNew->mWidth = mpcHeader->skinwidth; + pcNew->mHeight = mpcHeader->skinheight; pcNew->pcData = new aiTexel[pcNew->mWidth * pcNew->mHeight]; @@ -158,8 +157,6 @@ void MDLImporter::CreateTexture_3DGS_MDL4(const unsigned char* szData, unsigned int iType, unsigned int* piSkip) { - const MDL::Header* pcHeader = (const MDL::Header*)this->mBuffer; - ai_assert(NULL != piSkip); if (iType == 1 || iType > 3) @@ -172,8 +169,8 @@ void MDLImporter::CreateTexture_3DGS_MDL4(const unsigned char* szData, // allocate a new texture object aiTexture* pcNew = new aiTexture(); - pcNew->mWidth = pcHeader->skinwidth; - pcNew->mHeight = pcHeader->skinheight; + pcNew->mWidth = mpcHeader->skinwidth; + pcNew->mHeight = mpcHeader->skinheight; if (bNoRead)pcNew->pcData = (aiTexel*)0xffffffff; this->ParseTextureColorData(szData,iType,piSkip,pcNew); @@ -224,8 +221,9 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { MDL::RGB565 val = ((MDL::RGB565*)szData)[i]; - - pcNew->pcData[i].a = 0xFF; + AI_SWAP2(val); + + pcNew->pcData[i].a = 0xFF; pcNew->pcData[i].r = (unsigned char)val.b << 3; pcNew->pcData[i].g = (unsigned char)val.g << 2; pcNew->pcData[i].b = (unsigned char)val.r << 3; @@ -254,6 +252,7 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, for (i = 0; i < pcNew->mWidth*pcNew->mHeight;++i) { MDL::ARGB4 val = ((MDL::ARGB4*)szData)[i]; + AI_SWAP2(val); pcNew->pcData[i].a = (unsigned char)val.a << 4; pcNew->pcData[i].r = (unsigned char)val.r << 4; @@ -287,9 +286,9 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, pcNew->pcData[i].a = 0xFF; pcNew->pcData[i].b = *_szData++; - pcNew->pcData[i].g = *_szData++; - pcNew->pcData[i].r = *_szData; - } + pcNew->pcData[i].g = *_szData++; + pcNew->pcData[i].r = *_szData; + } } else i = pcNew->mWidth*pcNew->mHeight; @@ -317,10 +316,10 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, const unsigned char* _szData = &szData[i*4]; pcNew->pcData[i].b = *_szData++; - pcNew->pcData[i].g = *_szData++; - pcNew->pcData[i].r = *_szData++; - pcNew->pcData[i].a = *_szData; - } + pcNew->pcData[i].g = *_szData++; + pcNew->pcData[i].r = *_szData++; + pcNew->pcData[i].a = *_szData; + } } else i = pcNew->mWidth*pcNew->mHeight; @@ -352,9 +351,9 @@ void MDLImporter::ParseTextureColorData(const unsigned char* szData, pcNew->pcData[i].a = 0xFF; pcNew->pcData[i].r = *sz++; - pcNew->pcData[i].g = *sz++; - pcNew->pcData[i].b = *sz; - } + pcNew->pcData[i].g = *sz++; + pcNew->pcData[i].b = *sz; + } this->FreePalette(szColorMap); } @@ -381,9 +380,11 @@ void MDLImporter::CreateTexture_3DGS_MDL5(const unsigned char* szData, // first read the size of the texture pcNew->mWidth = *((uint32_t*)szData); + AI_SWAP4(pcNew->mWidth); szData += sizeof(uint32_t); pcNew->mHeight = *((uint32_t*)szData); + AI_SWAP4(pcNew->mHeight); szData += sizeof(uint32_t); if (bNoRead)pcNew->pcData = (aiTexel*)0xffffffff;