Java Reference
In-Depth Information
Create a VirtualUniverse object.
Create a relevant Locale object and attach this to the VirtualUniverse.
Construct content branches.
Compile branch graphs and attach to Locale.
Construct view branch and attach to Locale.
Create a Canvas3D object.
Create a TransformGroup TG.
Create a ViewPlatform object VP and attach to the TransformGroup TG.
Create a View object and attach to the ViewPlatform.
Create a Canvas3D object and attach to the View.
Create a PhysicalBody object and attach to the View.
Figure 3. Code segment for setting up simple universe
1.
public SimpleUniverseApp () {
2.
virtualUniverse = new VirtualUniverse();
Locale locale = new Locale(virtualUniverse);
3.
VirtualWorld vWorld = new VirtualWorld(); BranchGroup scene = vWorld.createVirtualWorld();
4.
scene.compile(); locale.addBranchGraph(scene);
5.
BranchGroup view = createViewGraph(); enableInteraction(view); view.compile();
6.
locale.addBranchGraph(view); }
7.
8.
public BranchGroup createViewGraph() {
9.
Canvas3D canvas3D = new Canvas3D(); String caption = "Example 1";
10.
TransformGroup viewPlatform; viewManager = new ViewManager(this, 1, 1);
11.
BranchGroup viewRoot = new BranchGroup();
12.
TransformGroup transformGroup = new TransformGroup();
13.
viewRoot.addChild(transformGroup);
14.
GraphicsConfiguration config = viewManager.getPreferredGraphicsConfiguration();
15.
canvas3D = new Canvas3D(config); viewManager.add(canvas3D, caption);
16.
viewPlatform = createViewPlatform(canvas3D, 0);
17.
transformGroup.addChild(viewPlatform);
18.
return viewRoot; }
19.
20. public TransformGroup createViewPlatform(Canvas3D canvas3D, int mode) {
21.
Transform3D transform3D = vpTransform3D(mode);
22.
ViewPlatform viewPlatform = new ViewPlatform();
23.
TransformGroup objTransform = new TransformGroup(transform3D);
24.
objTransform.addChild(viewPlatform);
25.
View view = new View();
26.
view.attachViewPlatform(viewPlatform);
27.
view.addCanvas3D(canvas3D);
28.
view.setPhysicalBody(new PhysicalBody());
29.
view.setPhysicalEnvironment(new PhysicalEnvironment());
30.
return objTransform; }
Search WWH ::




Custom Search