Java Reference
In-Depth Information
Figure 15. Code segment and result for MonoscopicPolicyApp.java
1.
public BranchGroup createViewGraph(){
2.
final int numberOfViews = 3; Canvas3D canvas3D[] = new Canvas3D[numberOfViews];
3.
String caption[] = {"Left Eye View", "Cyclopean Eye View", "Right Eye View"};
4.
TransformGroup viewPlatform; viewManager = new ViewManager(this, 1, 3);
5.
BranchGroup viewRoot = new BranchGroup();
6.
TransformGroup transformGroup = new TransformGroup();
7.
viewRoot.addChild(transformGroup);
8.
9.
GraphicsConfiguration config = viewManager.getPreferredGraphicsConfiguration();
10.
for (int i = 0; i < numberOfViews; i++) {
11.
canvas3D[i] = new Canvas3D(config);
12.
viewManager.add(canvas3D[i], caption[i]); }
13.
canvas3D[0].setMonoscopicViewPolicy(View.LEFT_EYE_VIEW);
14.
canvas3D[1].setMonoscopicViewPolicy(View.CYCLOPEAN_EYE_VIEW);
15.
canvas3D[2].setMonoscopicViewPolicy(View.RIGHT_EYE_VIEW);
16.
viewPlatform = createViewPlatform(canvas3D, FRONT_VIEW);
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.setPhysicalBody(new PhysicalBody());
28.
view.setPhysicalEnvironment(new PhysicalEnvironment());
29.
for (int i = 0; i < canvas3D.length; i++) view.addCanvas3D(canvas3D[i]);
30.
return objTransform; }
In the createViewPlatform method, line 26 dictates the use of a View.RELATIVE_
TO_SCREEN policy. This is essential in order for manual eye adjustment to work. In the
createPanel method of Figure 17, the switch statement in line 47 retrieves either the left
or right eye coordinates depending on the panel index. The coordinates are then placed in
Search WWH ::




Custom Search