Java Reference
In-Depth Information
content branch for the rotatingcube
The content branch, as its name suggests, is the container for the 3D objects, their attributes
and behavior in a scene. From extracting the overall code fragment of Figure 1, Figure 6
shows the content branch in the RotatingCube example. In general, the 3D content of the
scene will include the geometry, appearance and behavior attributes of the object and the
scene.
Figure 6. Content branch and scene graph for the RotatingCube example
12. protected BranchGroup buildContentBranch(Node Geometry_Appearance)
13. {
14. BranchGroup BG_c=new BranchGroup();
15. Transform3D S1 = new Transform3D();
16. S1.set(new AxisAngle4d(1.0,1.0,0.0,Math.PI/4.0));
17. TransformGroup TG_c = new TransformGroup();
18. TG_c.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
19. BG_c.addChild(TG_c);
20. TG_c.addChild(Geometry_Appearance);
21. Transform3D yAxis = new Transform3D();
22. Alpha rotationAlpha = new Alpha(-1,4000);
23. RotationInterpolator B1 = new RotationInterpolator
(rotationAlpha,TG_c,yAxis,0.0f,(float)Math.PI*2.0f);
24. BoundingSphere bounds=new BoundingSphere (new Point3d(0.0,0.0,0.0),100.0);
25. B1.setSchedulingBounds(bounds);
26. TG_c.addChild(B1);
27. BG_c.compile();
28. return BG_c;
:
:
:
:
34. protected Node buildShape()
35. {
36.
BG_c
Branch Group
Transform Group
TG_c
S1 Shape3D node
return new ColorCube(0.4);}
:
45. public RotatingCube()
46. {
Geometry
47.
GraphicsConfiguration
48.
config=SimpleUniverse.getPreferredConfiguration();
49.
Canvas3D Canvas3D_1=new Canvas3D(config);
50.
BranchGroup scene=buildContentBranch(buildShape());
:
}
Search WWH ::




Custom Search