Public Member Functions | Static Public Member Functions | Properties

CC3NodeVisitor Class Reference

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

#import <CC3NodeVisitor.h>

Inheritance diagram for CC3NodeVisitor:
Inheritance graph
[legend]

List of all members.

Public Member Functions

(NSString *) - fullDescription
(void) - requestRemovalOf:
(void) - visit:

Static Public Member Functions

(id) + visitor

Properties

CC3NodecurrentNode
CC3PerformanceStatisticsperformanceStatistics
CC3GLMatrixscratchMatrix
BOOL shouldVisitChildren
CC3NodestartingNode

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.


Member Function Documentation

- (NSString*) fullDescription

Returns a more detailed description of this instance.

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

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

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

+ (id) visitor

Allocates and initializes an autoreleased instance.


Property Documentation

- (CC3Node *) currentNode [read, assign]

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.

- (CC3PerformanceStatistics*) performanceStatistics [read, assign]

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.

- (CC3GLMatrix *) scratchMatrix [read, retain]

Returns a CC3GLMatrix that can be used as a scratch pad for any matrix math that is required during drawing.

This matrix is made available as a convenience to remove the overhead of repeatedly allocating and disposing temporary matrices during drawing matrix math calculations.

The matrix is lazily created the first time this property is accessed, and is not released until the visitor is deallocated. It can be reused repeatedly during the drawing of any meshes, and from frame to frame.

Because of this, you should not assume that the matrix will have any particular contents when accessed at the beginning of any particular calculation. Always ensure that you populate it to the desired initial state using one of the populate... methods of CC3GLMatrix.

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

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

The initial value of this property is YES.

- (CC3Node *) startingNode [read, assign]

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.


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