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

(void) - close
(id) - initWithWorld:
(void) - open
(void) - requestRemovalOf:

Static Public Member Functions

(id) + visitor
(id) + visitorWithWorld:

Properties

CC3PerformanceStatisticsperformanceStatistics
BOOL shouldVisitChildren
CC3Worldworld

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.

The traversal of the node structural hierarchy is handled by the node, using contextual information contained in the visitor. The visitor encapsulates the CC3World, so that nodes have access to other nodes within their world.

The visitor class may also determine some or all of the activities that will occur during the traversal of the node hierarchy.

This base implementation does nothing. Subclasses can perform specialized functions when visiting the nodes, such as drawing, updating, or selecting nodes.


Member Function Documentation

- (void) close

Invoked automatically after visiting the last node during a visitation run.

This method is invoked automatically after all nodes have been visited. It is not invoked for each node visited.

Default implementation does nothing. Subclasses can override to clean up their state, or to reset any external state, such as GL state, upon completion of a visitation run.

- (id) initWithWorld: (CC3World *)  theWorld

Initializes this instance with the specified CC3World.

- (void) open

Invoked automatically prior to the first node being visited during a visitation run.

This method is invoked automatically once before visiting any nodes. It is not invoked for each node visited.

Default implementation does nothing. Subclasses can override to initialize their state, or to set any external state needed, such as GL state, prior to starting a visitation run.

- (void) requestRemovalOf: (CC3Node *)  aNode

Requests the removal of the specfied node.

During a visitation run, you should 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.

+ (id) visitor

Allocates and initializes an autoreleased instance without a CC3World.

+ (id) visitorWithWorld: (CC3World *)  theWorld

Allocates and initializes an autoreleased instance with the specified CC3World.


Property Documentation

- (CC3PerformanceStatistics *) performanceStatistics [read, assign]

The performanceStatistics being accumulated by the CC3World.

This is extracted from the CC3World, and may be nil if the world is not collecting statistics.

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

Indicates whether nodes should propagate visits to their children.

The default initial value is YES.

- (CC3World *) world [read, write, retain]

The CC3World that the node is part of.

Each node can interact with other nodes in the 3D world, through this property.

The requirement for encapsulating the world is determined by the subclass. Some subclasses may not need access to the CC3World.


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