Java Reference
In-Depth Information
Figure 17. Second code segment for ManualEyeApp.java
43. public void createPanel(int index) {
44.
JLabel currentLabel; JButton currentMinus; JLabel currentValue; JButton currentPlus;
45.
viewManager.createControlPanel();
46.
String[] labelString = {"X", "Y", "Z"};
47.
switch (index) {
48.
case 0: canvas3D[index].getLeftManualEyeInImagePlate(eye); break;
49.
case 1: canvas3D[index].getRightManualEyeInImagePlate(eye); break; }
50.
for (int i = 0; i < 3; i++) {
51.
currentLabel = new JLabel(labelString[i]);
52.
currentMinus = new JButton("-"); currentPlus = new JButton("+");
53.
switch (i) {
54.
case 0: currentValue = new JLabel(String.valueOf(eye.x)); break;
55.
case 1: currentValue = new JLabel(String.valueOf(eye.y)); break;
56.
case 2: currentValue = new JLabel(String.valueOf(eye.z)); break;
57.
default: currentValue = new JLabel(""); }
58.
currentValue.setHorizontalAlignment(JLabel.RIGHT);
59.
currentMinus.addActionListener (this); currentPlus.addActionListener (this);
60.
label.add(currentLabel);
61.
minus.add(currentMinus); value.add(currentValue); plus.add(currentPlus);
62.
viewManager.addControl(currentLabel, 1, 3); viewManager.addControl(currentMinus);
63.
viewManager.addControl(currentValue); viewManager.addControl(currentPlus); } }
As can be seen from the screen shot in Figure 18, the left and right eyes show slightly
more of the left and right sides of the virtual world, respectively. Figure 19 shows some
results when the x, y, and z coordinates of the eyes are changed.
The values reflected on the panel show the default position for the left and right eyes
respectively. This is with respect to the image plate coordinate, with the positive x axis
pointing to the right, positive y axis pointing to up, and the positive z axis pointing out of
the image plate.
The left eye view and the right eye view significantly differ from the ones in Mono-
scopicPolicyApp, this is because of the different View policies being used. Monoscop-
icPolicyApp uses the default View policy, that is View.RELATIVE_TO_FIELD_OF_VIEW,
while ManualEyeApp uses the View.RELATIVE_TO_SCREEN policy. It is also because
of this policy that the portion of the virtual world that is rendered changes as the window
is moved around the screen.
Since the left eye view is independent of the right eye view, it is possible to observe the
changes on one view and expect the other view to respond in the same manner. Setting the
x position of the left eye to 0.202, essentially moving the eye to the right, results in more of
the left portion of the virtual world being rendered. Similarly, moving the left eye to the left
to x position 0.52 results in more of the right portion of the virtual world being rendered.

Search WWH ::

Custom Search