Java Reference
In-Depth Information
mouse, while clicking the mouse will have no effect. Also, a CylinderRay pick shape that
propagates towards the negative z-axis infinitely is selected for picking the object.
pIckInG obJects WIthIn a specIfIed bound from a
certaIn posItIon
Instead of picking objects using a standard pick shape and finding intersection of the
shape with visual objects, it may sometimes be more convenient to pick objects within
some specified bounds from a certain position. The position and the bound can of course
be updated dynamically depending on changes in the viewpoint of the user or as the user
navigates within the 3D virtual world using, say, the mouse. The underlying class for
implementation in this approach is PickBound, where only the shape and the position of
the bound are important.
The next few figures illustrate a simple example using PickBound in an application
where the colors of some spherical objects as shown in Figure 22 can be changed by using
the mouse. Figure 23 shows the code segment for the creation of the six spherical objects
at different locations. Note that spheres 3 and 6 are green in color and are closer to the
screen while the others are positioned in two different clusters.
Clicking the mouse near the two cluster groups will create an appropriate picking bound
at a 3D coordinate associated with the current mouse position and will result in the picking
of all the spheres enveloped by the specified bound. Subsequently, the coloring attributes of
the picked spheres will be changed, resulting in a change in the visual color of the objects.
Note, however, that since the program is such that the green spheres are quite far away
from the bound, they will not be picked.
Figure 22. Result from
Original scene
Right hand cluster
Left hand cluster
Search WWH ::

Custom Search