Graphics Reference
In-Depth Information
Left palm OC space. Transform V dc to the left palm's OC space by
M lp M la M b ) 1
V lp
=
V dc M d 2 w (
V dc M d 2 w M 1
b
M 1
la
M 1
lp
=
and use V lp (or pt lp ) for performing proximity tests with the vertices
pt lp =( x lp , y lp ) .
V lp = x lp y lp .
of C p 0 ,and R p 1 .
Notice that in order to correctly determine which component is closest to
the mouse-click position pt dc , we must perform the above computations for
every primitive in the scene hierarchy. In this case, we must also perform
the corresponding computations for the primitives of the right arm and right
palm.
The main advantage of this approach is that only the mouse-click position
needs to be transformed. The disadvantage is that the inverse transform of
every OC space must be computed.
2. Only transform primitive vertices . Leave the mouse-click position in DC
space and transform the primitive vertices of every component in the scene
hierarchy into the DC space for proximity tests. Notice that the transfor-
mation computation involved is similar to the drawing of primitives where
vertices are transformed from individual OC spaces into the DC space. The
OpenGL API takes advantage of this similarity and defines functionality to
approximate results of proximity tests based on drawing of primitives.
3. Transform both mouse-click position and primitive vertices. Transform
all positions to a convenient coordinate space for proximity tests. Recall
that when drawing primitives, our program computes and transforms ver-
tices to the NDC space. The graphics API is responsible for transforming
primitives from NDC to DC space. In this way, our program supports the
functionality of transforming vertices to NDC space but not to DC space. In
the absence of hardware-assisted proximity testing functionality, it is more
convenient to transform the mouse-click position into the NDC (or WC)
space and perform the proximity tests in the NDC (or WC) space.
X-pixels from
primitive
rectangle
p 1
Figure 11.20. A rect-
angle with boundaries not
aligned with the axis.
Proximity Tests
Once all primitive vertices and the mouse-click position are in the same coordi-
nate space, we must determine if the mouse-click position is sufficiently close to
any of the primitives for a successful selection. Notice that the mouse-click po-
sition can be represented as a point primitive, and in effect we are determining if
 
 
 
Search WWH ::




Custom Search