Commit 813274d8 authored by hybrid's avatar hybrid

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
parent a23436f9
...@@ -473,6 +473,8 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -473,6 +473,8 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
jnt->LocalMatrix.setTranslation( jnt->LocalMatrix.setTranslation(
core::vector3df(pJoint->Translation[0], pJoint->Translation[1], -pJoint->Translation[2]) ); 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 ); parentNames.push_back( (c8*)pJoint->ParentName );
...@@ -546,6 +548,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -546,6 +548,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
} }
core::array<MS3DVertexWeights> vertexWeights; core::array<MS3DVertexWeights> vertexWeights;
f32 weightFactor=0;
if ((pHeader->Version == 4) && (pPtr < buffer+fileSize)) if ((pHeader->Version == 4) && (pPtr < buffer+fileSize))
{ {
...@@ -594,6 +597,10 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -594,6 +597,10 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
subVersion = os::Byteswap::byteswap(subVersion); subVersion = os::Byteswap::byteswap(subVersion);
#endif #endif
if (subVersion==1)
weightFactor=1.f/255.f;
else
weightFactor=1.f/100.f;
pPtr += sizeof(s32); pPtr += sizeof(s32);
#ifdef _IRR_DEBUG_MS3D_LOADER_ #ifdef _IRR_DEBUG_MS3D_LOADER_
...@@ -730,7 +737,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -730,7 +737,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
{ {
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx; 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; w->vertex_id = index;
} }
boneid = vertexWeights[vertidx].boneIds[0]; boneid = vertexWeights[vertidx].boneIds[0];
...@@ -738,7 +745,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -738,7 +745,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
{ {
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx; 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; w->vertex_id = index;
} }
boneid = vertexWeights[vertidx].boneIds[1]; boneid = vertexWeights[vertidx].boneIds[1];
...@@ -746,7 +753,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file) ...@@ -746,7 +753,7 @@ bool CMS3DMeshFileLoader::load(io::IReadFile* file)
{ {
ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]); ISkinnedMesh::SWeight *w=AnimatedMesh->addWeight(AnimatedMesh->getAllJoints()[boneid]);
w->buffer_id = matidx; 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; w->vertex_id = index;
} }
boneid = vertexWeights[vertidx].boneIds[2]; boneid = vertexWeights[vertidx].boneIds[2];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment