Inherits from CC3NodeBoundingVolume : CC3BoundingVolume : NSObject
Declared in CC3BoundingVolumes.h

Overview

A bounding volume that forms a sphere around a single point. When applied to a node, the center of the sphere is the node’s center of geometry, and this class indicates that the node intersects another bounding volume if any part of the sphere intersects that bounding volume.

The radius of the sphere must cover the node, and is scaled automatically to match the globalScale of the node. For meshes, the center of geometry and local radius are calculated from the vertex locations. For other nodes, the center of gravity and radius can be set directly within the bounding volume via their respective properties.

Properties

globalRadius

The radius that encompasses the extent of the node in the global coordinate system, as measured from the global center of geometry of this instance.

@property (nonatomic, readonly) GLfloat globalRadius

Declared In

CC3BoundingVolumes.h

globalSphere

Returns a sphere constructed from the globalCenterOfGeometry and the globalRadius properties.

@property (nonatomic, readonly) CC3Sphere globalSphere

Declared In

CC3BoundingVolumes.h

radius

The radius that encompasses the extent of the node in the node’s local coordinate system, as measured from the center of geometry of this instance.

@property (nonatomic, assign) GLfloat radius

Discussion

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.

Setting the value of this property sets the shouldBuildFromMesh property to NO, so that the radius will not be overridden if the vertices of the mesh change.

The initial value of this property is zero.

Declared In

CC3BoundingVolumes.h

sphere

Returns a sphere constructed from the centerOfGeometry and the radius properties.

@property (nonatomic, readonly) CC3Sphere sphere

Declared In

CC3BoundingVolumes.h

Class Methods

boundingVolumeFromSphere:

Allocates and initializes an autoreleased instance from the specified sphere, and sets the shouldBuildFromMesh property to NO.

+ (id)boundingVolumeFromSphere:(CC3Sphere)sphere

Discussion

The sphere dimensions are specified in the coordinate system of the node. The resulting bounding volume is fixed to the sizes provided, and will not take into consideration the vertices of the mesh. It will, however, transform along with the node, as the node is transformed.

Declared In

CC3BoundingVolumes.h

Instance Methods

doesIntersect:

Returns whether this bounding volume intersects the specfied other bounding volume.

- (BOOL)doesIntersect:(CC3BoundingVolume *)aBoundingVolume

Discussion

This implementation tests whether the globalSphere of this bounding volume intersects the other bounding volume, by double-dispatching to the doesIntersectSphere:from: method of the other bounding volume, passing this bounding volume’s globalSphere as the sphere to test, and passing this bounding volume as the otherBoundingVolume argument to that method.

Declared In

CC3BoundingVolumes.h

doesIntersectConvexHullOf:planes:from:

Returns whether a convex hull composed of the specified global planes intersects this bounding volume. The planes may be the face planes of a mesh, or they may be the sides of an oriented bounding box (OBB), or frustum, etc.

- (BOOL)doesIntersectConvexHullOf:(GLuint)numOtherPlanes planes:(CC3Plane *)otherPlanes from:(CC3BoundingVolume *)otherBoundingVolume

Discussion

Returns whether the globalSphere of this bounding volume intersects the convex hull defined by the specified planes. To be so, the globalCenterOfGeometry of this bounding volume must be no farther away than the globalRadius from the front face of every one of the specified planes.

This implementation ignores the otherBoundingVolume argument.

Declared In

CC3BoundingVolumes.h

doesIntersectLocation:

Returns whether the specified global location intersects (is inside) this bounding volume.

- (BOOL)doesIntersectLocation:(CC3Vector)aLocation

Discussion

Returns whether the specified location is contained within the globalSphere of this bounding volume.

Declared In

CC3BoundingVolumes.h

doesIntersectRay:

Returns whether the specified global-coordinate ray intersects this bounding volume.

- (BOOL)doesIntersectRay:(CC3Ray)aRay

Discussion

Returns whether the specified ray intersects the globalSphere of this bounding volume.

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

Declared In

CC3BoundingVolumes.h

doesIntersectSphere:from:

Returns whether the specified global-coordinate sphere intersects this bounding volume.

- (BOOL)doesIntersectSphere:(CC3Sphere)aSphere from:(CC3BoundingVolume *)otherBoundingVolume

Discussion

Returns whether the specified sphere intersects the globalSphere of this bounding volume.

This implementation ignores the otherBoundingVolume argument.

Declared In

CC3BoundingVolumes.h

initFromSphere:

Initializes this instance from the specified sphere, and sets the shouldBuildFromMesh property to NO.

- (id)initFromSphere:(CC3Sphere)sphere

Discussion

The sphere dimensions are specified in the coordinate system of the node. The resulting bounding volume is fixed to the sizes provided, and will not take into consideration the vertices of the mesh. It will, however, transform along with the node, as the node is transformed.

Declared In

CC3BoundingVolumes.h

isInFrontOfPlane:

Returns whether this bounding volume lies completely outside the specified normalized global coordinate plane.

- (BOOL)isInFrontOfPlane:(CC3Plane)aPlane

Discussion

This method returns YES if the bounding volume lies completely on the side of the plane from which the plane normal points. It returns NO if this bounding volume intersects the plane or lies completely on the opposite side of the plane.

Returns whether the globalCenterOfGeometry of this bounding volume is farther away than the globalRadius from the side of the plane from which the normal points.

Declared In

CC3BoundingVolumes.h