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

#import <CC3NodeVisitor.h>

Inheritance diagram for CC3NodeVisitor:
Inheritance graph
[legend]

Instance Methods

(CC3TextureUnit *) - currentTextureUnitAt:
 
(NSString *) - fullDescription
 
(CC3Light *) - lightAt:
 
(CC3LightProbe *) - lightProbeAt:
 
(void) - requestRemovalOf:
 
(BOOL) - visit:
 

Class Methods

(id) + visitor
 

Properties

CC3Cameracamera
 
CC3MaterialcurrentMaterial
 
CC3MeshcurrentMesh
 
CC3MeshNodecurrentMeshNode
 
CC3NodecurrentNode
 
CC3ShaderProgramcurrentShaderProgram
 
CC3CameradefaultCamera
 
GLuint lightCount
 
GLuint lightProbeCount
 
CC3PerformanceStatisticsperformanceStatistics
 
CC3Scenescene
 
BOOL shouldVisitChildren
 
CC3NodestartingNode
 
GLuint textureCount
 

Detailed Description

A CC3NodeVisitor is a context object that is passed to a node when it is visited during a traversal of the node hierarchy.

To initiate a visitation run, invoke the visit: method on any CC3Node.

Subclasses will override template methods to customize the behaviour prior to, during, and after the node traversal.

If a node is to be removed from the node structural hierarchy during a visitation run, the requestRemovalOf: method can be used instead of directly invoking the remove method on the node itself. A visitation run involves iterating through collections of child nodes, and removing a node during the iteration of a collection raises an error.

Method Documentation

- (CC3TextureUnit*) currentTextureUnitAt: (GLuint)  texUnit

Returns the texture unit at the specified index from the mesh node that is currently being visited, or returns nil if the material covering the node has no corresponding texture unit.

It is up to the invoker to make sure that the current node actually is a CC3MeshNode.

The value returned by this method is only valid during the traversal of the node returned by the currentMeshNode property, and will be nil both before and after the visit: method is invoked on that node.

- (NSString*) fullDescription

Returns a more detailed description of this instance.

- (CC3Light*) lightAt: (GLuint)  index

Returns the light indicated by the index, or nil if the specified index is greater than the number of lights currently existing in the scene.

The specified index is an index into the lights array of the scene, and is not necessarily the same as the lightIndex property of the CC3Light.

- (CC3LightProbe*) lightProbeAt: (GLuint)  index

Returns the light probe indicated by the index, or nil if the specified index is greater than the number of light probes currently existing in the scene.

The specified index is an index into the lightProbes array of the scene.

- (void) requestRemovalOf: (CC3Node *)  aNode

Requests the removal of the specfied node.

During a visitation run, to remove a node from the hierarchy, you must use this method instead of directly invoking the remove method on the node itself. Visitation involves iterating through collections of child nodes, and removing a node during the iteration of a collection raises an error.

This method can safely be invoked while a node is being visited. The visitor keeps track of the requests, and safely removes all requested nodes as part of the close method, once the visitation of the full node assembly is finished.

- (BOOL) visit: (CC3Node *)  aNode

Visits the specified node, then if the shouldVisitChildren property is set to YES, invokes this visit: method on each child node as well.

Returns whether the visitation run was stopped once a desired result was accomplished. Depending on the type of visitation, this might occur if a particular node was reached, or some other desired result has been accomplished. The purpose of the returned value is not to indicate whether all node have been visited, or even that the visitation was aborted. Instead, you should think of the returned value as a way of indicating that a desired result has been accomplished, and that there is no need to visit further nodes. For visitations that normally visit all nodes, such as drawing, or updating, the return value will generally be NO.

Subclasses will override several template methods to customize node visitation behaviour.

+ (id) visitor

Allocates and initializes an autoreleased instance.

Property Documentation

- (CC3Camera*) camera
readwritenonatomicretain

The camera that is viewing the 3D scene.

If this property is not set in advance, it is lazily initialized to the value of the defaultCamera property when first accessed during a visitation run.

The value of this property is not cleared at the end of the visitation run.

- (CC3Material*) currentMaterial
readnonatomicassign

Returns the material of the mesh node that is currently being visited, or returns nil if that mesh node has no material.

It is up to the invoker to make sure that the current node actually is a CC3MeshNode.

This property is only valid during the traversal of the node returned by the currentMeshNode property, and will be nil both before and after the visit: method is invoked on that node.

- (CC3Mesh*) currentMesh
readnonatomicassign

Returns the mesh of the mesh node that is currently being visited.

It is up to the invoker to make sure that the current node actually is a CC3MeshNode.

This property is only valid during the traversal of the node returned by this property, and will be nil both before and after the visit: method is invoked on the node.

- (CC3MeshNode*) currentMeshNode
readnonatomicassign

Returns the mesh node that is currently being visited.

This is a convenience property that returns the value of the currentNode property, cast as a CC3MeshNode. It is up to the invoker to make sure that the current node actually is a CC3MeshNode.

This property is only valid during the traversal of the node returned by this property, and will be nil both before and after the visit: method is invoked on that node.

- (CC3Node*) currentNode
readnonatomicassign

The CC3Node that is currently being visited.

This property is only valid during the traversal of the node returned by this property, and will be nil both before and after the visit: method is invoked on the node.

- (CC3ShaderProgram*) currentShaderProgram
readnonatomicassign

Under OpenGL ES 2.0 & OpenGL, returns the shader program of the mesh node that is currently being visited, or returns nil if that mesh node has no shader program, or when using OpenGL ES 1.1.

It is up to the invoker to make sure that the current node actually is a CC3MeshNode.

This property is only valid during the traversal of the node returned by the currentMeshNode property, and will be nil both before and after the visit: method is invoked on that node.

- (CC3Camera*) defaultCamera
readnonatomicretain

The default camera to use when visiting a node assembly.

This implementation returns the activeCamera property of the starting node. Subclasses may override.

- (GLuint) lightCount
readnonatomicassign

Number of lights in the scene.

- (GLuint) lightProbeCount
readnonatomicassign

Min of number of light probes in the scene, and the number used by the shader program.

- (CC3PerformanceStatistics*) performanceStatistics
readnonatomicassign

The performanceStatistics being accumulated during the visitation runs.

This is extracted from the startingNode, and may be nil if that node is not collecting statistics.

- (CC3Scene*) scene
readnonatomicassign

Returns the CC3Scene.

This is a convenience property that returns the scene property of the startingNode property.

- (BOOL) shouldVisitChildren
readwritenonatomicassign

Indicates whether this visitor should traverse the child nodes of any node it visits.

The initial value of this property is YES.

- (CC3Node*) startingNode
readnonatomicassign

The CC3Node on which this visitation traversal was intitiated.

This is the node on which the visit: method was first invoked to begin a traversal of the node structural hierarchy.

This property is only valid during the traversal, and will be nil both before and after the visit: method is invoked.

- (GLuint) textureCount
readnonatomicassign

Returns the number of textures in the current mesh node.

It is up to the invoker to make sure that the current node actually is a CC3MeshNode.


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