• Create Account

# Multiple Mesh World Transformation help

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1nbviper  Members   -  Reputation: 100

Like
0Likes
Like

Posted 08 May 2011 - 09:11 PM

Hello,

I hope you can help me out with this. I'm attempting to manipulate the position and orientation of a human skeleton in a 3D environment. The skeleton is made up of multiple meshes (skull, body core, left arm, right arm).

The skull and body have the same center of rotation, but the arms have a center of rotation located at the top of each arm. (This is because I need to manipulate the arms separately from the body, later on).

My problem is, I can't seem to figure out the correct transformation to keep the arms with the body. My current code looks as follows (using SlimDX):

//Body
_device.SetTransform(TransformState.World, Matrix.Scaling(_scale, _scale, _scale)
* Matrix.RotationY(_skullYPR.Y) //Rotation about the Y axis
* Matrix.Translation(_position)); //Location in 3D space
...
...

//Right Upper Arm
_device.SetTransform(TransformState.World, Matrix.Scaling(_scale, _scale, _scale)
* Matrix.RotationY(_skullYPR.Y)
* Matrix.Translation(_position.X - 5.0f, _position.Y - 5.5f, _position.Z)); //Offset of arm position


This results in the arm remaining in the same position (with a proper rotation around it's own center of rotation) I've attach a couple images for you to reference.

I've tried adding additional rotation matrices, but I'm just having a brain fart right now and can't think it through properly.

The question is how do I properly apply a rotation that takes into account the translation from the center of the body?

Facing Forward, everything is ok. (I know a collar bone is missing )

Rotated, rotates in position, doesn't move with body

Any help or direction would be greatly appreciated!!!

### #2karwosts  Members   -  Reputation: 840

Like
2Likes
Like

Posted 09 May 2011 - 12:08 AM

You want to build the transform of the child bones by appending them to the transforms of the parent bones.

First, some abbrebiations to make things simpler:

Mb: body matrix
Ma: arm matrix

Sb: body scale
Rb: body rotation
Tb: body translation
Sa: arm scale
Ra: arm rotation
Ta: arm translation

If your body matrix is defined like this:

Mb = Sb * Rb * Tb,

then your arm matrix would be defined like this:

Ma = Sa * Ra * Ta * Mb
or
Ma = Sa * Ra * Ta * Sb * Rb * Tb

Basically everything that you put on the left hand side adds to the chain of transforms. In this case the arm translation is only the offset from the center of the body to the arm position, it has nothing to do with the arm's global position. Because you're chaining it together with the body translation, you can say that the arm translation is defined in "body space", instead of "world space", where you would supply the actual coordinate of it. Again the arm rotation is only the rotation of the arm in its own local space, it doesn't have anything to do with the rotation of the body.

You could do a similar thing with a hand mesh, by defining its rotation and translation relative to the position of the arm.

Mh = Sh * Rh * Th * Sa * Ra * Ta * Sb * Rb * Tb.

This concept comes up a lot when doing animation, basically in the simplest explanation is that when you have an object whose transform is a derivative of some parent, then you want to define the position of the sub object relative to the coordinate space of the parent, don't try to compute it directly in the world space. Its the same concept whether you're dealing with hands on arms on torsos or moons orbiting planets orbiting stars.
My Projects:
Portfolio Map for Android - Free Visual Portfolio Tracker
Electron Flux for Android - Free Puzzle/Logic Game

### #3haegarr  Crossbones+   -  Reputation: 6999

Like
1Likes
Like

Posted 09 May 2011 - 01:51 AM

The keyword to look for is "forward kinematics", often simply called "parenting"; karwosts has described its math for row vectors and the usual transformation chain scale -> rotation -> translation.

However, the things may be more complicated dependent on how the various co-ordinate spaces in use are placed and related. Each mesh, when imported for its own, has its local co-ordinate space. The 1st transformation applied uses it as its reference. The 2nd transformation then is applied w.r.t. the so transformed space. The 3rd transformation ... and so on. Hence, you may need to adapt the space in order to apply a transformation in the desired space if that space isn't accidentally coincident with the current one. That means extra steps to take if e.g. the center of scaling and the center of rotation isn't the same point, or e.g. (using karwosts' solution) the co-ordinate frame of the arm isn't directly given w.r.t. the frame of the body.

### #4nbviper  Members   -  Reputation: 100

Like
0Likes
Like

Posted 09 May 2011 - 07:21 AM

Perfect, thank you both! This makes complete sense.

My skeleton is now whole.

Thank you again for the clear explanation!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS