Graphics Reference
In-Depth Information
class
CModel {
Source file.
Model.h
file
in the
Model
folder of the
D3D
_
TranslateScaleObject
project.
.
// called by the slider bar event service routines
A:
void
SetTranslation(
float
x,
float
y);
// to update the m
_
Transate/m
_
Scale variables
void
SetScale(
float
x,
float
y);
private
:
.
// These are the
t
x
and
t
y
displacements
B:
float
m
_
TranslateX, m
_
TranslateY;
// These are the
s
x
and
s
y
scaling factors
float
m
_
ScaleX, m
_
ScaleY;
C:
UWB
_
PrimitiveRectangle m
_
Rectangle;
// The rectangle
};
Listing 9.1.
The
CModel
class of Tutorial 9.1.
void
CModel::DrawModel() {
Source file.
Model.cpp
file in the
Model
folder of the
D3D
_
TranslateScaleObject
project.
.
// the operators
A:
D3DXMATRIX
translate
_
matrix, scale
_
matrix, combined
_
matrix;
// compute
T
(
t
x
,
t
y
)
B:
D3DXMatrixTranslation(&translate
_
matrix, m
_
TranslateX, m
_
TranslateY, 0);
// compute
S
(
s
x
,
s
y
)
D3DXMatrixScaling( &scale
_
matrix, m
_
ScaleX, m
_
ScaleY, 1);
//
M
a
=
ST
C:
D3DXMatrixMultiply(&combined
_
matrix, &scale
_
matrix, &translate
_
matrix);
D:
LPDIRECT3DDEVICE9
pDevice=UWBD3D
_
GraphicsSystem::...GetD3DDevice();
//
M
W
←
ST
pDevice->SetTransform(D3DTS
_
WORLD, &combined
_
matrix);
E:
m
_
Rectangle.Draw(lod, m
_
DrawHelper);
.
}
Listing 9.2.
The
CModel::DrawModel()
function of Tutorial 9.1.
Search WWH ::
Custom Search