Graphics Reference
In-Depth Information
class
CBall :
public
UWB
_
PrimitiveCircle
A:
virtual void
MoveTo(
float
,
float
);
virtual void
MouseDownVertex(
int
,
float
,
float
);
virtual vec3
GetLocation()
const
;
virtual void
Update(
float
elapsed
_
seconds);
protected
:
B:
virtual void
DrawPrimitive(eLevelOfDetail lod,
UWB
_
DrawHelper& draw
_
helper)
const
;
private
:
C:
UWB
_
XformInfo
m
_
Xform
;
D:
CBall::CBall() {
SetCenter(
vec3
(0, 0, 0));
SetRadius(1.0f); }
vec3
CBall::GetLocation()
const
{
return m
_
Xform
.GetTranslation();}
void
CBall::MoveTo(
float
x,
float
y)
{
m
_
Xform
.SetTranslation(
vec3
(x, y, 0.0f));}
void
CBall::MouseDownVertex(
int
id,
float
x,
float
y)
A1:
Source
file.
CBall.h
file
in
the
Model
folder
of
the
.
vec3
center =
m
_
Xform
.GetTranslation();
vec3
pt(x, y, 0.0f);
m
_
Xform
.SetScale(length(center-pt));
.
void
CBall::Update(
float
elapsed
_
seconds)
.
vec3
displacement = elapsed
_
seconds
*
GetVelocity();
m
_
Xform
.SetTranslation(
m
_
Xform
.GetTranslation() + displacement);
.
D3D
_
BallShoot3
project.
.
B1:
void
CBall::DrawPrimitive(eLevelOfDetail lod,
UWB
_
DrawHelper& draw
_
helper)
const
draw
_
helper.PushModelTransform();
draw
_
helper.InitializeModelTransform();
m
_
Xform
.SetUpModelStack(draw
_
helper);
// sets up matrix stack
__
super::DrawPrimitive(lod, draw
_
helper);
//
circle
's draw function
draw
_
helper.PopModelTransform();
Listing 9.13.
The
CBall
class of Tutorial 9.8.
Search WWH ::
Custom Search