Extracting orientation:Quaternion and translation:Vector3D from SkeletonJoint’s inverseBindPose

Software: Away3D 4.x

mataps, Newbie
Posted: 20 April 2013 07:33 AM   Total Posts: 9

Hello away3d team,

Im trying to animate my md5 mesh manually, as my starting point I want to copy the SkeletonJoint’s orientation and translation to JointPose, but I came accross the issue where I could’nt find anything useful from SkeletonJoints properties. So my initial thought is that SkeletonJoints stored the orientation and translation in the inverseBindPose property, but when I tried to decompose it my model got screwed. Im not very good in Math and English so I think it’s better if i show my code smile.

private function onAssetComplete(event:AssetEvent):void
{
 
if (event.asset.assetType == AssetType.ANIMATION_SET)
 
{
  animationSet 
event.asset as SkeletonAnimationSet;
  
  
//build the animator
  
animator = new SkeletonAnimator(animationSetskeleton);
  
  
//build the skeletonPose for custom animation
  
skeletonPose = new SkeletonPose();
  
  
//create a jointPose for each joint ( clone :D );
  
for(var i:int 0skeleton.joints.lengthi++)
  
{
   
var jointPose:JointPose = new JointPose();
   
jointPose.name skeleton.joints[i].name;

   var 
matrix3D:Matrix3D = new Matrix3D();
   
matrix3D.copyRawDataFrom(skeleton.joints[i].inverseBindPose);
   
matrix3D.invert();
   var 
decomposedMatrix:Vector.<Vector3D> = matrix3D.decompose(Orientation3D.QUATERNION);
   
   
jointPose.translation.copyFrom(decomposedMatrix[0]);
   
jointPose.orientation.fromMatrix(matrix3D);
   
   
skeletonPose.jointPoses.push(jointPose);
  
}
  
  
//create a new clip and add it to animationSet
  
var skeletonClip:SkeletonClipNode = new SkeletonClipNode();
  
skeletonClip.stitchFinalFrame true;
  
//add 2 frames since it will throw an error only 1 frame is added
  
skeletonClip.addFrame(skeletonPose1000);
  
skeletonClip.addFrame(skeletonPose1000);
  
skeletonClip.name "myAnim";
  
//finally add the clip to the animationSet :)
  
animationSet.addAnimation(skeletonClip);
  
  
mesh.animator animator;
  
animator.play("myAnim");
  
 
}
  

I’ve searched google and other posts and I always find people struggling on this king of issue but nothing works for them. Hope that you will kindly answer my question. Thanks smile

   

CbbK, Newbie
Posted: 22 April 2013 05:30 PM   Total Posts: 13   [ # 1 ]

Hi mataps, I’m working on the exact same topic and I also have problems with it, did you find a way to control the Skeleton programaticaly?

 

   

mataps, Newbie
Posted: 26 April 2013 08:15 AM   Total Posts: 9   [ # 2 ]

Hello CbbK, I still struggling with this problem. From reading the md5 specs, I found out that md5 stores skeleton coordinates in global position so I’m thinking of finding a way to convert global coordinates to Mesh’s local and I think in that way I can obtain the correct orientation and translation. But, for now the only workaround that i’m using is, making an animation of the skin’s default Pose (ie. steady Pose) and importing it to away3d, and by loading the steady animation I’m able to get the skeleton’s correct Pose. I hope that helps :D, if you find the way around this. Please do share it with this forum so that it would be easy for other newbies to find the solution :D. Thanks!

 

   

CbbK, Newbie
Posted: 26 April 2013 09:05 AM   Total Posts: 13   [ # 3 ]

Hey mataps, check my thread about it, it may help you : http://away3d.com/forum/viewthread/4395/

 

   

mataps, Newbie
Posted: 26 April 2013 09:21 AM   Total Posts: 9   [ # 4 ]

Ok, we’re on the same track as of now :D ...but i’m looking forward in converting skeleton/joint’s orientation and translation manually (ie. without having to load an existing animation to get the Skeleton’s pose). I hope that make sense smile.

 

   

CbbK, Newbie
Posted: 26 April 2013 09:47 AM   Total Posts: 13   [ # 5 ]

That’s great then, I hope you can help each other smile
Just to know, what’s the final goal you’re trying to achieve? For me, I’m trying to do make the skeleton’s arms point at a dynamic position, like Tomb Raider first of it’s name, you have Lara’s animation holding her guns and her arms moving with her target.
I saw the SkeletonDifferenceNode, i don’t realy understand how it works and didn’t have much time to try, but I’ll try to combine 2 animations : first would be “holding the gun”, the other “pointAt”. What I don’t know is how I must fill the SkeletonPose in the “pointAt” Node, I’ll try to fill it with null JointPose, or JointPose with 0 translation 0 rotation for all Joint that should not be animated, and hope that Away3D will do skeletonPose = skeletonPose(“holding the gun”) + skeletonPose(“pointAt”).

 

   

CbbK, Newbie
Posted: 26 April 2013 11:23 AM   Total Posts: 13   [ # 6 ]

And it worked like a charm! :D
The solution to my problem was exactly skeletonPose = skeletonPose(“holding the gun”) + skeletonPose(“pointAt”). I didn’t use the SkeletonDifferenceNode as it may have a different purpose (interpolate between 2 states).
Instead I wrote 2 classes : SkeletonAdditiveNode and SkeletonAdditiveState (attached)
Used like that :

_skeletonAimAtNode = new AimAtSkeletonClipNode();
_skeletonAdditiveNode = new SkeletonAdditiveNode();
_skeletonAdditiveNode.leftOperand _animationSet.getAnimation(WALK_ANIM);
_skeletonAdditiveNode.rightOperand _skeletonAimAtNode;
_skeletonAdditiveNode.name AIM_ANIM;
_animationSet.addAnimation(_skeletonAdditiveNode);
_animator.play(AIM_ANIM_stateTransition); 

It does the addition of my AimAtSkeletonClipNode (which creates a Pose with the required translation and orientation changes) and the WALK_ANIM.

 

File Attachments
graphicobjects.zip  (File Size: 2KB - Downloads: 170)
   

SuperSam, Sr. Member
Posted: 26 April 2013 09:04 PM   Total Posts: 102   [ # 7 ]

That’s pretty interesting ! And it’s very nice to post what you’ve done so far, thanks, that helps to get a better grab on the framework.

Unfortunately your attachments won’t download, they’re a blank page. :/

 

   

CbbK, Newbie
Posted: 26 April 2013 10:14 PM   Total Posts: 13   [ # 8 ]

I updated the attachment. I hope it’ll help you.

 

   

mataps, Newbie
Posted: 27 April 2013 03:31 PM   Total Posts: 9   [ # 9 ]

Thank you so much for your help. What I want to achieve is something like skeleton debugger UI, that will display all the bones and will try to control it with click and drag(ie. something like 3d software does) and add some frames, I noticed also SkeletonDifference class and I think it is used by Away3d bone animation interpolation thing smile. Anyway I hope I can do an experiment with your code. I will try this out as soon as I finish doing my current project. I will post some updates here on what I’ve figured out so far. And hopefully i’ll be able to share my code with you guys :D. Cheers!

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X