Hi,
we got several selfmade models (j3o) with bones but without animations.
The animations were planned to happen in code. AnimationFactory was thus modified to support BoneTrack as follows:
[java]
public Animation buildAnimation(Class<? extends Track> class1)
{...
if (SpatialTrack.class.equals(class1))
{
… usual SpatialStuff …
}
else if (BoneTrack.class.equals(class1))
{
BoneTrack boneTrack = new BoneTrack(5, times, translations, rotations, scales);
// creating the animation
spatialAnimation = new Animation(name, duration);
spatialAnimation.setTracks(new BoneTrack[] { boneTrack });
}
[/java]
Nothing fancy, just changed SpatialTrack to BoneTrack. (Would be nice to have BoneTrack support in the AnimationFactory btw)
We just modified it to have a proper way of simple animation interpolating instead of doing the calculations on our own.
As a guideline we’ve used TestOgreComplexAnim.java to construct the bone animation stuff:
[java]
animControl = model.getControl(AnimControl.class); // get control over this model
…
animControl.addAnim(getWalkAnimation(“ourAnimation”…));
// run animation
channelLArm = animControl.createChannel();
channelLArm.addFromRootBone("uparm.right");
channelLArm.setAnim("ourAnimation");
[/java]
[java]
@Override
protected Animation getWalkAnimation(String animationName, Vector3f offset, float strength, boolean reverse)
{
// negative if reverse animation is true
float neg = reverse ? -1.0f : 1.0f;
// animation of 2 seconds named animationName and with 25 frames per second
AnimationFactory animationFactory = new AnimationFactory(2, animationName, 25);
// creating a translation keyFrame at time = 0 with a translation in WU
animationFactory.addTimeTranslation(0, offset);
animationFactory.addTimeRotation(0, Quaternion.IDENTITY);
// Creating a rotation keyFrame at time = 0.5 of quarter PI around the X axis
animationFactory.addTimeRotation(0.5f, new Quaternion().fromAngleAxis(-neg * strength * FastMath.QUARTER_PI, walkDirection));
animationFactory.addTimeRotation(1.5f, new Quaternion().fromAngleAxis(neg * strength * FastMath.QUARTER_PI, walkDirection));
// rotating back to initial rotation value at time = 2
animationFactory.addTimeRotation(2.0f, Quaternion.IDENTITY);
return animationFactory.buildAnimation(BoneTrack.class);
}
[/java]
Now to the actual bug: We got several models loaded playing the same animation but as soon as one of the models disappears from the screen the animation gets reset for all models.
In addition a small video demonstrating the effect:
[video]http://www.youtube.com/watch?v=w24hDvTtlXI[/video]
Behind the wall there are couple more models playing the animation.
Sinbad-Demo does not show this effect as it uses predefined animations.
Greets