Advertisement Jump to content
SBSFAM

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 this post


Link to post
Share on other sites
Advertisement

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;
		 COLOR_PICK_SHADER->SendMVPtoShader(MVP);

box_model->DrawSimpleModel(COLOR_PICK_SHADER);
}}

I could twist something

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!