Game Development Reference
In-Depth Information
Although we will discuss framebuffers in the Rendering offscreen using framebuffers
section, we will not implement picking using the preceding technique in this topic.
Picking using ray casting
We have discussed ray casting in the previous section, Understanding the basic ray
casting concepts . In that section, we discussed that a ray was generated from a player's
position and direction to detect any object's intersection. Now, let's replace the
player position with screen coordinates where the mouse was clicked and derive the
direction from the camera direction (also called the eye vector). Hence, picking using
ray casting is implemented by casting a ray from the camera's position and direction
into the scene—the objects intersected by the ray are the user selected objects. This is
shown in the following diagram:
Object
Screen
Eye
Ray
Let's understand the power of this technique. Using this technique, we can select
objects up to any level of detail, but there is always a tradeoff in precision versus
performance. So, let's understand the possibilities:
For jigLib.JBox colliders, if a scene object is associated with the JBox or
JSphere collider, then you will only be able to select a complete object. The
Jbox , JSphere , and JCapsule colliders are also known as bounding box
colliders. They are the fastest colliders. They have minimum computation
load as the exact shape of the 3D object is not considered but a simple
geometry is checked against the intersection. We have already associated
these colliders with our scene objects in Chapter 7 , Physics and Terrains .
 
Search WWH ::




Custom Search