Help understanding GlobalInversedMatrix and animation

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
deleted22
Posts: 1
Joined: Tue Oct 17, 2023 4:59 am

Help understanding GlobalInversedMatrix and animation

Post by deleted22 »

I'm trying to implement my own render/animation code and porting my existing logic which uses the irrlicht api. Currently my animation code produces gibberish and I'm trying to get better understanding of animation math and how to use the B3D keyframe data I have

I'm confused about how irrlicht animates. In the CSkinnedMesh::skinJoint function, it has this code

Code: Select all

	core::matrix4 jointVertexPull(core::matrix4::EM4CONST_NOTHING);
	jointVertexPull.setbyproduct(joint->GlobalAnimatedMatrix, joint->GlobalInversedMatrix);
	jointVertexPull.transformVect(thisVertexMove, weight.StaticPos);
I don't understand the role of GlobalInversedMatrix. When mesh is loaded, CSkinnedMesh::finalize is called. And it calls CSkinnedMesh::calculateGlobalMatrices, which has this code

Code: Select all

	joint->GlobalMatrix = parentJoint->GlobalMatrix * joint->LocalMatrix;
	joint->GlobalInversedMatrix = joint->GlobalMatrix;
	joint->GlobalInversedMatrix.makeInverse();
so it looks like GlobalInversedMatrix is the inverse of the joint's initial pose matrix? when this is multiplied with the animated pose matrix, what effect does that have? what does the inverse matrix represent in this context? insights about this would help me.
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Help understanding GlobalInversedMatrix and animation

Post by CuteAlien »

There is another comment in the CXMeshFileLoader:

Code: Select all

	// transforms the mesh vertices to the space of the bone
	// When concatenated to the bone's transform, this provides the
	// world space coordinates of the mesh as affected by the bone
	core::matrix4& MatrixOffset = joint->GlobalInversedMatrix;
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
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Help understanding GlobalInversedMatrix and animation

Post by CuteAlien »

Funny coincidence - I was hunting an old bug last 2 days in an .X files. And it seems to be related to the line I just posted above. The broken file starts working when I set that MatrixOffset (aka the GlobalInversedMatrix) to the identity matrix instead. Not sure yet if it will break other stuff (so nothing changed yet - also have to understand this first and it's not code I've worked with much yet).

edit: That turned out to be a false alarm. The .X file I was investigating seems to be broken.

I suspect the animation system might have been strongly influenced by the design of .X, so maybe reading a description how that works can help? https://www.gamedev.net/tutorials/_/tec ... ectx-r2221
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
Post Reply