From 813274d8ea407c58e155eefa75afde1d115c40c5 Mon Sep 17 00:00:00 2001 From: hybrid Date: Sun, 14 Feb 2010 22:55:35 +0000 Subject: [PATCH] Fix a problem with file format differences (wrong weights) and a problem with wrongly placed bones. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3221 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CMS3DMeshFileLoader.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/Irrlicht/CMS3DMeshFileLoader.cpp b/source/Irrlicht/CMS3DMeshFileLoader.cpp index 0dcf4d2d..8b68a1c0 100644 --- a/source/Irrlicht/CMS3DMeshFileLoader.cpp +++ b/source/Irrlicht/CMS3DMeshFileLoader.cpp @@ -473,6 +473,8 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) jnt->LocalMatrix.setTranslation( core::vector3df(pJoint->Translation[0], pJoint->Translation[1], -pJoint->Translation[2]) ); + jnt->Animatedposition.set(jnt->LocalMatrix.getTranslation()); + jnt->Animatedrotation.set(jnt->LocalMatrix.getRotationDegrees()); parentNames.push_back( (c8*)pJoint->ParentName ); @@ -546,6 +548,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) } core::array vertexWeights; + f32 weightFactor=0; if ((pHeader->Version == 4) && (pPtr < buffer+fileSize)) { @@ -594,6 +597,10 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) #ifdef __BIG_ENDIAN__ subVersion = os::Byteswap::byteswap(subVersion); #endif + if (subVersion==1) + weightFactor=1.f/255.f; + else + weightFactor=1.f/100.f; pPtr += sizeof(s32); #ifdef _IRR_DEBUG_MS3D_LOADER_ @@ -730,7 +737,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) { ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); w->buffer_id = matidx; - sum -= (w->strength = vertexWeights[vertidx].weights[0]/100.f); + sum -= (w->strength = vertexWeights[vertidx].weights[0]*weightFactor); w->vertex_id = index; } boneid = vertexWeights[vertidx].boneIds[0]; @@ -738,7 +745,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) { ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); w->buffer_id = matidx; - sum -= (w->strength = vertexWeights[vertidx].weights[1]/100.f); + sum -= (w->strength = vertexWeights[vertidx].weights[1]*weightFactor); w->vertex_id = index; } boneid = vertexWeights[vertidx].boneIds[1]; @@ -746,7 +753,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) { ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); w->buffer_id = matidx; - sum -= (w->strength = vertexWeights[vertidx].weights[2]/100.f); + sum -= (w->strength = vertexWeights[vertidx].weights[2]*weightFactor); w->vertex_id = index; } boneid = vertexWeights[vertidx].boneIds[2];