Java Reference
In-Depth Information
Create a PhysicalEnvironment object and attach to the View.
Attach the TransformGroup to view branch.
Note that the creation and use of a TransformGroup for attaching the ViewPlatform
is to ensure that the viewing angle or position can be changed by using the appropriate
transformation. The code segment in Figure 3 gives an example showing how the structure
of a SimpleUniverse object can be set up.
Figure 4. Code structure for multiple views
1.
public class ViewModelApp extends JApplet implements ActionListener
2.
{
3.
public void main(String[] args)
4.
{
// main method to run the application, specify screen size
5.
}
6.
7.
public ViewModel()
8.
{
// constructor, calls createViewGraph() and createVirtualWorld() from VirtualWorld.java
9.
}
10.
11.
public void destroy()
12.
{
// destructor
13.
}
14.
15.
public BranchGraph createViewGraph()
16.
{
// uses ViewManager.java to format and insert captions; calls createViewPlatform()
17.
}
18.
19.
public TransformGroup createViewPlatform(Canvas3D canvas3D, int mode)
20.
{
// most of the settings on the view model made here; calls vpTransform3D
21.
}
22.
23.
public Transform3D vpTransform3D(int mode)
24.
{
// specify the orientation and position of the View Platform
25.
}
26.
27.
public void enableInteraction(BranchGroup viewRoot)
28.
{
// functionality for keyboard and mouse navigation in the virtual world
29.
}
30.
31.
public void createPanel(int mode)
32.
{
// adds control such as buttons and check boxes for interaction
33.
}
34.
35.
public void actionPerformed(ActionEvent e)
36.
{
// specify the changes to be made when a control element is clicked
37.
}
38. }
Search WWH ::




Custom Search