...
> The other option is to make three nested transformgroups, each one of
> which is responsible for its own axis of rotation and has its own
> rotationinterpolator.
Pretty new to this TransformGroup stuff. Can you guide me to any
examples of nested transforms (especially with different rotations) ?
The idea is the same as "The Multi-Axis Spin-Test Inertia [186]
Facility (MASTIF) trainer" pictured at
http://history.nasa.gov/SP-45/ch10.htm [
http://history.nasa.gov/SP-45/p178i.jpg ]
> The other option is to make three nested transformgroups, each one of
> which is responsible for its own axis of rotation and has its own
> rotationinterpolator.
I persevered at bit and came up with this:
/*
* SceneGraph1.java
*/
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.Alpha;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.RotationInterpolator;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
public class SceneGraph1 extends BranchGroup
{
private BoundingSphere boundingSphere;
public SceneGraph1 ()
{
super();
TransformGroup xGimbal = new TransformGroup();
TransformGroup yGimbal = new TransformGroup();
TransformGroup zGimbal = new TransformGroup();
xGimbal.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
yGimbal.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
zGimbal.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
addChild(xGimbal);
xGimbal.addChild(yGimbal);
yGimbal.addChild(zGimbal);
ColorCube cube = new ColorCube(0.4);
zGimbal.addChild(cube);
Transform3D xAxis = new Transform3D();
Transform3D yAxis = new Transform3D();
Transform3D zAxis = new Transform3D();
xAxis.rotX(Math.PI/2.05);
yAxis.rotY(Math.PI/1.25);
zAxis.rotZ(Math.PI/1.43);
Alpha xRotationAlpha = new Alpha(-1,
Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE, 0, 90,2500,200,
0,1460,200, 0);
Alpha yRotationAlpha = new Alpha(-1,
Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE,
0,210,2120,100,125,1425,150, 90);
Alpha zRotationAlpha = new Alpha(-1,
Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE,
0,320,2800,150,100,1900,640,120);
RotationInterpolator xRotator = new
RotationInterpolator(xRotationAlpha, xGimbal, xAxis, 0f, (float)
Math.PI*2.0f);
RotationInterpolator yRotator = new
RotationInterpolator(yRotationAlpha, yGimbal, yAxis, 0f, (float)
Math.PI*2.0f);
RotationInterpolator zRotator = new
RotationInterpolator(zRotationAlpha, zGimbal, zAxis, 0f, (float)
Math.PI*2.0f);
boundingSphere = new BoundingSphere(new Point3d(0.0,0.0,0.0),
100.0);
xRotator.setSchedulingBounds(boundingSphere);
yRotator.setSchedulingBounds(boundingSphere);
zRotator.setSchedulingBounds(boundingSphere);
xGimbal.addChild(xRotator);
yGimbal.addChild(yRotator);
zGimbal.addChild(zRotator);
// Set background color
Color3f bgColor = new Color3f(0.5f,0.5f,0.5f);
Background bgNode = new Background(bgColor);
bgNode.setApplicationBounds(boundingSphere);
addChild(bgNode);
// Have Java 3D perform optimizations on this scene graph.
compile();
}
public BoundingSphere getBoundingSphere ()
{
return boundingSphere;
}
}
sanbikinoraion - 05 Nov 2006 11:29 GMT
Have you seen this site? I found it very useful when I was starting
out:
http://www.java-tips.org/other-api-tips/java3d/