Public Member Functions | Static Public Member Functions | Properties

CC3NodeBoundingVolume Class Reference

Bounding volumes are used by CC3Nodes to determine whether a node interset the camera's frustum, or to determine boundaries for collision detection during physics simulation. More...

#import <CC3BoundingVolumes.h>

Inheritance diagram for CC3NodeBoundingVolume:
Inheritance graph
[legend]

List of all members.

Public Member Functions

(void) - buildVolume
(BOOL) - doesIntersectFrustum:
(void) - update

Static Public Member Functions

(id) + boundingVolume

Properties

GLfloat cameraDistanceProduct
CC3Vector centerOfGeometry
CC3Vector globalCenterOfGeometry
CC3Nodenode
BOOL volumeNeedsBuilding

Detailed Description

Bounding volumes are used by CC3Nodes to determine whether a node interset the camera's frustum, or to determine boundaries for collision detection during physics simulation.

Many different shapes of boundaries are available, including points, spheres, bounding boxes, etc, permitting tradeoffs between accuracy and computational processing time.

This base bounding volume is simply a single point. When applied to a node, it indicates that the node intersects the frustum if the node's center of geometry is within the frustum.

For meshes, the center of geometry is calculated from the vertex locations. For other nodes, it can be set directly within the bounding volume via the centerOfGeometry property.


Member Function Documentation

+ (id) boundingVolume

Allocates and initializes an autoreleased instance.

- (void) buildVolume

Template method that builds the bounding volume in the node's local coordinate system.

Default does nothing except set the volumeNeedsBuilding property to NO. Subclasses will override to calculated a real bounding volume, but should invoke this superclass method to set the volumeNeedsBuilding property to NO.

- (BOOL) doesIntersectFrustum: (CC3Frustum *)  aFrustum

Returns whether this bounding volume intersects the specfied frustum.

This default implementation always returns YES. Subclasses will override appropriately.

This method is invoked automatically by the node whenever it needs to determine whether or not it should be drawn.

- (void) update

Transforms this bounding volume to match the transformation of the node.

If this bounding volume has not yet been built, invokes the buildVolume method first.

This method is invoked automatically by the node whenever it recalculates its transformMatrix. Usually, the application never needs to invoke this method directly.


Property Documentation

- (GLfloat) cameraDistanceProduct [read, write, assign]

A measure of the distance from the camera to the centre of geometry of the node.

This is used to test the Z-order of this node to determine rendering order.

For nodes whose rendering order depends on distance to the camera (translucent nodes), this property is set automatically once the global location of the node and the camera are determined. The application will generally make no use of this property.

Do not use the value of this property as the true distance from the node to the camera. This measure is not the actual distance from the camera to the node, but it is related to that distance.

Different node sequencers may measure distance differently. If the node sequencer uses the true distance from the camera to the node, this property will be set to the square of that distance to avoid making the computationally expensive and unnecessary square-root calculation. In addition, some node sequencers may compare distance in one direction only, such as only in the forwardDirection of the camera, or only the Z-axis component of the distance.

- (CC3Vector) centerOfGeometry [read, write, assign]

The center of geometry for the node in the node's local coordinate system.

Defaults to {0, 0, 0}.

- (CC3Vector) globalCenterOfGeometry [read, assign]

The center of geometry for the node in the global coordinate system.

This is updated automatically by the transformVolume method of this bounding volume.

- (CC3Node *) node [read, write, assign]

The node whose boundary this instance is keeping track of.

- (BOOL) volumeNeedsBuilding [read, write, assign]

Indicates whether the volume needs building.

This is typically set to YES during instance initialization, and then to NO when the local bounding volume is calculated. This occurs the first time the update method is invoked. Usually, that is sufficient, and the application never needs to set this property. But, if for some reason it is determined that the bounding volume needs to be recalculated, this property can be reset back to YES, and the next invocation of the update method will rebuild the volume.


The documentation for this class was generated from the following file: