Java Reference
In-Depth Information
Figure 7. Code Segment for using the SimpleUniverse class
Virtual Universe
U1
10. private SimpleUniverse U1 = null;
:
:
45. public RotatingCube()
46. {
47. GraphicsConfiguration
48. config=SimpleUniverse.getPreferredConfiguration();
49. Canvas3D
Canvas3D_1=new Canvas3D(config);
:
54.
Locale
L1
BG_v
TG_v
Screen3D
add("Center",Canvas3D_1);
:
:
}//end RotatingCube()
View1
Canvas3D_1
VP
Body1
Environ1
with default values used for the important parameters and nodes. The code segment for
doing so is also provided in the figure.
Very briefly, line 10 in Figure 7 invokes the constructor to create a simple universe. In
the java applet, all the variables in the method public RotatingCube(), starting from line
45, will then be initialized when the source code is compiled.
Lines 47 and 48 in Figure 7, invoke the SimpleUniverse.getPreferredConfiguration
method for passing the Graphics Configuration to the Canvas3D constructor. The latter
will construct a Canvas3D object, which corresponds to a 2D image plate in the 3D virtual
world. Projecting the 3D objects onto this 2D image plate appropriately and painting this
image plate onto the computer display will enable the user to view the virtual world. Line
54 adds the created Canvas3D canvas to the simple universe.
dIfference betWeen Java 3d applet and
applIcatIon
A standalone application of Java 3D and a Web-based Java 3D application in the form of
an applet may share most of the classes. This implies that the codes written for the stand-
alone application can easily be migrated to a Web-based applet application without much
modification. However, there is a need to take into consideration of the following three
issues in the event of a migration.
Search WWH ::




Custom Search