Weird result using Skeleton (again)

Software: Away3D 4.x

CbbK, Newbie
Posted: 21 April 2013 05:15 PM   Total Posts: 13

Hey, it’s me again, strugling with the Skeleton, I must be doing something wrong because the results I have are completely messy.
I use Away3D 4.1 Alpha.

I have a Skeleton and 2 animations (IDLE and WALK) both are loaded, and working. Everything is fine until now, I try to control the Skeleton programaticaly.

So what I do is that I create a SkeletonClipNode, I add it to my SkeletonAnimationSet and create the SkeletonPose by duplicating the current pose :

_skeletonAimAtNode = new SkeletonClipNode();
_skeletonAimAtNode.name AIM_ANIM;
_animationSet.addAnimation(_skeletonAimAtNode);
    
var 
currentPose:SkeletonPose _animator.globalPose;
for(var 
i:uint=0i<_skeleton.joints.length; ++i{
 
var jointPose:JointPose = new JointPose();
 
jointPose.copyFrom(currentPose.jointPoses[i]);
 
pose.jointPoses.push(jointPose);
}
_skeletonAimAtNode
.addFrame(pose1);
_skeletonAimAtNode.addFrame(pose2);
_animator.play(AIM_ANIM_stateTransition); 

What I expect from this code is to have my Skeleton stop every movements (it is playing this new animation, that contains only 1 frame). Then I plan to position each Joint dynamicaly, according to some external factors.

A couple of problems here, the names in all the JointPose in currentPose are “null” :/
If I add only 1 frame to _skeletonAimAtNode I have a RangeError in SkeletonClipState/updatePositionDelta(), adding it twice solves this problem.
Finaly, once the animation is played all Joints are completely upside down, they all moved in a very chaotic direction and the mesh is completely f*cked up :/

   

SuperSam, Sr. Member
Posted: 22 April 2013 11:01 AM   Total Posts: 102   [ # 1 ]

Okay uh… You’re ahead of me in mastering Away3D so I probably won’t be able to help, but if no one ever replies for lack of sufficient knowledge, this forum will never take off.

You say all copied names are null. This could be one of the cause of the problems you’re seeing, maybe. Have you tried copying them manually right after calling jointPose.copyFrom in your for loop ?
Does it improve anything ?

We can talk back and forth if you want, it might help you figure out the real culprit by yourself if anything. Wording things out usually helps.

 

   

CbbK, Newbie
Posted: 22 April 2013 12:35 PM   Total Posts: 13   [ # 2 ]

Hi SuperSam, I hope together we can understand how the Skeleton works then!
Yes, i tried to retrieve the Joint names from the Skeleton and affect them to the JointPose, with no success.
When I trace the position of each JointPose before my animation they are all OK, if I try to move them to the same position :

var jointPose:JointPose = new JointPose();
 
jointPose.copyFrom(currentPose.jointPoses[i]);
 
jointPose.translation = new Vector3D(111);
 
pose.jointPoses.push(jointPose); 

And retrace their position they are all here and there, but not at (1, 1, 1). Perhaps the translation parameter is relative to the parent Joint position.  Anyway I’ll do more tests to understand it and post my results here.

 

   

SuperSam, Sr. Member
Posted: 22 April 2013 01:05 PM   Total Posts: 102   [ # 3 ]

Yeah it’s tough to say anything, testing is the best way to find out in our case. If you can post the whole source I can do tests as well to figure out what’s wrong, I guess 2 is better than 1 :p

Good luck either way. I can’t guess further than “Perhaps the translation parameter is relative to the parent Joint position” or “It could be a transformation order issue” without the source.

 

   

CbbK, Newbie
Posted: 22 April 2013 02:27 PM   Total Posts: 13   [ # 4 ]

Sure thank you, i attached my prototype (src.zip), it contains CharacterTest.fla, the Character class and the 3D data.
In the animation if you press any key the character will start to walk, if you press another key he’ll stop. Without touching anything it displays an “idle” animation. Both work great, but when you click on the ground you’ll notice the bug, the mesh goes crazy. Before each click the position of each Joint is traced.

 

File Attachments
src.zip  (File Size: 79KB - Downloads: 184)
   

SuperSam, Sr. Member
Posted: 22 April 2013 03:57 PM   Total Posts: 102   [ # 5 ]

Ok thanks. I’ll have some time to test this in a couple of hours if you don’t find the cause before then smile

OMG I’m reinstalling Flash Pro ! It’s been a long time :D

 

   

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

Ok, I found it!
I opened the idle.md5anim with a texteditor to understand how it works, as I thought the JointPose contains the translation of the Joint to it’s parent.
The problem is that I was using the SkeletonPose from the SkeletonAnimator globalePose property, which is wrong. I compared the positions to the positions writen in the md5anim file, they are not the same, I don’t know what they are, perhaps an offset with their baseframe.
To retrieve the current (real) SkeletonPose and duplicate it I use the following code :

var currentPose:SkeletonPose = (_animator.activeState as SkeletonClipState).currentPose;
var 
pose:SkeletonPose = new SkeletonPose();
for(var 
i:uint=0i<_skeleton.joints.length; ++i{
 
var jointPose:JointPose = new JointPose();
 
jointPose.copyFrom(currentPose.jointPoses[i]);
 
jointPose.name _skeleton.joints[i].name;
 
pose.jointPoses.push(jointPose);

Tadam! The skeleton works as intended now smile

Beware of the line “jointPose.name = _skeleton.joints.name;”, copyFrom doesn’t copy the Joint name (actualy the currentPose has only null names, how can it work like that? It’s a kind of magic smile)

 

   

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

Ah yes, globalPose ! Sounds like something I could have found, but I’m coming too late. Darn you.

Good job and thanks for sharing the final solution. Sounds like it took you a bunch of hours :D *patpats*

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X