Graphics Reference
In-Depth Information
The vertices of the rectangle V i are transformed by
V i M W M V M P
=
V i TM w 2 n I 4
=
V i TM w 2 n .
Because the M w 2 n matrix is not changing, the translation effect we observed when
changing the slider bar is accomplished by the computed T translation operator
(or translate _ matrix ). This tutorial verifies that by properly computing and
loading the matrix processors before sending the vertices and the drawing com-
mands to the graphics API, we can indeed control the location of the rectangle.
Tutorial 8.2. Per-Primitive Translation
Tutorial 8.2.
Project Name:
D3D _ TranslateObjects
Library Support:
UWBGL _ MFC _ Lib1
UWBGL _ D3D _ Lib8
Goals. Further experiment with programming the matrix processors; more
specifically, we want to understand that the matrix processor can be changed
in between drawing commands.
Approach. Examine the drawing of two primitives, with and without user-
controlled transformations.
Figure 8.20 is a screenshot of running Tutorial 8.2. This tutorial is similar to the
previous one except that the user has the option of choosing to translate either
the circle or the rectangle by selecting the two radio control buttons located at
the lower left of the application window. We can verify that with the “Control
Rectangle” button selected, the circle remains at the origin, whereas the slider
bars control the location of the rectangle in exactly the same manner as in the
previous tutorial. If we activate the “Control Circle” button, we notice a swap
between the rectangle and the circle, where the rectangle jumps to and remains at
the lower-left origin and the slider bars control the location of the circle. Except
for the CModel class, the solution of this tutorial is identical to that of the previous
one.
From the described behaviors of this tutorial and from the tracing of the matrix
processors from the previous tutorial, we can derive that, in this case, when a
primitive (circle or rectangle) is under the slider translation control, its vertices V i
should be transformed by
Figure 8.20.
Tutorial
8.2.
M w 2 n ,
where t x and t y are the corresponding slider-bar values. The vertices of the primi-
tive that is not controlled by the slider bars should be transformed by
V i T
(
t x ,
t y )
V i M w 2 n .
 
Search WWH ::




Custom Search