Java Reference
In-Depth Information
Figure 19. Fifth code segment for PickConeRayBehavior.java
30.
// get intersected object and process
31.
result = picktool.pickClosest();
32.
if( result != null )
33.
{
34.
picked_tg = (TransformGroup)result.getNode( PickResult.TRANSFORM_GROUP);
35.
lighting = (PointLight ) picked_tg.getChild( 1 );
36.
mouse_button = ((MouseEvent)event[i]).getButton();
37.
switch ( mouse_button )
38.
{
39.
case MouseEvent.BUTTON1: // left mouse button clicked
40.
if ( lighting.getEnable ( ) == false ) lighting.setEnable ( true );
41.
else lighting.setEnable ( false ); break;
42.
case MouseEvent.BUTTON2: // other mouse button clicked
43.
case MouseEvent.BUTTON3:
44.
if ( lighting.getEnable ( ) == true )
45.
{
46.
lighting.getColor( light_colour );
47.
if ( light_colour.equals( red ) ) lighting.setColor( white );
48.
else lighting.setColor( red );
49.
}; break;
50.
}
51.
}
52.
break;
53. …
With relationship similar to that between PickRaySegment and PickRay, PickConeRay-
Segment is also a variation of PickConeRay with an additional control on the length of the
cone ray that can be specified. Specifically, PickConeRay has rays within a conic volume
that is infinite in length, whereas the length of the cone in PickConeRaySegment can be
specified and finite. The usage of PickConeRaySegment is similar to that of PickConeRay,
although it may be more useful in applications for picking objects of different depths.
cylInder pIckInG shape
The use of conic picking shape is most appropriate for applications where a 3D prospec-
tive view is involved when rendering the virtual world. However, in scenarios where the
view or projection used is primarily or approximately parallel in nature, it may be more
useful to choose a picking shape that is cylindrical in nature for picking or interacting with
objects. The abstract base picking class for this purpose is PickCylinder with subclasses
PickCylinderRay and PickCylinderSegment. Both PickCylinderRay and PickCylinderSeg-
Search WWH ::




Custom Search