Java Reference
In-Depth Information
The Locale object, denoted by L1 in Figure 4, contains a set of branches, or BranchGroup
subgraphs at a specified location in the VirtualUniverse. In terms of structure, the Locale
is child node of the VirtualUniverse and the parent of BranchGroup objects. Each Locale
node may be used for several visual, interaction, sound, and other objects that are next to
a certain location in the universe. In the chapter on multiple views, we will see that each
locale may also be used to provide a different view of the same universe.
Each Locale node may have many branches depending on applications. In the example
in Figure 2-4, two BranchGroup nodes BG_v and BG_c, which serves as the root of the
view and content subgraphs, are attached to the Locale node L1.
vIeW branch for the rotatingcube
The generic view branch shown in Figure 4 is primarily for defining the way the user sees
the 3D objects in the virtual universe. In the RotatingCube example, the SimpleUniverse
class is invoked to instantiate a view branch with default parameters. This is sufficient for
many simple applications.
In more complicated applications, a more specific view branch may be needed for
creating special views into the virtual 3D universe. An example for creating a customized
view branch is given in Figure 5. This code segment can be used to replace line 10 as well
as lines 47 and 48 in the RotatingCube code segment of Figure 1. With some other minor
modifications, the same result, which is a rotating color cube, will be obtained.
Figure 5. A more specific view branch
1. protected BranchGroup buildViewBranch(Canvas3D c){
2. BranchGroup BG_v = new BranchGroup();
3. Transform3D viewTransform = new Transform3D();
4. viewTransform.set(new Vector3f(0.0f,0.0f,5.0f);
5. TransformGroup TG_v = new TransformGroup(viewTransform);
6. ViewPlatform VP = new ViewPlatform();
7. TG_v.addChild(VP);
8. BG_v.addChild(TG_v);
9. View View1 = new View();
10. PhysicalBody Body1 = new PhysicalBody();
11. PhysicalEnvironment Environ1 = new PhysicalEnvironment();
12. View1.setPhysicalBody(Body1);
13. View1.setPhysicalEnvironment(Environ1);
14. View1.addCanvas3D(c);
15. View1.attachViewPlatform(VP);
16. return BG_v;
17. }//end
BG_v
TG_v
Screen3D
View1
Canvas3D_1
VP
Body1
Environ1
Search WWH ::




Custom Search