Graphics Reference
In-Depth Information
class
CModel {
public
:
.
A:
void
SetObjectColor(
const
UWB
_
Color& color);
void
SetCircleFillMode(
bool
filled);
B:
void
StartDefineGraphicsObject(
float
world
_
x,
float
world
_
y);
void
EndDefineGraphicsObject(
float
world
_
x,
float
world
_
y);
void
MoveGraphicsObject(
float
world
_
x,
float
world
_
y);
Source file.
Model.h
file
in the
Model
folder of the
D3D
_
ObjectsAndAttributes
project.
C:
void
DrawModel();
.
private
:
.
UWB
_
CircleGeometry m
_
Circle;
UWB
_
PointGeometry
D:
m
_
Point;
UWB
_
LineGeometry
m
_
Line;
UWBD3D
_
DrawHelper m
_
DrawHelper;
.
E:
};
Listing 7.5.
The
CModel
class (Tutorial 7.1).
Alternatively, if an
OGLDrawHelper
ispassedtothe
Draw()
function, then the
corresponding OpenGL drawing would occur.
LineGeometry
and
CircleGeome
try
have similar class structures, and the details are not shown here.
The
CModel
class.
With the functionality defined in
UWB
_
D3D
_
Lib4
,thecore
application state (or the
CModel
class) of Tutorial 7.1 can be defined. From
Listing 7.5, we can see that public interface of the model class includes (A)
methods for setting primitive attributes, (B) methods for interactively drawing
the primitives, and (C) drawing of the model. Privately, we see instances of
geometric primitives at label D, and the
D3DDrawHelp
object (
m
_
DrawHelper
)
that will support the drawing in D3D. The implementation of these methods is
shown in Listing 7.6. At label A, we see that the attribute-setting methods (e.g.,
SetObjectColor()
) are implemented by straightforward calling of public meth-
ods supported by the corresponding primitive type (e.g.,
m
_
Circle
's
SetColor()
method). At label B, we see that to properly support primitive editing, we must
determine the currently active primitive type and then set the vertex/geometric
properties accordingly.
Lastly at label C, we see that the D3D graphics API-
Search WWH ::
Custom Search