Graphics Reference
In-Depth Information
B:
for
(
int
i=0; i<count; i++)
UWB
_
Primitive
*
pTestPrimitive = m
_
AllPrimitives.PrimitiveAt(i);
const
UWB
_
BoundingVolume
*
pTestBV = pTestPrimitive->GetBoundingVolume(lod);
for
(
int
j=i+1; j<count; j++)
UWB
_
Primitive
*
pOtherPrimitive = m
_
AllPrimitives.PrimitiveAt(j);
const
UWB
_
BoundingVolume
*
pOtherBV = pOtherPrimitive->GetBoundingVolume(lod);
if
(pOtherBV && pTestBV->Intersects(
*
pOtherBV))
pTestPrimitive->CollisionResponse(pOtherPrimitive, pOtherBV->GetCenter());
pOtherPrimitive->CollisionResponse(pTestPrimitive, pTestBV->GetCenter());
C:
m
_
AllPrimitives.Update(elapsed
_
seconds);
.
Source file.
Model.cpp
file
in
the
Model
folder
of
the
D3D
_
ObjectCollections
project.
void
CModel::DrawModel()
m
_
AllPrimitives.Draw( lod, m
_
DrawHelper);
if
(m
_
bShowBoundingVolumes)
m
_
AllPrimitives.DrawChildBoundingVolumes(lod, &m
_
DrawHelper, color);
Listing 7.24.
(cont.)
Tutorial 7.5.
Project Name:
D3D
_
BallShoot2
Library Support:
UWBGL
_
MFC
_
Lib1
UWBGL
_
D3D
_
Lib7
Tutorial 7.5. Re-implementing the Ball-Shooting Program
Figure 7.13 is a screenshot of running Tutorial 7.5. This tutorial re-implements
the ball-shooting program based on the new library (
UWB
_
D3D
_
Lib7
). We modify
Tutorial 7.4 such that the GUI front end resembles that of the ball-shooting pro-
gram, and in this case we only support the creation of the
CBall
(a subclass of
PrimitiveCircle
) primitive type. The
CModel
of the source code is very simi-
lar to Tutorial 7.4. When comparing the core implementation of our application
state (
CModel
) to that from Tutorial 5.6, we see a more general solution (we can
support shooting/colliding of any primitives) with fewer details (all collisions and
mathematics are hidden in class implementations).
Figure 7.13.
Tutorial
7.5.
Search WWH ::
Custom Search