Java Reference
In-Depth Information
in the example of Figure 7, three arrays specifying rotation, translation, and scaling have
to be supplied at each position, in addition to the knots array.
switchvalueInterpolator
This class of interpolator allows the child of the target switch node to be selected. Specifi-
cally, if the target switch node has n children, the child index selected using SwitchVal-
ueInterpolator can range from 0 to n-1.
In the illustrating example of Figure 8, the target switch node has 2 children. Specifically,
line 6 defines the target switch node, and line 7 sets its capability to ALLOW_SWITCH_
WRITE, enabling the selected child to be modified. Lines 10 and 11 add the children for
this node, with the first child index being associated with a trapezoidal object, and the
second child index being that for a prism.
Figure 8. Code segment and result of RotPosScalePathInter.java
1.
public BranchGroup createSceneGraph()
2.
{
3.
BranchGroup objRoot = createBranchScene();
4.
BoundingSphere bound = new BoundingSphere();
5.
Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE, 0, 0, 0,
0, 4000, 0, 0, 4000);
6. Switch objSwitch = new Switch();
7. objSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
8. SwitchValueInterpolator switchInterpol = new SwitchValueInterpolator (alpha, objSwitch);
9. switchInterpol.setSchedulingBounds(bound);
10. objSwitch.addChild(new Quad());
11. objSwitch.addChild(new Triangle());
12. TransformGroup objTilt = new TransformGroup();
13. Transform3D tiltX = new Transform3D();
14. Transform3D tiltY = new Transform3D();
15. tiltX.rotX(Math.PI/5.0d);
16. tiltY.rotY(Math.PI/5.0d);
17. tiltX.mul(tiltY);
18. objTilt.setTransform(tiltX);
19. objRoot.addChild(objTilt);
20. objTilt.addChild(objSwitch);
21. objTilt.addChild(switchInterpol);
22. switchInterpol.setLastChildIndex(1);
23. objRoot.compile();
24. return objRoot;
25. }
Search WWH ::




Custom Search