Java Reference
In-Depth Information
The alpha object for this simulation has alphaAtOneDuration and alphaAtZeroDuration
equal to 4000. With these values, the visual object observed will be a trapezoidal one for
4 seconds before changing to a prism. SwitchValueInterpolator is invoked in line 8, with
its input arguments being the alpha object and the target switch node.
transparencyInterpolator
The TransparencyInterpolator class can be used to change the transparency of an visual
object by altering its transparency attributes.
In the example of Figure 9, a visual trapezoidal object is declared in line 8. Line 10 creates
an appearance object, and the appearance of the visual object is passed to this appearance
Figure 9. Code segment and result of DemoTransparencyInterpolator.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,
4000, 2000, 1000, 4000, 2000, 1000);
6.
TransformGroup objTransparency = new TransformGroup();
7.
objTransparency.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
8.
Shape3D quadTransparentObj = new Quad();
9. objTransparency.addChild(quadTransparentObj);
10. Appearance quadTransparentObjAppear = quadTransparentObj.getAppearance();
11. TransparencyAttributes transparencyAttr = new TransparencyAttributes();
12. transparencyAttr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
13. transparencyAttr.setTransparencyMode(TransparencyAttributes.BLENDED);
14. quadTransparentObjAppear.setTransparencyAttributes(transparencyAttr);
15. TransparencyInterpolator transparencyInterpol = new TransparencyInterpolator(alpha,
transparencyAttr, 0f, 1f);
16. transparencyInterpol.setSchedulingBounds(bound);
17. TransformGroup objTilt = new TransformGroup();
18. Transform3D tiltX = new Transform3D();
19. Transform3D tiltY = new Transform3D();
20. tiltX.rotX(Math.PI/5.0d);
21. tiltY.rotY(Math.PI/5.0d);
22. tiltX.mul(tiltY);
23. objTilt.setTransform(tiltX);
24. objRoot.addChild(objTilt);
25. objTilt.addChild(objTransparency);
26. objTransparency.addChild(transparencyInterpol);
27. objRoot.compile();
28. return objRoot;
29. }
Search WWH ::




Custom Search