Graphics Reference
In-Depth Information
see a direct mapping to public methods defined by the
Primitive
hierarchy. We
observe the capability of a carefully designed object-oriented hierarchy where,
based on the mouse-click-drag metaphor, we have designed two interface func-
tions. Here we see that with the same two-function interface, we can create/edit
three different types of primitives. At labels D and E are update and draw func-
tions. It is expected that these two functions should be called more than real-time
thresholds in each second (e.g., more than 20 times). In this case, at labels D1 and
E1, we call the corresponding functions for the three primitives to accomplish the
display of smooth motion.
Source files.
Model.h/cpp
files in the
Model
folder of the
D3D
_
ObjectClasses
project.
class
CModel {
A:
void
SetCurrentTypeToPoint();
void
SetCurrentTypeToLine();
.
B:
void
SetShadeMode( eShadeMode mode );
eShadeMode GetShadeMode();
.
C:
void
StartDefineGraphicsObject(
float
world
_
x,
float
world
_
y);
void
EndDefineGraphicsObject(
float
world
_
x,
float
world
_
y);
void
MoveGraphicsObject(
float
world
_
x,
float
world
_
y);
D:
void
UpdateSimulation();
E:
void
DrawModel();
private
:
F:
float
m
_
WorldWidth, m
_
WorldHeight;
// size of the world
UWB
_
Clock m
_
stop
_
watch;
// wall-clock elapses in between updates
UWBD3D
_
DrawHelper m
_
DrawHelper;
// helper for D3D drawing
UWB
_
Primitive
*
m
_
pCurrentObject;
// pointer to primitive currently being edited
UWB
_
PrimitiveCircle m
_
Circle;
// instance of circle
UWB
_
PrimitivePoint m
_
Point;
//
line and
UWB
_
PrimitiveLine m
_
Line;
//
point
};
Listing 7.13.
The
CModel
class of Tutorial 7.2.
Search WWH ::
Custom Search