Do I need to do anything with the GlobalMatrix on SJoint?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
n00bc0de
Posts: 38
Joined: Tue Oct 04, 2022 1:21 am

Do I need to do anything with the GlobalMatrix on SJoint?

Post by n00bc0de »

I have read somewhere in the documentation that GlobalMatrix on a joint does not need to be set by a loader but when I looked through the B3D loader it does set it. I just want to clarify if I actually need to do anything with it.
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Do I need to do anything with the GlobalMatrix on SJoint?

Post by CuteAlien »

Not 100% sure, but I have the feeling the B3D loader uses it for something internal while loading. The part with the "// Transform the Vertex position by nested node..." comment. I don't know enough about B3D, so not sure why it transforms vertices to global space already on loading (and also slightly suspect it transforms the normals by the same matrix without checking if it has scale, but maybe animation never has scale).

On first view strange, but probably has some reason. Like maybe vertex groups are hierarchical absolute for base-mesh and relative to that for animation (makes not much sense... probably something else). Sorry, hard to tell without digging deeper in the B3D format. But it does overwrite GlobalMatrix in finalize(). So whatever it does while loading - it is ignored in the end.

So think of GlobalMatrix maybe as something you won't need, but in case you need a helper matrix within the loader it might be useful as it's not doing anything otherwisey yet at that point.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
n00bc0de
Posts: 38
Joined: Tue Oct 04, 2022 1:21 am

Re: Do I need to do anything with the GlobalMatrix on SJoint?

Post by n00bc0de »

Thanks for the quick answer. If finalize() does overwrite it then I will just ignore it. Also, am I correct in assuming that irrlicht will apply local matrices for parents to child joints internally or should I apply those when loading my skinned mesh?

For example, if I have bone1 rotated at 30 degrees and it has a child bone2 rotated at 30 degrees, do I set the rotation of the local matrix on bone2 to 60 degrees or is that done by irrlicht?
n00bc0de
Posts: 38
Joined: Tue Oct 04, 2022 1:21 am

Re: Do I need to do anything with the GlobalMatrix on SJoint?

Post by n00bc0de »

Disregard my question. I found the answer in the B3D loader. That file is practically mandatory documentation on how to load a skinned mesh.

The B3D loader uses the GlobalMatrix to transform the vertices for the joints they are attached to. Thankfully all of the irrlicht source code is written to be readable by people who aren't computer science geniuses.
Post Reply