Graphics Reference
In-Depth Information
class
CModel {
.
Source file.
Model.h
file
in the
Model
folder of the
D3D
_
TranslateSingleObject
project.
// called by the slider bars service functions
A:
void
SetTranslation(
float
x,
float
y);
.
// to redraw the rectangle (and the grid)
void
DrawModel();
.
// the rectangle
B:
UWB
_
PrimitiveRectangle m
_
Rectangle;
// the x/y displacement from the GUI slider bars
C:
float
m
_
TranslateX, m
_
TranslateY;
};
private
:
CModel::CModel() : m
_
TranslateX(0), m
_
TranslateY(0) {
D:
m
_
Rectangle.SetCorners(
vec3
(0,0,0),
vec3
(2,3,0));
.
Listing 8.1.
The
CModel
class of Tutorial 8.1.
structure of this tutorial is similar to the ones we have worked with previously.
The
CTutorialDlg
class represents the application main window with the
Draw
OnlyHandler
implementing the draw-only functionality of the view/controller
pair UI drawing area. The model of this tutorial is straightforward. At label B in
Listing 8.1, we see that the model has a simple rectangle. The
SetTranslation()
function at label A is called by the event service routines for the GUI transla-
tion slider bars to set the model's representation for the translation at label C.
Label D shows that the rectangle is initialized with corners of
Figure 8.19.
Tutorial
8.1.
.
From interacting with the Tutorial 8.1 program, we verify that the rectangle is
indeed 2
(
0
,
0
)
and
(
2
,
3
)
×
3 in size, and with both slider bars set to 0, the rectangle does in-
deed appear at the lower-left corner of the drawing area. Before we examine the
CModel::DrawModel()
function, let us refresh our memory by examining the
matrix processors that we have programmed in all of our tutorials.
Initialization of the matrix processors.
Recall that during the
CTutorialDlg
initialization, in the
CTutorialDlg::OnInitDialog()
function, we call the
Search WWH ::
Custom Search