Jump to content

  • Log In with Google      Sign In   
  • Create Account

Bone based animation confusion


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.

  • You cannot reply to this topic
1 reply to this topic

#1 gnomgrol   Members   -  Reputation: 627

Like
0Likes
Like

Posted 21 August 2014 - 05:03 AM

Well met!

 

I have some questions on bone-based animating.

 

The process I got (in short):

 

- Export the vertices with boneweights and also the skeleton, with the bones as worldmatrices (position, rotation, scale),  as a "basemesh" (from the modeling program)

- Export an animation as the bone-worldmatrices for each frame

- For playing an animation, transform every vertex by ((bonematrices of the current frame) - (bonematrices of the baesmesh)) for each bone assigned to it, using the weights

 

The reason that this isn't working is that, when transforming one vertex of a mesh with a matrix, the rotation and scaling will be applied from the origin of the mesh as the origin, not the position of the bone.

 

I thought that could be fixed with relative ease, by constructing the worldmatrix for each bone like this:

// Answer from a question on stackoverflow
mat4 result = glm::translate(-pivot) *
glm::scale(..) *
glm::rotate(..) *
glm::translate(pivot) *
glm::translate(..);

 

Where pivot would just be the position of the bone. But when applying this, there is no change to the final result. Stuff still uses the center of the model as pivot-point for scaling/rotating.

 

Also, this method of animating completly ignores the parent-child-relations that bones hold to each other. Is there something gained from using those relations when computing the rendering?

I understand why they are extremly helpful when modeling in the modelingprogram, but is there a reason to also use them when rendering?

 

 

Your help is, as always, greatly appreciated!

Have a nice day!

 



Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 6407

Like
0Likes
Like

Posted 21 August 2014 - 06:06 AM

You may want to take a look at this article on matrix-based skinned animation, particularly the section "A Slight Diversion From The Initialization Process." As you suspect, bone animation must take place in bone space ("local," not world matrix). It appears you're using "world" (rather than local) matrices. After the local animation takes place, each bone's world animation matrix is formed by combining that local animation matrix with it's parent's world animation matrix, commonly done with a recursive function.

 

For that process, you'll need the local animation matrices for each bone.

 

For rendering, you'll also need the bone's offset matrix (inverse-bind-pose) to transform each weighted vertex from world space to local space before the animation matrix is applied.

 

Where pivot would just be the position of the bone.

 

That's more than just a translation, as it includes the local transforms (scale and rotate, as well as translate) for a bone in relation to it's parent. You've got the right idea, but use the inverse of the bone's bind-pose world matrix (it's also called the "offset" matrix,) calculated once and reused, rather than recalculating it each frame.

 

Following a vertex multiplication by the offset matrix, apply the bone's animation matrix, combine the weighted vertex positions (from each influence bone), and transform to screen space.

 

EDIT: It's been a while since I've used OGL, but, as I recall, you must be mindful of matrix multiplication order. I.e., by default, scale-rotate-translate would be Trans * Rot * Scale.


Edited by Buckeye, 21 August 2014 - 07:51 AM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.





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