Graphics Reference
In-Depth Information
Collision primitive. Using spherical bound (circular bound in 2D) to ap-
proximate collision is efficient.
Collision computation. For objects traveling at high speed, we should
intersect the line segment(s) defined by the corresponding velocities.
The source code of the implementation can be found in the HitTrophy() func-
tion of the Trophy _ Hit.cpp file in the Model folder of the D3D _ CollisionIn3D
project. The details of line-sphere intersection are described in Appendix B.
16.7 Selection in 3D
Mouse-click selection of scene nodes in 3D involves identical issues as discussed
in Section 15.4. In both cases, we must construct a 3D ray based on a 2D mouse-
click position.
Tutorial 16.9.
Project Name:
D3D _ SelectionIn3D
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib17
Tutorial 16.9. Mouse-click selection of a scene node.
Goal. Demonstrate that we can support the point-and-click metaphor in
selecting objects in 3D space.
Approach. Implement mouse-click selection with a simple scene hierar-
chy.
Figure 16.20 is a screenshot of running Tutorial 16.9. Click on the “Show Colli-
sion Sphere” checkbox to display the spherical wire-frame bound. Now, with the
shift key depressed, the left mouse button will generate a selection ray, a line seg-
ment from the camera position, through the mouse-click position into the world.
In this tutorial, the selection ray is intersected with the wire-frame bound. Notice
that we can use the exact same line-sphere intersection routine to detect selection!
Notice that in this case, we compute and report the results of intersection between
the line and the spherical bound without considering other objects in the scene.
For example, rotate (tumble) the camera position such that the floor occludes the
trophy scene hierarchy. Now invoke the selection ray (by depressing the shift key
and LMB) and drag the mouse around the screen area where the shusui plane is
behind the floor. Because we are only intersecting the ray and the spherical bound,
our program will report a successful collision even though the floor occludes the
object!
Figure 16.20.
Tutorial
16.9.
 
Search WWH ::




Custom Search