Java Reference
In-Depth Information
keyboard, mouse or other wakeup events that will trigger the behavior. The various types
of wakeup events have been extensively described in the last chapter on interaction and
behavior in general.
Lastly, it is necessary to provide an appropriate processStimulus method that will
be invoked by the system when wakeup stimuli for the specified events or some logical
combinations of these have been received. Figure 6 shows a few line of codes in a process-
Stimulus method for getting mouse locations.
pIcktool
In many applications, the use of simple PickRay or PickConeRay is not satisfactory and
the specification of a more customized PickTool with a desired picking shape is needed
Figure 7. Constructor for PickTool and transforming 2D mouse to 3D virtual positions
1.
public PickingBehaviour( BranchGroup branch )
2.
{
3.
picktool = new PickTool( branch );
4.
picktool.setMode( PickTool.GEOMETRY );
Direction vector
5. }
6. ..
7. ..
8. ..
9. ..
10. ..
11. ..
12. ..
13. ..
14. ..
Mouse Coordinates
C
15. ..
16. ..
17.
x_m = ((MouseEvent)event[i]).getX();
18.
y_m = ((MouseEvent)event[i]).getY();
19.
20.
// transforming the 2D local coordinates to virtual world coordinates
21.
canvas.getPixelLocationInImagePlate( x_m, y_m, pt_m );
22.
canvas.getImagePlateToVworld( trans );
23.
trans.transform( pt_m );
24.
25.
// getting the direction for the picking shape
26.
canvas.getCenterEyeInImagePlate( start_pt );
27.
trans.transform( start_pt );
28.
pt_m.sub( start_pt );
29.
dirn.set( pt_m );
30.
dirn.normalize();
31.
32.
// picking shape set to be Ray
33.
picktool.setShapeRay( start_pt, dirn );
Search WWH ::




Custom Search