Public Member Functions | Properties

CC3NodeTransformingVisitor Class Reference

CC3NodeTransformingVisitor is a CC3NodeVisitor that is passed to a node when it is visited during transformation operations. More...

#import <CC3NodeVisitor.h>

Inheritance diagram for CC3NodeTransformingVisitor:
Inheritance graph
[legend]
Collaboration diagram for CC3NodeTransformingVisitor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(CC3GLMatrix *) - parentTansformMatrixFor:

Properties

BOOL isTransformDirty
BOOL shouldLocalizeToStartingNode

Detailed Description

CC3NodeTransformingVisitor is a CC3NodeVisitor that is passed to a node when it is visited during transformation operations.

This visitor encapsulates whether the transformation matrix needs to be recalculated. The transformation matrix needs to be recalculated if any of the node's transform properties (location, rotation, scale) have changed, or if those of an ancestor node were changed.

The transforms can be calculated from the CC3World or from the startingNode, depending on the value of the shouldLocalizeToStartingNode property. Normally, the transforms are calculated from the CC3World, but localizing to the startingNode can be useful for determining relative transforms between ancestors and descendants.


Member Function Documentation

- (CC3GLMatrix*) parentTansformMatrixFor: (CC3Node *)  aNode

Returns the transform matrix to use as the parent matrix when transforming the specified node.

This usually returns the transformMatrix of the parent of the specified node. However, if the specified node has no parent, or if the shouldLocalizeToStartingNode is set to YES and the startingNode is either the specified node or its parent, this method returns nil.


Property Documentation

- (BOOL) isTransformDirty [read, assign]

Returns whether the transform matrix of the node currently being visited is dirty and needs to be recalculated.

The value of this property is consistent throughout the processing of a particular node. It is set before each node is visited, and is not changed until after the node has finished being processed, even if the node's transform matrix is recalculated during processing. This allows any post-node-processing activities, either within the visitor or within the node, to know that the transform matrix was changed.

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

Indicates whether all transforms should be localized to the local coordinate system of the startingNode.

If this property is set to NO, the transforms of all ancestors of each node, all the way to CC3World, will be included when calculating the transformMatrix and global properties of that node. This is the normal situation.

If this property is set to YES the transforms of the startingNode and its ancestors, right up to the CC3World, will be ignored. The result is that the transformMatrix and all global properties (globalLocation, etc) will be relative to the startingNode.

This can be useful when you want to coordinate node positioning within a particular common ancestor, by using their global properties relative to that common ancestor node.

It is also used when determine the boundingBox property of a node, by transforming all descendant nodes by all transforms between the node and each descendant, but ignoring the transforms of the ancestor nodes of the node whose local bounding box is being calculated.

Setting this property to YES will force the recalculation of the transformMatrix of each node visited, to ensure that they are relative to the startingNode. Further, once the visitation run is complete, if this property is set to YES, the close method will rebuild the transformMatrices of the startingNode and its descendants, to leave the transformMatrices in their normal global form.

The initial value of this property is NO.


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