# Bone animation: calculate matrix of a child.

## Recommended Posts

Hi, I'm new to bone animation and I'm confused about calculating a matrix of a child(bone).

Let's say, I have a pelvis bone(root) and a spine bone(child to root).

I have a rotation for each(pelvis and spine) in Quaternion.

for pelvis(root), what I did is multiplying 4x4 matrix of quaternion with its' coordinate to calculate a local transform.

and for spine, I did the same.

So in order to find the world matrix of the spine(child), should I do local transform matrix of pelvis * local transform matrix of spine?

##### Share on other sites

I dont quite get you, but i think you want to rotate spine by its own local axis.

So first thing to do is that you place not rotated pelvis and not rotated spine in proper positions, then you get the vector from pelvis rotation pivot point to spine rotation pivot point.

Then to actually rotate the spine along with pelvis rotation.

You have rotation matrix of pelvis, and local rotation mattix of spine, now you translate spine so the rot pivot point of spine is at 0,0,0 then you apply spine rotmat then you translate back to original position then you should multiple vector computed earlier by pelvis rot mat then i think you combine those two matrices by multipkying them, its wuite harf to say cause it seems i deleted the code that actually did that and found something like this

Where ship would be your pelvis and right boardside is your spine and ship is centered at 0,0,0 point and right boardside resides where it should

for (int i=0; i < ship_count; i++)
for (int j=0; j < ship[i]->boardside_cannon_cnt; j++)
{

vec3 rotpos = ship[i]->ROTATION_MAT * ship[i]->right_boardside[j].pos;

Matrix44<float> wrld;
wrld.TranslateP(rotpos + ship[i]->pos);
MVP = (wrld * ACTUAL_VIEW) * ACTUAL_PROJECTION;

}}

I could twist something

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015750
×