Java Reference
In-Depth Information
ment give rise to a pick shape that is cylindrical in nature with a certain circular cross
section. However, the former is infinite in its length, whereas the latter has a length that
is finite and can be specified.
Figures 20 and 21 illustrate the use of PickCylinderRay to pick a trapezoidal object and
transforming it to become a square. Figure 20 shows the important variables, the construc-
Figure 20. First code segment and result for PickCylinderRayBehavior.java
1.
public class SimpleBehavior extends Behavior
2.
{
3.
private WakeupCriterion[] allEvents;
4.
private PickCanvas pickCanvas;
5.
private Point3d p_3d;
6.
private PickResult pickres;
7.
private Shape3D shape3d;
8.
private BranchGroup branch;
9.
10.
public SimpleBehavior ( Canvas3D canvas, BranchGroup branchgroup ) // constructor
11.
{
12.
pickCanvas = new PickCanvas( canvas, branchgroup );
13.
pickCanvas.setTolerance( 0.0f );
14.
pickCanvas.setMode( PickCanvas.GEOMETRY );
15.
pickCanvas.setMode( PickTool.GEOMETRY );
16.
pickCanvas.setMode( PickCanvas.GEOMETRY_INTERSECT_INFO );
17.
branch = branchgroup;
18.
}
19.
20.
public void initialize()
21.
{
22.
allEvents = new WakeupCriterion[2];
23.
allEvents[0] = new WakeupOnAWTEvent( MouseEvent.MOUSE_DRAGGED );
24.
allEvents[1] = new WakeupOnAWTEvent( MouseEvent.MOUSE_PRESSED );
25.
wakeupOn ( new WakeupOr( allEvents ) );
26.
}
27.
public void processStimulus(Enumeration criteria)
28.
{
// actions to take when triggered }
29. }
Trapezoidal object
becomes a square
through pressing or
dragging the mouse
Search WWH ::




Custom Search