Skeletal Animation Help

Started by
3 comments, last by GamerSg 20 years, 3 months ago
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.
Advertisement
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.
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 darwin3d.com 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.
Math3d is pretty good. I''ve been using it for a while now and had no major problems. It''s not actively updated anymore though, as far as I can tell.
[size="1"]
I could perhaps scream D3DX utility library at you, but you dont want to hear that, do you?
die or be died...i think

This topic is closed to new replies.

Advertisement