Graphics Reference
In-Depth Information
class
CModel {
Source file.
Model.h
file
in the
Model
folder of the
D3D
_
PerPrimitiveTransform
project.
.
// Called by the slider bar event service routines
A:
void
SetTranslation(
float
x,
float
y);
// these functions set the corresponding
void
SetScale(
float
x,
float
y);
// transformation parameters defined below
void
SetRotation(
float
angle
_
radians );
private
:
.
// The rectangles on screen
B:
UWB
_
PrimitiveRectangle m
_
Rectangle1, m
_
Rectangle2;
// parameters for transformation:
(
t
x
,
t
y
)
float
m
_
TranslateX, m
_
TranslateY;
float
m
_
ScaleX, m
_
ScaleY, m
_
RotateAngleRadians;
//
C:
(
s
x
,
s
y
)
, and
θ
};
Listing 9.6.
The
CModel
class of Tutorial 9.5.
Source file.
Model.cpp
file in the
Model
folder of the
D3D
_
PerPrimitiveTransform
project.
void
CModel::DrawModel() {
.
A:
pMatrixStack->LoadIdentity();
pMatrixStack->Push();
pMatrixStack->TranslateLocal(m
_
TranslateX, m
_
TranslateY, 0.0f);
B:
C1:
pMatrixStack->Push();
vec3
pivot = m
_
Rectangle1.GetLocation();
D:
pMatrixStack->TranslateLocal(pivot.x, pivot.y, 0.0f);
pMatrixStack->ScaleLocal(m
_
ScaleX, m
_
ScaleY, 1.0f);
pMatrixStack->TranslateLocal(-pivot.x, -pivot.y, 0.0f);
pDevice->SetTransform( D3DTS
_
WORLD, pMatrixStack->GetTop() );
m
_
Rectangle1.Draw( lod, m
_
DrawHelper );
E:
C2:
pMatrixStack->Pop();
F1:
pMatrixStack->Push();
G:
// calls matrix stack translate/rotate functions
// loads the D3D WORLD matrix processor and draws m
_
Rectangle2
F2:
pMatrixStack->Pop();
.
Listing 9.7.
The
CModel::DrawModel()
function of Tutorial 9.5.
Search WWH ::
Custom Search