Graphics Reference
In-Depth Information
where
β
is half of vertical FOV,
α
is half of horizontal FOV,
and
) .
Equation (15.9) is the projection ray in EC space for the point
n is distance to near plane
(
n
z e ≤−
1
(
x dc ,
y dc )
in DC
0, all projection rays will intersect the origin. Re-
member that in EC space, the camera is located at the origin.
space. Notice that when z
=
EC-to-WC transform. Finally, we must transform the projection ray of Equa-
tion (15.9) to the WC space. A straightforward approach is to transform two
points on the projection ray from EC to WC. For example, we can choose z e =
0
and z e =
1 as two convenient points on the projection ray in EC space:
p e
=(
0
,
0
,
0
) ,
(15.10)
× x dc
× y dc
2
2
p e
=(
tan
( β )(
W dc
1
) ,
tan
( α )(
H dc
1
) , −
1
) .
The M e 2 w of Equation (14.6) will transform these two points to WC space: p wc
and p wc . Notice that p e is the camera position in EC, and thus p wc is the camera
position p e . Recall from Section 14.5.4 that the camera position is neatly encoded
in the fourth row of the M e 2 w matrix. This means that we can obtain the values
of p w simply by reading the first three elements of the fourth row of the M e 2 w
matrix. In this way,
transforms
←→
p e p e )
p w p w ) .
Projection ray in EC
(
Projection ray in WC
(
We can then intersect the WC projection ray with the geometries in WC space to
compute for intersections. Recall that the projection ray describes a line from the
camera position through the mouse position into the scene. We have transformed
this line from the DC coordinates, via NDC and EC, to the WC space. Any
objects that intersects this ray are objects that are underneath the mouse position.
When there is more than one object underneath a pixel, we must compute all the
intersections and keep the result that is closest to the camera position p w .
Tutorial 15.4.
Project Name:
D3D _ CameraInvXform
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib14
Tutorial 15.4. Mouse Click-to-World Transformation
Goal. Demonstrate the creation of a 3D projection ray in WC space based
on the 2D mouse-click position.
Approach. Implement the mathematics presented in Section 15.4 and vi-
sualize the WC projection ray with a separate camera.
Search WWH ::




Custom Search