This topic is now archived and is closed to further replies.

Skeletal Animation Help

This topic is 5093 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to do some skeletal animation and this is what i am currently doing. (If has a parent, apply parents matrix first) 1) Translate to origin 2) rotate bone 3) translate back Is that right? So i am basically constructing 3 matrices and multiplying them to get 1 matrix for the bone. Sounds kind of inefficient to me. Also, it doesnt seem to be working right. The bone doesnt seem to be rotating about it''s own axis, but instead appears to be rotating around the origin. I don''t know what is the problem. Maybe my matrix multiplication code is wrong, since i copied it. Or maybe my Quaternion to matrix code. I was also wondering if it would be faster if i just let the hardware to do my calculations, something like this: glPushMatrix(); glLoadIdentity(); glTranslatef(-bone.x,-bone.y,-bone.z); glRotatef(bone.a,bone.x,bone.y,bone.z); glTranslatef(bone.x,bone.y,bone.z); glGetFloat();//Whatever the command is, i cant remember glPopMatrix(); I know it will be much faster this way and i also wont have to worry about my matrix code. The only thing is, reading from the gfx card is slow, but for 16 floats how much could it possibly slow down? Or should i just stick to doing it on the CPU. PS Currently, im not in Vertex Shaders and even if i was, i want to have a software fallback. I know vertex Shaders would be fastest since i wont have to read back the data at all.

Share this post

Link to post
Share on other sites
I dont think you want to use the opengl matrix stack for animating the bones...

I''ve recently tried to do matrix palette skinning with mixed results, but this is what I''ve learned. Sorry if it''s not 100% correct, I''ve still got a bug with something.

For each bone, keep a static matrix, an inverse static matrix, and a dynamic matrix. The static matrix is calculated/loaded once, and is the transformation from the parent''s origin to this joint. The inverse static is obviously the inverse matrix of the static matrix. and the dynamic matrix is the matrix that you actually change to animate the bone.

then each frame you calculate your matrix palette by doing this:
palette[boneid] = static*dynamic*invstatic*palette[parentid];

you obviously need to do this starting at the root bone and working down otherwise you''d be using and old palette entry for the parent.

then you skin your vertices by multiplying them by the palette entry(s) for the corresponding boneid. (if you want multiple bones, you just weight them)

hope that helps!

anyone see any problems? please correct me.

Share this post

Link to post
Share on other sites
Hmm, the way i store my data is not by vertex but by bone.

Meaning, each bone has a list of IDs it affects and their corresponding weights. I just felt more comfortable with this way.

Anyway i think my problem lies in the matrix code.
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Anyone has a website with matrix code/QuaterniontoMatrix and all the other ops required for skeletal animation. I found one a but it used the OpenGL matrix stack to do it''s calculations. I represent my matrices as float[16] and would like to keep it this way.

Most websites use a 2D array. Also my matrix code might have been mixed with row/column major formats since i got the code from multiple sources.

Share this post

Link to post
Share on other sites