Protected Attributes

CC3NodeArrayZOrderSequencer Class Reference

An CC3NodeArrayZOrderSequencer is a type of CC3NodeArraySequencer that sorts the contained nodes by their Z-order, which is a combination of the explicit Z-order property of each node, and a measure of the distance from the camera to the globalCenterOfGravity of the node's bounding volume. More...

#import <CC3NodeSequencer.h>

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

List of all members.

Protected Attributes

BOOL shouldUseOnlyForwardDistance

Detailed Description

An CC3NodeArrayZOrderSequencer is a type of CC3NodeArraySequencer that sorts the contained nodes by their Z-order, which is a combination of the explicit Z-order property of each node, and a measure of the distance from the camera to the globalCenterOfGravity of the node's bounding volume.

Use this sequencer for translucent nodes. There is no need to use this sequencer for nodes that are opaque (whose isOpaque property returns YES), and the overhead of testing each node on each update should be avoided in that case.

The nodes are sorted using the Z-order property and the cameraDistanceProduct property of the boundingVolume of each node, from furthest from the camera to closest. Nodes without a boundingVolume are added to the end of the array.

Explicit Z-order sequence takes priority over distance to camera. However, sorting based on distance to the camera alone is quite effective. In almost all cases, it is not necessary to set the Z-order property of the nodes, and if the nodes are moving around, assigning an explicit Z-order to each node can actually interfere with the dynamic determination of the correct drawing order. Only use the Z-order property if you have reason to force a specific node to be drawn before or after another node for visual effect.

The distance between a node and the camera can be measured in one of two ways:

  1. The true 3D straight-line distance between the node and the camera.
  2. The distance from the camera to the node measured "straight out" from the camera, ignoring how far the node is away from the center of the camera's view.

The value of the shouldUseOnlyForwardDistance property determines which of these two methods will be used. See the notes of that property in the CC3NodeSequencer for more information. By default, the true 3D distance is used.

Since all nodes, and the camera, can move around on each update, this sequencer will test and re-order its nodes on each update.

Be careful about setting the allowSequenceUpdates property to NO on this sequencer. Since this sequencer will generally only be used to keep translucent nodes in their correct drawing order, setting allowSequenceUpdates to NO will defeat the purpose, and will result in translucent nodes not properly displaying other translucent objects that are behind them.


Member Data Documentation

- (BOOL) shouldUseOnlyForwardDistance [protected]

For sequencers that order nodes based on distance to the camera, indicates whether, when comparing distances from the nodes to the camera, only the distance component that is parallel to the camera's forwardDirection should be considered.

If the value of this property is NO, nodes will be sorted based on the true 3D straight-line distance from each node to the camera, as if drawing a measuring tape from the location of the camera to the location of the center of geometry of the node. This is the most common 3D scenario.

If the value of this property is YES, nodes will be sorted based on the shortest distance from the camera to a plane that is perpendicular to the forwardDirection of the camera and contains the location of the node. This has the effect of sorting nodes based on their distance "straight-out" from the camera, ignoring distance contributed by nodes that are "off to the side" of the camera's view. This option is good for scenes that are built from large planar nodes that move in layers at fixed distances from a fixed camera, similar to cell-animation techniques.

The initial value for this property is NO, indicating that the true 3D distance between the camera and the center of geometry of the node will be used to determine drawing order. Unless your 3D scene is using special cell-animation techniques with large planar nodes, you should not change the value of this property.

In this default abstract implmentation, the value returned is always returned as NO, and values set in this property are ignored. Subclasses that sort based on Z-order, and subclasses that contain such other sequencers will override.

Implements CC3NodeSequencer.


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