www.jpct.net
Bones - Skeletal and Pose Animations for jPCT/jPCT-AE => Bones => Topic started by: AGP on August 18, 2014, 10:30:28 pm
-
Is there a way to transition gradually between one animation and another? Something along the lines of Unity's Animator.CrossFade (http://docs.unity3d.com/ScriptReference/Animator.CrossFade.html (http://docs.unity3d.com/ScriptReference/Animator.CrossFade.html))? Because that's one of the main things that a rigged object can do that a vertex-animated one can't.
-
no, not officially. you can blend pose animations with each other and with a skeletal animation but you cannot blend skeletal animations.
but of course you can try to implement it yourself. chase's skeleton helper (http://www.jpct.net/forum2/index.php/topic,3300.0.html) does skeleton pose interpolation, you can also try that.
-
Cool, I'll test this one and report back. Thanks.
-
I'm trying to interpolate between different animations, not SkeletonPoses. I don't even know how SkeletonHelper could help me with this, because all it sees is SkeletonPoses.
-
each time you apply a skin animation, first a skeleton pose is calculated then it's applied to mesh
-
OK. In this case, I need two SkeletonPoses, and I need them before the character is animated. Where would I call animatedGroup.get(0).getSkeletonPose()?
-
get two clones of SkeletonPose of the group. position each one according to your need. then interpolate them and apply the result to the original SkeletonPose.
-
The following isn't working.
animatedGroup.animateSkin(0.04f, IDLE);
animatedGroup.applyAnimation();
idlePose = animatedGroup.get(0).getSkeletonPose().clone();
idlePose.setToBindPose();//NOT SURE IF THIS IS NEEDED. JUST TRYING
idlePose.updateTransforms();//NOT SURE IF THIS IS NEEDED. JUST TRYING
animatedGroup.animateSkin(0.04f, WALKS);
animatedGroup.applyAnimation();
walkingPose = animatedGroup.get(0).getSkeletonPose().clone();
walkingPose.setToBindPose();//NOT SURE IF THIS IS NEEDED. JUST TRYING
walkingPose.updateTransforms();//NOT SURE IF THIS IS NEEDED. JUST TRYING
Then, in the game loop:
SkeletonPose pose = SkeletonHelper.interpolateSkeletonPose(idlePose, walkingPose, skinFrame+=deltaTime);
animatedGroup.setSkeletonPose(pose);
pose.updateTransforms();
animatedGroup.applySkeletonPose();
if (skinFrame >= 1.00f)
//SWITCH TO SECOND ANIMATION
What I get is the character in his static pose during the entire interpolation time (at the end of which, obviously, he switches to the second animation successfully). So, what should I be doing differently?
-
SkeletonPose.clone does not copy the current pose (animation). it just creates a new SkeletonPose attached to same Skeleton. try somthing like:
SkeletonPose pose1 = animatedGroup.get(0).getSkeletonPose().clone();
SkeletonPose pose2 = animatedGroup.get(0).getSkeletonPose().clone();
SkinClipSequence clip = animatedGroup.getSkinClipSequence();
clip.getClip(someIndex).applyTo(time, pose1);
clip.getClip(someOtherIndex).applyTo(time, pose2);
SkeletonPose newPose = SkeletonHelper.interpolateSkeletonPose(pose1, pose2, weight);
animatedGroup.setSkeletonPose(pose);
-
I had to add
pose.updateTransforms();
after setSkeletonPose() before it worked, but it finally did. Thanks a whole lot.