Public Member Functions | Properties

CC3NodeBoundingVolume Class Reference

CC3NodeBoundingVolumes are used by CC3Nodes to determine whether a node intersets another bounding volume, including 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]
Collaboration diagram for CC3NodeBoundingVolume:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(BOOL) - doesIntersectFrustum:
(CC3Vector- locationOfRayIntesection:
(void) - markTransformDirty

Properties

GLfloat cameraDistanceProduct
CC3Vector centerOfGeometry
CC3Vector globalCenterOfGeometry
BOOL isTransformDirty: 1
CC3Nodenode
BOOL shouldDraw: 1
BOOL shouldMaximize: 1

Detailed Description

CC3NodeBoundingVolumes are used by CC3Nodes to determine whether a node intersets another bounding volume, including 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 another bounding volume if the node's center of geometry is within that bounding volume.

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


Member Function Documentation

- (BOOL) doesIntersectFrustum: (CC3Frustum *)  DEPRECATED_ATTRIBUTE
Deprecated:
Replaced by the more general doesIntersect: method.
- (CC3Vector) locationOfRayIntesection: (CC3Ray localRay

Returns the location at which the specified ray intersects this bounding volume or returns kCC3VectorNull if the ray does not intersect this bounding volume.

The result honours the startLocation of the ray, and will return kCC3VectorNull if this bounding volume is "behind" the startLocation, even if the line projecting back through the startLocation in the negative direction of the ray intersects this bounding volume.

The ray may start inside this bounding volume, in which case, the returned location represents the exit location of the ray.

Both the input ray and the returned location are specified in the local coordinate system of the node holding this bounding volume. A valid non-null result can therefore be used to place other nodes at the intersection location, by simply adding them to the node at the returned location.

The returned result can be tested for null using the CC3VectorIsNull function.

The operation of this method is affected by the shouldIgnoreRayIntersection property. If that property is set to YES, this method will always return kCC3VectorNull. See the notes of the shouldIgnoreRayIntersection property for more info.

When using this method, keep in mind that the returned intersection location is located on the surface of the bounding volume, not on the surface of the node. Depending on the shape of the surface of the node, the returned location may visually appear to be at a different location than where you expect to see it on the surface of on the node.

- (void) markTransformDirty

Marks that this volume requires being transformed.

This is different than the markDirty method. That method indicates that the underlying structure of the bounding volume needs to be rebuilt. This method indicates that the underlying structure may not have changed, but it requires being transformed to match a change in the node's transform properties.

The node containing this bounding volume should invoke this method whenever the transform matrix of that node has changed.

After this method has been invoked, the transformation is automatically carried out lazily when the bounding volume is tested against another bounding volume, or when a property that depends on the transformation is accessed.

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.

For mesh nodes, the value of this property is automatically calculated from the vertex locations, via specialized subclasses of CC3NodeBoundingVolume used for meshes. For other nodes, this property can be set directly, if needed.

You can also set this property directly for mesh nodes as well. Doing so will override the value that was calculated automatically. This can be useful when the vertices will be changing frequently, and therefore the bounding volume will need to be recalculated frequently. By setting this property to a value that suits all possible vertex configurations, you can avoid expensive recalculations of the bounding volume as the vertices change.

When setting the value of this property on a mesh node directly, be sure to also set the shouldUseFixedBoundingVolume property of the node to YES, to stop automatic recalculation of this bounding volume whenever the underlying mesh vertices change.

The initial value of this property is kCC3VectorZero.

- (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.

- (BOOL) isTransformDirty [read, assign]

Indicates whether this volume needs to be transformed.

This is different than the isDirty property, and is an indication that the node has been transformed and therefore the bounding volume of the node needs to be transformed as well.

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

The node whose boundary this instance is keeping track of.

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

Indicates that this bounding volume should draw itself over the node.

This property can be useful during development to verify the extent of the bounding volume.

Setting this property to YES will add a translucent child mesh node, of an appropriate shape, to the node whose bounding volume this is.

Implemented in CC3NodeInfiniteBoundingVolume, and CC3NodeNullBoundingVolume.

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

If the value of this property is set to YES, the boundary of this volume will only ever expand when this bounding volume is repeatedly rebuilt from the underlying mesh vertex data.

The shape of the boundary depends on the subclass. Whenever this bounding volume is rebuilt, the resulting boundary is compared to the previous boundary, and replaces the previous boundary only if it is larger.

Rebuilding occurs whenever the node marks the bounding volume as dirty using the markDirty method. The bounding volume is rebuilt lazily and automatically when the bounding volume is tested against another bounding volume, or when a property that depends on the rebuilding is accessed.

Setting this property to YES and the shouldUseFixedBoundingVolume of the node to NO can be useful when pre-computing an appropriate fixed boundary for a node whose vertex location data frequently changes, such as a particle generator, and is often used at development time.

Once the resulting maximized boundary is determined, it can then be explicitly set into this bounding volume at run time, and the shouldUseFixedBoundingVolume of the node can be set to YES so that the processing cost of constantly rebuilding this bounding volume will not be incurred.

If a dynamic boundary is required at runtime, set both the shouldUseFixedBoundingVolume of the node and this property to NO. With a dynamic boundary, setting this property to YES has no advantage. The performance cost will be the same, and the resulting boundary will be less accurate.

The initial value of this property is NO.


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