Game Development Community

Rigged mesh goes head over heels when MaskNodesHandsOff is used.

by Sorin Daraban · in Artist Corner · 11/30/2012 (11:57 am) · 4 replies

As the title says, I have a rigged mesh that I downloaded off the Internet.
When I try to manually control the Spine or the Pelvis bone by code, the shape goes head over heels in T3D.
I use MaskNodesHandsOff, in code, to turn off animation on any of the above mentioned bones.

Any idea why this happens and how to fix this problem?

I searched all over the net, and I found out about 'Zeroing Out' bones in Milkshape. Not a good option, as I have to re-animate all the bones, and I'm not an artist.
I also know about how the turretShape (kind of) works, as well as all the resources and discussions available here on the resource and forum pages.

Thx.



#1
11/30/2012 (10:23 pm)
As a shot in the dark, can you get the model into your animation software and see where the bones are, at frame zero?

I'm not sure what you mean by "manually control the Spine or the Pelvis bone by code" I didn't know that was an option for animation.
You mention that making your animations over again isn't an option because your not an artist... but at the same time your trying to animate the bones with code, if I read your post correctly.

So I thought i'd give a little help with some info in-case your correct and that animation can be done with code. The pictures below are for the gimbal illustration, disregard the yellow lines... that's not a bone.

media.use.com/images/s_1/1847a11c603c11816990.jpg
Red equals X or Heading.
Green equals Y or Pitch.
Blue equals Z or Bank.

Each bone in a set has a start and end, both ends receive their alignment from the parent bone and they can be rotated to avoid "gimbal lock". Gimbal lock is when any of the axis is parallel to another.
Example of Gimbal lock:
media.use.com/images/s_1/fdc19c7f049ca7fc3a57.jpg
In the picture above the Bank is gimbal locked with the heading ( z,x ) which means you only have Green Y(Pitch) and Red X(Heading) but not Blue Z(Banking) until the Pitch is moved to allow Z the freedom to move.
And all 3 of the Axis have a +360 from zero or a -360 from zero in which they can be rotated from the "rest" position (clockwise or counter-clock wise rotation ).

My theory is that when you move the spine with code, your actually moving the Green Y(Pitch) to -180 degrees and making the character look like it's eating feet, or your moving the Blue Z(Bank) to 180 degrees in either direction and getting the same effect.

If this is not the case, then my only other thought is that the bones are at "rest" when you stop all animation. The bones would be effectively at frame zero.. their start position before any animation begins. If this is what is happening then you'll need to load the model into your animation software and reset the bones to a proper postion, then begin your animations from frame one.. leaving frame zero alone for each animation you make, you'll need to start with frame zero ( the rest position then begin on frame 1 again ).
That is to say, you want to preserve frame zero as the bones will be in the correct "rest" position.








#2
12/01/2012 (1:33 am)
Thanks Scott.

I quickly read through what you said, and I'll go over it in more detail a little bit later; but now, I just wanted to quicly show you what I meant by controlling bone animation by code.

There's an option in T3D to turn off animation on any given bone on a rigged character. Here's an example of that:

if(mDataBlock->yawNode != -1)
   mShapeInstance->setNodeAnimationState(mDataBlock->yawNode, TSShapeInstance::MaskNodeHandsOff); //Yaw node is now  available to be controlled/animated manually. I placed it in onNewDataBlock.

MatrixF *_yawNodeMat = &mShapeInstance->mNodeTransforms[mDataBlock->yawNode]; //Get the yawNode's matrix.
Point3F _yawNodePos = mShapeInstance->getShape()->defaultTranslations[mDataBlock->yawNode]; //extract the position

EulerF zRot(0,0, mHeadRot.z);
_yawNodeMat->set(zRot); //Rotate the yawNode along the Z axis (yaw.)
_yawNodeMat->seColumn(3, _yawNodePos); 
mShapeInstance->mNodeTransforms[mDataBlock->yawNode] = _yawNodeMat; //store the new rotation in the node.
#3
12/01/2012 (11:04 am)
For all readers of the thread, I provide a link to demonstrate Yaw and Pitch so that reading the code will be more logical to follow:
http://www.grc.nasa.gov/WWW/k-12/airplane/rotations.html

Perhaps a visual screen grab of the model in the folded position you speak of would help too.
The way I picture it in my mind is the object is bent over with face to the ground.
If I was animating that, I'd move the Green Y(Pitch) which is perpendicular to Red X(Heading), but centered on the Z Axis. This makes the character bend at the waist.
The small bit of code sample shows me the Z(Center of Gravity) and X(Heading)starts at zero or is initialized there.
I could assume that "zero" is the ground, or the feet of the object, from which it will pivot.

#4
12/02/2012 (5:51 am)
"The way I picture it in my mind is the object is bent over with face to the ground." - Yes, that is how the model is.
If you still need a picture to demonstrate the problem, I will post one when I get arround it. Just let me know.

Thanks for taking all this time to find an explanation for my problem.