Graphics Reference
In-Depth Information
Approach. Collide the left and right palm scene nodes of Figure 11.13 with
different types of primitives.
Figure 11.23 is a screenshot of running Tutorial 11.8. On the lower side of the
drawing area is the human model hierarchy of Figure 11.14. As in previous tuto-
rials, the user can select and manipulate the transformation operators of any node
in this hierarchy. Recall that in this hierarchy, the palm nodes are located at the
end of the corresponding arms. UWB _ Primitive objects that we will refer to as
bullets are generated at the top of the drawing area and dropped vertically towards
the human model. This tutorial counts the number of times the bullets collide with
the left and right palm scene nodes. When a collision is detected, the bullet object
reacts by bouncing away from the colliding palm scene node.
This tutorial implements two types of bullets: balls and arms. A ball bul-
let is a simple circle primitive, whereas an arm-bullet is a CPrimitiveArm ob-
ject. Listing 11.18 shows that CPrimitiveArm is a subclass of UWB _ Primitive .
This object wraps over an instance of the CArm scene node object (as defined in
Listing 11.7 on p. 306). The Update() function at label A moves/rotates the
CPrimitiveArm object by modifying the CArmXformInfo object; the GetBound
ingVolume() function at label B calls SceneNode::GetNodeBounds() to com-
pute the WC bounding box, whereas the DrawPrimitive() function at label C
draws the CArm object. In this way, from the public interface, CPrimitiveArm
behaves exactly like a UWB _ Primitive object. Listing 11.19 highlights the main
Figure 11.23.
Tutorial
11.8.
class CPrimitiveArm : public UWB _ Primitive {
Source file.
PrimitiveArm.h/cpp file
in the Model folder of the
D3D _ SceneNodeCollision
project.
public :
.
// periodic update of primitive
A: virtual void Update( float elapsed _ seconds);
// Compute WC bbox
B: virtual const UWB _ BoundingVolume * GetBoundingVolume( ... )
protected :
// draw the CArm scene node
C: virtual void DrawPrimitive( ... );
// Scene node as defined in Listing 11.7 for storing the WC bbox
D: CArm m _ Arm;
UWB _ BoundingBox m _ Bound;
};
Listing 11.18. The CPrimitiveArm class of Tutorial 11.8.
 
Search WWH ::




Custom Search