I need some help with my loader. Position animation works fine, but scaling and rotating don’t really work correctly. The way animation works in my loader (or doesn’t work :P), is that I have have an AnimationGroup class that contains a reference to the TransformGroup and Transform3D of an object that will be animated. Then a setTime() function is called indirectly by the user of TDSModel (though setCurrentFrame), which calls the setTime function of all AnimationGroups:
public void setTime(float time) {
if (rotTransform != null)
rotTransform.setTime(time);
if (posTransform != null)
posTransform.setTime(time);
if (scaleTransform != null)
scaleTransform.setTime(time);
objectOfTransform.setTransform(transformOfObject);
}
This, as you can see, calls the setTime function of all the different types of animation. Each of the classes that the setTime is called on, have a reference back to their “parent” AnimationGroup class, so that they can directly manipulate the object’s Transform3D. So first the rotation is applied like so: parent.transformOfObject.setRotation(AxisAngle4f). Then posTransform sets the postion like so: parent.transformOfObject.setTranslation(Vector3f). Then scaleTransform sets the scale of the object like so: parent.transformOfObject.setScale(floatScale).
Then finally AnimationGroup sets the Transform3D onto the TransformGroup object: objectOfTransform.setTransform(transformOfObject);
Now, in animations from models that i’m testing, I’m getting funky results. If I animate just the position, it works fine. However, if I animate just the scaling, then the object scales, but it also moves in some direction (even when the position is not being animated), instead of just scaling in place. And the rotation also does not rotate the object in place, but rather moves and rotates it (again, even with the other two animations off).
So obviously I think I’m doing something wrong here, but what is it?
If you want to look at the actual code then click my sig and download the loader (even if you already have, I just re-uploaded a “new” v1.2 with the changes in animation. It’s currently set to just animate the postion–which it does correctly)
Relevant classes:
TimedTransform
PosTransform
RotTransform
ScaleTransform
AnimationGroup
RotationChunk – enable/disable rotation animation
PositionChunk – enable/disable position animation
ScaleChunk – enable/disable scale animation
TDSModel

