Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Skeletal Animations Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
mallouk

March 17, 2005, 05:05 PM

Hello there!

I'm having a little problem creating a skeletal animation system and I wondered if any of you guys could help me.

Let me try to explain what's going on:

I am exporting the data from max with a maxscript. For each bone, I export the absolute transform with one quaternion and two vectors which respectively carry the absolute scale, and absolute translation.

To compute the absolute matrix for each bone on the engine side, I just transform everything into matrices and compute:

  1.  
  2. absoluteMatrix = rotationMatrix * scaleMatrix * translationMatrix
  3.  


and this seems to work fine.

At first, I chose to calculate the relative matrices on the engine side, just after the animations are loaded. So here is what I am doing:

(1) Compute the length of the bones with:

  1.  
  2.   // Any child will do
  3.   Matrix4x3 child = children[0]->absoluteInitialTranslation;
  4.   Matrix4x3 relative = inverse(absoluteInitialTranslation) * child;
  5.   length = Vector3(relative.m41, relative.m42, relative.m43).magnitude();
  6.  


(2) Recursively compute the relative matrices with something like this:

  1.  
  2.   relPos = inverse(parent->absoluteTranslation) * absoluteTranslation;
  3.   relScale = inverse(parent->absoluteScale) * absoluteScale;
  4.   relRot = inverse(parent->AbsoluteRotation) * absoluteOrientation;
  5.  


I do that for every keyframe, there are more details that I can post if necessary.

(3) This is what I think I am getting wrong. After the interpolation (slerp for the rotations), I recursively reconnect the bones with the following:

  1.  
  2.   absoluteRotation = parent->absoluteRotation * relativeRotation;
  3.   absoluteScale = parent->absoluteScale * relativeScale;
  4.   absoluteTranslation.identity();
  5.   Matrix4x3 m;
  6.   m.setupRotation(parent->absoluteRotation);
  7.   // X is the max direction for the up vector
  8.   absoluteTranslation.setupTranslation(Vector3(parent->length, 0, 0) * m);
  9.   // Concatenate with the translation of the parent
  10.   absoluteTranslation = parent->absoluteTranslation * absoluteTranslation;
  11.  


This is a good summary of what I am doing. The visual problem Is is that some bones seem to be slightly in the wrong place. The animations play well, but there's a little distortion in the mesh particularly next to some joints.

I have compared the computed absolute matrices against the ones that come from max in the rest pose. There is a difference in the translation parts (the rotations seem to be fine so far). This difference is very small in the first two bones of the hierarchy, but as the recursion goes down the tree the difference gets bigger and bigger.

I would really appreciate any ideas. Thanks in advance.

-William

 
juhnu

March 17, 2005, 10:52 PM

do you get the correct results without interpolation?

juhani

 
Rui Martins

March 18, 2005, 04:10 AM

I would suggest you calculate the relative matrices in relative form !

What you currently do is calculate the child relative matrix, by using it's absolute matrix.

Your problem is due to floating point error accumulation !

You should use the previous matrix in the hierarchy and not the absolute matrix. i.e. you need to use the abslute matrix, because that is where the info is, but you should multiply it by the inverse of the recursively found current node Matrix, not use the absolute again.

Doing it this way, you ensure that every child node keeps the same errors as it's father, and so the skeleton doesn't break apart.

 
mallouk

March 19, 2005, 06:58 PM

Hello Rui,

I finally got that issue solved. The problem was that I was not computing the translation part of the absolute matrices correctly. I actually multiplied the initial translation vector by the transition matrix of the parent bone to solve the problem.

I came across two good links on skeletal animations for anybody who reads this message as reference to solve a similar problem:

http://www.robthebloke.org/models/html/Anim_cycles.html (indicated by blue_knight)

http://www.morrowland.com/apron/article/general/character%20animation/index.php

Salve!
William

 
This thread contains 4 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.