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

#import <CC3NodeVisitor.h>

Inheritance diagram for CC3NodePuncturingVisitor:
Inheritance graph
[legend]

Instance Methods

(CC3Vector- globalPunctureLocationAt:
 
(id) - initWithRay:
 
(CC3Node *) - puncturedNodeAt:
 
(CC3Vector- punctureLocationAt:
 
- Instance Methods inherited from CC3NodeVisitor
(CC3TextureUnit *) - currentTextureUnitAt:
 
(NSString *) - fullDescription
 
(CC3Light *) - lightAt:
 
(CC3LightProbe *) - lightProbeAt:
 
(void) - requestRemovalOf:
 
(BOOL) - visit:
 

Class Methods

(id) + visitorWithRay:
 
- Class Methods inherited from CC3NodeVisitor
(id) + visitor
 

Properties

CC3Vector closestGlobalPunctureLocation
 
CC3NodeclosestPuncturedNode
 
CC3Vector closestPunctureLocation
 
NSUInteger nodeCount
 
CC3Ray ray
 
BOOL shouldPunctureFromInside
 
BOOL shouldPunctureInvisibleNodes
 
- Properties inherited from CC3NodeVisitor
CC3Cameracamera
 
CC3MaterialcurrentMaterial
 
CC3MeshcurrentMesh
 
CC3MeshNodecurrentMeshNode
 
CC3NodecurrentNode
 
CC3ShaderProgramcurrentShaderProgram
 
CC3CameradefaultCamera
 
GLuint lightCount
 
GLuint lightProbeCount
 
CC3PerformanceStatisticsperformanceStatistics
 
CC3Scenescene
 
BOOL shouldVisitChildren
 
CC3NodestartingNode
 
GLuint textureCount
 

Detailed Description

CC3NodePuncturingVisitor is a CC3NodeVisitor that is used to collect nodes that are punctured (intersected) by a global ray.

For example, you can use the CC3Camera unprojectPoint: method to convert a 2D touch point into a CC3Ray that projects into the 3D scene from the center of the camera. All objects that lie visually below the touch point will be punctured by that projected ray.

Or, you may want to know which nodes lie under a targetting reticle, or have been hit by the path of a bullet.

To find the nodes that are punctured by a global CC3Ray, create an instance of this class, and invoke the visit: method on that instance, passing the CC3Scene as the argument. You can also invoke the visit: method with a particular structural node, instead of the full CC3Scene, to limit the range of nodes to inspect (for example, to determine which object in a room, but not outside the room, was hit by a bullet), for design or performance reasons.

The visitor will collect the nodes that are punctured by the ray, in order of distance from the startLocation of the CC3Ray. You can access the nodes and the puncture locations using the closestPuncturedNode, punctureNodeAt: closestPunctureLocation, and punctureLocationAt: methods.

Only nodes that have a bounding volume will be tested by this visitor. Nodes without a bounding volume, or whose shouldIgnoreRayIntersection property is set to YES will be ignored by this visitor.

The shouldPunctureFromInside property can be used to include or exclude nodes where the start location of the ray is within its bounding volume.

To save instantiating a CC3NodePuncturingVisitor each time, you can reuse the visitor instance over and over, through different invocations of the visit: method.

Method Documentation

- (CC3Vector) globalPunctureLocationAt: (NSUInteger)  index

Returns the location of the puncture on the node returned by the puncturedNodeAt: method.

The specified index must be between zero and nodeCount minus one, inclusive.

When multiple nodes are punctured by the ray, the location of the puncture on each can be accessed using the specified positional index, with the order determined by the distance from the startLocation of the ray to the global location of the puncture for each node. The index zero represents the node whose puncture is globally closest to the startLocation of the ray.

The returned location is on the bounding volume of the node (or tightest bounding volume if the node is using a composite bounding volume such as CC3NodeTighteningBoundingVolumeSequence), and is specified in the local coordinate system of the node.

The results will not include nodes that do not have a bounding volume, or whose shouldIgnoreRayIntersection property is set to YES.

- (id) initWithRay: (CC3Ray aRay

Initializes this instance with the specified ray, which is specified in the global coordinate system.

- (CC3Node*) puncturedNodeAt: (NSUInteger)  index

Returns the node punctured by the ray at the specified order index, which must be between zero and nodeCount minus one, inclusive.

When multiple nodes are punctured by the ray, they can be accessed using the specified positional index, with the order determined by the distance from the startLocation of the ray to the global location of the puncture for each node. The index zero represents the node whose puncture is globally closest to the startLocation of the ray.

The results will not include nodes that do not have a bounding volume, or whose shouldIgnoreRayIntersection property is set to YES.

- (CC3Vector) punctureLocationAt: (NSUInteger)  index

Returns the location of the puncture on the node returned by the puncturedNodeAt: method.

The specified index must be between zero and nodeCount minus one, inclusive.

When multiple nodes are punctured by the ray, the location of the puncture on each can be accessed using the specified positional index, with the order determined by the distance from the startLocation of the ray to the global location of the puncture for each node. The index zero represents the node whose puncture is globally closest to the startLocation of the ray.

The returned location is on the bounding volume of the node (or tightest bounding volume if the node is using a composite bounding volume such as CC3NodeTighteningBoundingVolumeSequence), and is specified in the local coordinate system of the node.

The results will not include nodes that do not have a bounding volume, or whose shouldIgnoreRayIntersection property is set to YES.

+ (id) visitorWithRay: (CC3Ray aRay

Allocates and initializes an autoreleased instance with the specified ray, which is specified in the global coordinate system.

Property Documentation

- (CC3Vector) closestGlobalPunctureLocation
readnonatomicassign

Returns the location of the puncture on the node returned by the closestPuncturedNode property, or kCC3VectorNull if the ray intersects no nodes.

The returned location is on the bounding volume of the node (or tightest bounding volume if the node is using a composite bounding volume such as CC3NodeTighteningBoundingVolumeSequence), and is specified in the global coordinate system.

- (CC3Node*) closestPuncturedNode
readnonatomicassign

Returns the node punctured by the ray that is closest to the startLocation of the ray, or nil if the ray intersects no nodes.

The result will not include any node that does not have a bounding volume, or whose shouldIgnoreRayIntersection property is set to YES.

- (CC3Vector) closestPunctureLocation
readnonatomicassign

Returns the location of the puncture on the node returned by the closestPuncturedNode property, or kCC3VectorNull if the ray intersects no nodes.

The returned location is on the bounding volume of the node (or tightest bounding volume if the node is using a composite bounding volume such as CC3NodeTighteningBoundingVolumeSequence), and is specified in the local coordinate system of the node.

The result will not include any node that does not have a bounding volume, or whose shouldIgnoreRayIntersection property is set to YES.

- (NSUInteger) nodeCount
readnonatomicassign

The number of nodes that were punctured by the ray.

- (CC3Ray) ray
readwritenonatomicassign

The ray that is to be traced, specified in the global coordinate system.

This property is set on initialization, but you may set it to another ray when reusing the same visitor on more than one visitation.

- (BOOL) shouldPunctureFromInside
readwritenonatomicassign

Indicates whether the visitor should consider the ray to intersect a node's bounding volume if the ray starts within the bounding volume of the node.

The initial value of this property is NO, indicating that the visitor will not collect punctures for any node where the ray starts within the bounding volume of that node.

This initial value makes sense for the common use of using the ray to pick nodes from a touch, as, when the camera is within a node, that node will not be visible. However, if you have a character within a room, and you want to know where in the room a thrown object hits the walls, you might want to set this property to YES to collect nodes that are punctured from the inside as well as from the outside.

- (BOOL) shouldPunctureInvisibleNodes
readwritenonatomicassign

Indicates whether the visitor should include those nodes that are not visible (whose visible property returns NO), when collecting the nodes whose bounding volumes are punctured by the ray.

The initial value of this property is NO, indicating that invisible nodes will be ignored by this visitor.


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