v2.0.2
Instance Methods | Properties | List of all members
CC3NodeBoundingVolume Class Reference

#import <CC3BoundingVolumes.h>

Inheritance diagram for CC3NodeBoundingVolume:
Inheritance graph
[legend]

Instance Methods

(CCColorRef- displayNodeColor
 
(CCOpacity- displayNodeOpacity
 
(BOOL) - doesIntersectFrustum:
 
(CC3Vector- locationOfRayIntesection:
 
(void) - markTransformDirty
 
(void) - scaleBy:
 
- Instance Methods inherited from CC3BoundingVolume
(BOOL) - doesIntersect:
 
(BOOL) - doesIntersectConvexHullOf:planes:
 
(BOOL) - doesIntersectConvexHullOf:planes:from:
 
(BOOL) - doesIntersectLocation:
 
(BOOL) - doesIntersectRay:
 
(BOOL) - doesIntersectSphere:
 
(BOOL) - doesIntersectSphere:from:
 
(NSString *) - fullDescription
 
(CC3Vector- globalLocationOfGlobalRayIntesection:
 
(BOOL) - isInFrontOfPlane:
 
(void) - markDirty
 
(void) - populateFrom:
 

Properties

CC3Vector centerOfGeometry
 
CC3Vector globalCenterOfGeometry
 
BOOL isTransformDirty
 
CC3Nodenode
 
BOOL shouldBuildFromMesh
 
BOOL shouldDraw
 
BOOL shouldMaximize
 
- Properties inherited from CC3BoundingVolume
BOOL isDirty
 
GLuint planeCount
 
CC3Planeplanes
 
BOOL shouldIgnoreRayIntersection
 
BOOL shouldLogIntersectionMisses
 
BOOL shouldLogIntersections
 
GLuint vertexCount
 
CC3Vectorvertices
 

Additional Inherited Members

- Class Methods inherited from CC3BoundingVolume
(id) + boundingVolume
 

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 is an abstract class that tracks the center of geometry of the node. Subclasses are provided to reflect specific shapes around the node and to perform suitable intersection tests.

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.

In most cases, each node has its own bounding volume. However, when using bounding volumes with skin mesh nodes whose vertices are influenced by separate bone nodes, it often makes sense to share the bounding volume between one of the primary skeleton bones and the skin mesh nodes, so that the bone can control the movement and shape of the bounding volume, and the skin node can use that same bounding volume to determine whether its vertices are intersecting another bounding volume, including the camera frustum.

You employ this technique by assigning the bounding volume to the bone first, using the boundingVolume property of the skeleton bone node, and then assigning the same bounding volume to all skin nodes affected by that skeleton, using the setSkeletalBoundingVolume: method on a common ancestor node of all the affected skin mesh nodes.

Method Documentation

- (CCColorRef) displayNodeColor

The color used when this bounding volume is displayed.

- (CCOpacity) displayNodeOpacity

The opacity used when this bounding volume is displayed.

- (BOOL) doesIntersectFrustum: (CC3Frustum *)  __deprecated
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.

- (void) scaleBy: (GLfloat)  scale

Scales the size of this bounding volume by the specified amount, relative to its current size.

This method also sets the shouldBuildFromMesh property to NO so that the size of this bounding volume will not change if the underlying mesh vertices change.

Property Documentation

- (CC3Vector) centerOfGeometry
readwritenonatomicassign

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.

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

The initial value of this property is kCC3VectorZero.

- (CC3Vector) globalCenterOfGeometry
readnonatomicassign

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
readnonatomicassign

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
readwritenonatomicassign

The node whose boundary this instance is keeping track of.

- (BOOL) shouldBuildFromMesh
readwritenonatomicassign

Indicates whether this instance should build its bounds from the vertex locations within the mesh held by this bounding volume's node.

The node must be a CC3MeshNode for this property to be set to YES.

The initial value of this property will be NO if this bounding volume was created with specific dimensions, or if the node is not a type of CC3MeshNode. Otherwise, the initial value of this property will be YES.

- (BOOL) shouldDraw
readwritenonatomicassign

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.

- (BOOL) shouldMaximize
readwritenonatomicassign

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: