Java Reference
In-Depth Information
Figure 1. Code segment and result of DemoPositionInterpolator.java
1.
public BranchGroup createSceneGraph()
2.
{
3.
BranchGroup objRoot = createBranchScene();
4.
5.
BoundingSphere bound = new BoundingSphere();
6.
Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE, 0, 0,
4000,2000,1000, 4000, 2000, 1000);
7.
8.
TransformGroup objPosition = new TransformGroup();
9.
objPosition.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
10.
objPosition.addChild(new Quad());
11.
12.
Transform3D axisPosition = new Transform3D();
13.
axisPosition.rotZ(Math.PI/2.0);
14.
PositionInterpolator positionInterpol = new PositionInterpolator(alpha,
objPosition,axisPosition, 0f, 0.8f);
15.
positionInterpol.setSchedulingBounds(bound);
16.
17.
TransformGroup objTilt = new TransformGroup();
18.
19.
Transform3D tiltX = new Transform3D();
20.
Transform3D tiltY = new Transform3D();
21.
tiltX.rotX(Math.PI/5.0d);
22.
tiltY.rotY(Math.PI/5.0d);
23.
tiltX.mul(tiltY);
24.
objTilt.setTransform(tiltX);
25.
26.
objRoot.addChild(objTilt);
27.
objTilt.addChild(objPosition);
28.
objPosition.addChild(positionInterpol);
29.
30.
objRoot.compile();
31.
32.
return objRoot;
33.
34. }
positionpathInterpolator
The code segment and results in Figure 2 show how PositionPathInterpolator can be used
together with the alpha values to change the translational position of the target Transfor-
Search WWH ::




Custom Search