Graphics Reference
In-Depth Information
class CModel {
Source file. Model.h file
in the Model folder of the
D3D _ SceneNodeCollision
project.
// ... similar to that of Tutorial 11.7
// pointers to the left/right palm scene nodes
A: UWB _ SceneNode * m _ pLeftPalmNode, * m _ pRightPalmNode;
// all the bullets in the world
B: UWB _ PrimitiveList * m _ bullets;
}
Listing 11.19. The CModel class of Tutorial 11.8.
void CModel::UpdateSimulation() {
UWB _ BoundingBox left _ palm _ bounds, right _ palm _ bounds; // variables for WC bboxes
m _ DrawHelper.InitializeModelTransform(); // initialize for OC-WC transformation
// WC bbox of left palm scene node
A:
m _ Body.GetNodeBounds(m _ pLeftPalmNode, left _ palm _ bounds ...)
// WC bbox of right palm scene node
m _ Body.GetNodeBounds(m _ pRightPalmNode,right _ palm _ bounds ...)
B:
for ( every primitive in the m _ bullet list )
// pTestPrimitive is current bullet
C:
UWB _ Primitive * pTestPrimitive = m _ bullets.PrimitiveAt(i);
const UWB _ BoundingVolume * pVolume = pTestPrimitive->GetBoundingVolume();
// left palm collides current bullet
C1:
if (left _ palm _ bounds.Intersects( * pVolume))
pTestPrimitive->CollisionResponse( ... ); // current bullet should bounce away
m _ hit _ count++; // increment the on screen hitCount
C2:
C3:
// Test right palm node for intersection and perform similar
// operations to that of Left Palm
.
Source file.
Model _ Simulation.cpp file
in the Model folder of the
D3D _ SceneNodeCollision
project.
// Create new bullets about every 0.5 seconds
if (m _ second _ counter > 0.5f) CreateNewBullet();
D:
E:
// destroy all bullets that are outside the world
}
Listing 11.20. The CModel::UpdateSimulation() function of Tutorial 11.8.
difference of the CModel class from that of Tutorial 11.7. In this tutorial, during
the creation of the human model hierarchy, the references to the left and right
palm scene nodes are kept in the m _ pLeftPalmNode and m _ pRightPalmNode
variables (at label A of Listing 11.19). These two pointers are used to compute
WC bounding boxes for collision detections. The m _ bullets primitive list at la-
Search WWH ::




Custom Search