Graphics Reference
In-Depth Information
(c) We can now invoke
UWB
_
EchoToStatusArea()
to echo the status of
our application from anywhere in our application to the
IDC
_
STATUS
area.
Tutorial 5.3. Effects of Real-Time Simulation
Tutorial 5.3.
Project Name:
D3D
_
SimulateGravity
Library Support:
UWBGL
_
MFC
_
Lib1
UWBGL
_
D3D
_
Lib2
•
Goals.
Demonstrate working with real-time changes to the model in our
development framework.
•
Approach.
Continue working with Tutorial 5.2; we will simulate how the
created circle may drop under gravitational force. Because this is a simple
example with a simple model, it is straightforward to focus on the increased
complexity of the model component and the process of simulating real-time
events in our development environment.
•
Application specification.
The application reacts to mouse events in a sim-
ilar manner to that of Tutorial 5.2. In addition, when all mouse buttons are
released, the defined circle will free fall toward the bottom of the appli-
cation window. Our application must detect the situation when the circle
drops outside of the window and stop any further computations.
Figure 5.8 is a screenshot of the free-falling circle from Tutorial 5.3.
Figure 5.8.
Tutorial 5.3.
Model
Our application is now about creating a circle that
moves
.Wedefinea
CBall
to
be a circle with a velocity. Notice that a
CBall
object understands if it is within a
rectangular width
height bound. Our application model contains a
CBall
object
(instead of the
CircleGeometry
in Tutorial 5.2). In addition, anticipating support
for the ball-shooting program, we name our interface functions accordingly.
×
class
CBall :
public
UWBD3D
_
CircleGeometry {
Source
file.
Ball.h
file
in
the
Model
folder
of
the
public
:
.
vec3
GetVelocity()
const
;
void
SetVelocity(
const vec3
& velocity);
bool
IsOutsideBounds(width, height)
const
;
// in/out side a bound defined by: width by height
private
:
vec3
m
_
velocity;
D3D
_
SimulateGravity
project.
}
Listing 5.16.
The
CBall
class (Tutorial 5.3).
Search WWH ::
Custom Search