Graphics Reference
In-Depth Information
compute the
M
1
operator, and at label E, the concatenated matrix at the top of the
stack is loaded into the
WORLD
processor for drawing of rectangle
R
1
.The
Pop()
operation at label C2 eliminates the
M
1
operator at the top of the matrix stack and
restores the
T
operator that was saved by the
Push()
operation at label C1.
The code at labels F and G computes
M
2
and draws
R
2
in a similar manner as that
for
M
1
and
R
1
.
This tutorial demonstrates using the matrix stack for saving/restoring shared
transform operators, and that we can load/override the matrix processor (e.g., the
WORLD
matrix processor) to change the transformations of different primitives.
(
t
x
,
t
y
)
UWBGL_D3D_Lib9
Change summary.
See p. 521
for a summary of changes to
the library.
This library extends from
Lib8
by extending the
D3D
_
DrawHelper
class to sup-
port the matrix stack and by designing the new
XformInfo
class to abstract the
programming of transformations.
The
D3D
_
DrawHelpler
class.
As shown in Listing 9.8, the updated implemen-
tation of
UWBD3D
_
DrawHelper
class has an instance of the D3D matrix stack (B)
and implements the transformation functions of the
DrawHelper
class (A). List-
ing 9.9 shows the implementation of the transformation functions. First, notice
that for all cases, before the functions return, we load the top of the matrix stack to
class
UWBD3D
_
DrawHelper :
public
UWB
_
DrawHelper {
Source file.
uwbgl
_
D3DDrawHelper3.h
file in the
D3D Files/
DrawHelper
subfolder of
the
UWBGL
_
D3D
_
Lib9
project.
.
A:
transformation functions defined by
UWB_DrawHelper
(the parent class)
bool
InitializeModelTransform();
bool
AccumulateModelTransform(
vec3
translation,
vec3
scale,
float
rotation
_
radians,
vec3
pivot);
bool
PushModelTransform();
bool
PopModelTransform();
private
:
.
B:
ID3DXMatrixStack
*
m
_
pMatrixStack;
};
Listing 9.8.
The
UWBD3D
_
DrawHelper
class (
Lib9
).
Search WWH ::
Custom Search