Ogre_glTF icon indicating copy to clipboard operation
Ogre_glTF copied to clipboard

Failing to load skeleton

Open crjc opened this issue 4 years ago • 3 comments

Hello, lovely plugin here. I'm just struggling to load a particular mesh:

Walking2.glb.zip (However, CesiumMan works fine)

Basically, I am receiving the following assertion from Ogre: (!pos.isNaN() && "Invalid vector supplied as parameter"), function setPosition, file .../OgreMain/src/OgreOldNode.cpp, line 391. https://github.com/Ybalrid/Ogre_glTF/blob/6a59adf2f04253a3afb9459549803ab297932e8d/src/Ogre_glTF_skeletonImporter.cpp#L40

It looks like convertWorldToLocalPosition is returning NaN values because the scale of the parent bone is +inf.

If I comment out the following line, the mesh loads fine - however, playing an animation makes everything look awful. I may be mistaken but I believe the scale becomes so small until it reaches a point where _getDerivedScale starts returning +inf. https://github.com/Ybalrid/Ogre_glTF/blob/6a59adf2f04253a3afb9459549803ab297932e8d/src/Ogre_glTF_skeletonImporter.cpp#L42

I'm kinda running out of ideas and would appreciate it if I could be pointed in the right direction

Thanks!

crjc avatar Nov 12 '20 00:11 crjc

I actually stopped that assertion by flipping the division, although the mesh breaks as soon as you begin an animation.

bone->setScale(scale / parent->_getDerivedScale()); 

crjc avatar Nov 27 '20 15:11 crjc

Try removing the scale. As you see in line 38 it is doing a decomposition of the bind matrix into rotation, translation and scale. What are the contents of that matrix.?

xissburg avatar Nov 30 '20 04:11 xissburg

I believe the matrix is the global transform of the bone, and Ogre expects the position, rotation and scale of a bone to be local.

I have tried to simply not apply the scale to a bone, and this loads the mesh fine, however animations turn the mesh into spaghetti.

crjc avatar Nov 30 '20 10:11 crjc