Performing a Sequence of Animated Transformations
Hi everyone, I'm a rookie at Java3D, and am desperately searching for help with a problem. I'm sure it's not too complex, but I can't seem to figure it out for the life of me. I am working on a simple Rubik's cube simulation in J3D, and am currently trying to get the cube to move its parts and animate. The moves that the cube does will be controlled by a string in memory that dictates the order of moves (ex. "FBL'R"). I figured that I could use multiple RotationInterpolators to accomplish this goal, but instead of playing in sequence, the latter one just overwrites the others completely. The code I'm using is as follows:
topClockwiseGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
topClockwiseGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
root.addChild(topClockwiseGroup);
// Adds the appropriate cubelet faces to this group
topClockwiseGroup.addChild(topFaceGroup(cubeBranch));
// Adds the interpolator to this
topClockwiseGroup.addChild(clockwiseAnimation(topClockwiseGroup));
// Makes the cube visible
root.addChild(cubeBranch);
u.addBranchGraph(root);
root.detach();
TransformGroup allClockwiseGroup = new TransformGroup();
allClockwiseGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
allClockwiseGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
allClockwiseGroup.addChild(allFaceGroup(cubeBranch));
allClockwiseGroup.addChild(clockwiseAnimation(allClockwiseGroup));
root.addChild(allClockwiseGroup);
root.addChild(cubeBranch);
And here is the interpolator's code:
public RotationInterpolator clockwiseAnimation (TransformGroup cubeTG){
Alpha rotationAlpha = new Alpha(1, 4000);
RotationInterpolator interpolator = new RotationInterpolator(rotationAlpha, cubeTG, new Transform3D(), 0.0f, -(float)(Math.PI/2.0));
interpolator.setSchedulingBounds(bounds);
return interpolator;
}
I'm not even sure if this is the right approach... so I would really appreciate some input on this.




