I want to animate a group of objects rotating around the z axis. I tried to do this by using the RotationInterpolator class which takes in (at least) an Alpha class (timer) and TransformGroup (the objects to rotate).
Here's a conceptual scene graph of my object structure:
The rotation itself is pretty simple to achieve but unfortunately I can't figure out how to rotate around any axis other that the y axis. Here's the code I have right now:
// SphereRing is a collection of SphereObject classes (which inherit the object Sphere) sphereRings[nextSphereRing] = new SphereRing( radius ); // The method getTG() returns the TransformGroup. This TransformGroup contains each individual SphereObjects TransformGroup as children (see concept graph above) // variable masterTG is a TransformGroup masterTG.addChild( sphereRings[nextSphereRing].getTG() ); // create time varying function to drive the animation, on infinite loop with a 4sec calling interval Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator( rotationAlpha, sphereRings[nextSphereRing].getTG() ); // a bounding sphere specifies a region a behavior is active BoundingSphere bounds = new BoundingSphere(); rotator.setSchedulingBounds(bounds); masterTG.addChild(rotator); // variable scene is a BranchGroup scene.addChild(masterTG); scene.compile(); // variable simpleU is a SimpleUniverse simpleU.addBranchGraph(scene);
The Java documentation says that in RotationInterpolator, "[t]he interpolated angle is used to generate a rotation transform about the local Y-axis of this interpolator." So is the case that this object can only rotate around this axis?
From searching online I've found several posts on the Java.net forum and other forums but these deal with adding another axis of rotation as opposed to changing it to another.
I noticed that in the tutorial I'm mainly working from, Getting Started with the Java 3Dô API, the authour says of behaviours (which are ancestor classes of interpolators) "All of the mentioned behaviors are possible without using an interpolator; however, interpolators make creating a behavior much easier." Perhaps the scope of RotateInterpolator is only a rough and ready y axis rotator?
In the description of the RotationInterpolar short constructor, a variable in the long constructor - axisOfTranform - is by "set to identity". So perhaps by changing this matrix I can change the axis? I'll behonest, I don't quite understand how to do this, even after reading a stackoverflow forum thread which describes a similar problem.
Can anyone clear this up for me?