Java Reference
In-Depth Information
Figure 2. First code segment for PickBehaviour.java
1. import java.applet.Applet;
2. import java.awt.BorderLayout;
3. import java.awt.Frame;
4. import com.sun.j3d.utils.applet.MainFrame;
5. import com.sun.j3d.utils.geometry.*;
6. import com.sun.j3d.utils.universe.*;
7. import com.sun.j3d.utils.picking.behaviors.*;
8. import javax.media.j3d.*;
9. import javax.vecmath.*;
10. import java.awt.event.*;
11. import java.util.Enumeration;
12. import com.sun.j3d.utils.behaviors.keyboard.*;
13.
14. public class pickApp extends Applet
15. {
16.
Shape3D Landscape()
17.
{
18.
LineArray landGeom = new LineArray(44, GeometryArray.COORDINATES |
19.
GeometryArray.COLOR_3);
20.
float l = -100.0f;
21.
for(int c = 0; c < 44; c+=4)
22.
{
23.
landGeom.setCoordinate( c+0, new Point3f( -100.0f, 0.0f, l ));
24.
landGeom.setCoordinate( c+1, new Point3f( 100.0f, 0.0f, l ));
25.
landGeom.setCoordinate( c+2, new Point3f( l , 0.0f, -100.0f ));
26.
landGeom.setCoordinate( c+3, new Point3f( l , 0.0f, 100.0f ));
27.
l += 10.0f;
28.
}
29.
30.
Color3f c = new Color3f(0.1f, 0.8f, 0.1f);
31.
for(int i = 0; i < 44; i++) landGeom.setColor( i, c);
32.
33.
return new Shape3D(landGeom);
34.
}
35.
they are related to one another. This is described below and shows the processing and flow
involved in a typical picking operation:
PickTool: This is the base class in picking, and defines the tool that will be used in
the process. The associated method will return a PickResult object for each object
picked.
PickCanvas: This is a subclass of PickTool for the purpose of simplifying picking
based on mouse events from a canvas, and allows for picking using positional loca-
tions on a canvas through the generation of appropriate pick shape.
Search WWH ::

Custom Search