Displaying Ogre3D mesh and skeleton outside Ogre3D framework

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Bthouverez
Gnoblar
Posts: 2
Joined: Fri Jun 16, 2017 10:31 am

Displaying Ogre3D mesh and skeleton outside Ogre3D framework

Post by Bthouverez »

Hello everyone.

I'm currently working on a project where I am trying to display an Ogre 3D human model and its skeleton in my personal application. My model comes from MakeHuman (http://www.makehuman.org/) which gives me .mesh.xml and .skeleton.xml files.
I can draw the mesh but I got troubles displaying the skeleton since I did not find any specification for .skeleton.xml file format.

First three bones of my model look like this:

Code: Select all

        <bone id="0" name="root">
            <position x="0.0" y="8.70061683655" z="-0.647733330727" />
            <rotation angle="-1.51673085594">
                <axis x="-1.0" y="1.34804047087e-10" z="7.24879839663e-10" />
            </rotation>
        </bone>
        <bone id="1" name="spine05">
            <position x="-2.48034689255e-17" y="0.780916077708" z="-6.17040605277e-08" />
            <rotation angle="-1.96875790305">
                <axis x="1.0" y="0.0" z="0.0" />
            </rotation>
        </bone>
        <bone id="2" name="pelvis.L">
            <position x="-2.48034689255e-17" y="0.780916077708" z="-6.17040605277e-08" />
            <rotation angle="-1.68171712564">
                <axis x="0.0912755176101" y="0.151359656585" z="0.984255573641" />
            </rotation>
        </bone>
I tried to create a 4x4 matrix for each bone defining the transformation (translation and the rotation ) from previous bone, then I simply tried to display it with some glRotate and glTranslate functions but my results are bad.

I think I miss something with this skeleton format and I wonder if someone could explain me in what order do I need to do my transformations to display these first three bones correctly.

Thank you.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Displaying Ogre3D mesh and skeleton outside Ogre3D frame

Post by dark_sylinc »

Skeletal animations are tricky.

Assuming your routine to convert translation, quaternion & scale into a 4x4 matrix is correct (see our XML serializer for reference); the 4x4 will be in "local space", but to display them properly, these matrices need to be sent to the GPU in "bone-local" space; for which you need to do some math for that.

IIRC mBindDerivedInverse* variables were used for that (see also Bone::_getOffsetTransform). I can't recall more specifics because Skeletal animations, although simple in concept, can get quite complex on the implementation details; but the information I gave you should be enough to get you on the right track.

Cheers and good luck!
Matias
Bthouverez
Gnoblar
Posts: 2
Joined: Fri Jun 16, 2017 10:31 am

Re: Displaying Ogre3D mesh and skeleton outside Ogre3D frame

Post by Bthouverez »

Hello Matias,

Thank you for your response.
I did not think I would need some quaternions to do that. Following your advices, I checked my routine and updated it to use quaternions, my personal XML serializer looks very similar to Ogre's one and I am now really close to the result I want:

Image

This image presents my results: the mesh looks good and most of my bones seem to be correctly set at their position.
A remaining problem appears at the level of the elbows where a rotation seems to be broken. I can manually process a rotation around X axis of the elbows to move lower arms at their correct position in the mesh but I would like it be fixed when loading.

Do you know where it can come from?

Once again thank you for your help.
Post Reply