Inherits from CC3NodeVisitor : NSObject
Declared in CC3NodeVisitor.h

Overview

CC3NodeDrawingVisitor is a CC3NodeVisitor that is passed to a node when it is visited during drawing operations.

The visitor uses the camera property to determine which nodes to visit. Only nodes that are within the camera’s field of view will be visited. Nodes outside the camera’s frustum will neither be visited nor drawn.

Drawing operations only visit drawable mesh nodes, so the node access properties defined on the CC3NodeVisitor superclass that rely on the current node being a CC3MeshNode containing a mesh and material will be valid.

This visitor maintains access to a number of properties of the node being drawn, and other components in the scene, for access by rendering logic and shaders.

Properties

billboardCCRenderer

The Cocos2D renderer for rendering 2D CCNodes embedded in the 3D scene when using Cocos2D 3.1 and above.

@property (nonatomic, retain) CCRenderer *billboardCCRenderer

Discussion

CCNodes embedded in the 3D scene via CC3Billboard nodes must use a different renderer than the primary rendering loop, because the CC3Billboards are rendered as part of a single rendering command for the entire 3D scene, and the CCNodes containedin the CC3Billboards cannot be added to the rendering queue, while the 3D scene is being drawn.

If not set directly, this property will be lazily initialized on the first access to a new instance, that matches the characteristics of the instance in the ccRenderer property.

Declared In

CC3NodeVisitor.h

ccRenderer

The Cocos2D renderer. Available when using Cocos2D 3.1 and above.

@property (nonatomic, retain) CCRenderer *ccRenderer

Discussion

If not set directly, this property will be lazily initialized on the first access to either the renderer returned by the class-side CCRenderer currentRenderer property, if it exists, or to a new instance, if not.

Declared In

CC3NodeVisitor.h

current2DTextureUnit

The index of the current texture unit holding a 2D texture.

@property (nonatomic, readonly) GLuint current2DTextureUnit

Discussion

This value is initialized to zero when starting to draw each material, and is incremented as each 2D texture in the material is drawn.

Declared In

CC3NodeVisitor.h

currentColor

The current color used during drawing if no materials or lighting are engaged.

@property (nonatomic, assign) ccColor4F currentColor

Discussion

Each of the RGBA components of this color are floating point values between 0 and 1.

Declared In

CC3NodeVisitor.h

currentColor4B

The current color used during drawing if no materials or lighting are engaged.

@property (nonatomic, assign) ccColor4B currentColor4B

Discussion

Each of the RGBA components of this color are integer values between 0 and 255.

Declared In

CC3NodeVisitor.h

currentCubeTextureUnit

The index of the current texture unit holding a cube-map texture.

@property (nonatomic, readonly) GLuint currentCubeTextureUnit

Discussion

This value is initialized to zero when starting to draw each material, and is incremented as each cube-map texture in the material is drawn.

Declared In

CC3NodeVisitor.h

currentSkinSection

During the drawing of nodes that use vertex skinning, this property holds the skin section that is currently being drawn.

@property (nonatomic, assign) CC3SkinSection *currentSkinSection

Discussion

The value of this property is set by the skin section itself and is only valid during the drawing of that skin section.

Declared In

CC3NodeVisitor.h

defaultRenderSurface

Template property that returns the default value used to automatically set the value of the renderSurface property.

@property (nonatomic, readonly) id<CC3RenderSurface> defaultRenderSurface

Discussion

This implementation returns the value of the viewSurface property of the CC3SceneDrawingSurfaceManager held in the surfaceManager property. This is a subsection of the on-screen view surface.

Subclasses may override to return a different surface.

Declared In

CC3NodeVisitor.h

deltaTime

This property gives the interval, in seconds, since the previous frame.

@property (nonatomic, assign) CCTime deltaTime

Discussion

See the description of the CC3Scene minUpdateInterval and maxUpdateInterval properties for more information about clamping the update interval.

Declared In

CC3NodeVisitor.h

gl

Returns the OpenGL engine context.

@property (nonatomic, readonly) CC3OpenGL *gl

Discussion

During drawing, all OpenGL commands are invoked through this instance.

The value of this property is lazily retrieved and set the first time it is accessed.

The value of this property must be compatible with the GL context of the thread on which this visitor is used. If you want to use a single visitor instance on different threads, you can invoke the clearGL method to clear the GL engine reference so it can be lazily recreated when used on the next thread.

Declared In

CC3NodeVisitor.h

isDrawingEnvironmentMap

Indicates whether this visitor is rendering an environment map to a texture.

@property (nonatomic, assign) BOOL isDrawingEnvironmentMap

Discussion

Environment maps typically do not require full detail. This property can be used during drawing to make optimization decisions such as to avoid drawing more complex content when creating an environment map.

The initial value of this property is NO.

Declared In

CC3NodeVisitor.h

layerTransformMatrix

Returns the current CC3Layer GLKMatrix4 transform matrix. Available when using Cocos2D 3.1 and higher.

@property (nonatomic, readonly) const GLKMatrix4 *layerTransformMatrix

Declared In

CC3NodeVisitor.h

modelMatrix

Returns the current model-to-global transform matrix.

@property (nonatomic, readonly) const CC3Matrix4x3 *modelMatrix

Declared In

CC3NodeVisitor.h

modelViewMatrix

Returns the current model-view matrix.

@property (nonatomic, readonly) const CC3Matrix4x3 *modelViewMatrix

Declared In

CC3NodeVisitor.h

modelViewProjMatrix

Returns the current model-view-projection matrix.

@property (nonatomic, readonly) const CC3Matrix4x4 *modelViewProjMatrix

Declared In

CC3NodeVisitor.h

projMatrix

Returns the current projection matrix.

@property (nonatomic, readonly) const CC3Matrix4x4 *projMatrix

Declared In

CC3NodeVisitor.h

renderSurface

The rendering surface to which this visitor is rendering.

@property (nonatomic, retain) id<CC3RenderSurface> renderSurface

Discussion

The surface will be activated at the beginning of each visitation run.

You can set this property at any time to direct rendering to any on-screen or off-screen surface. If not set directly, this property will be set to the value of the defaultRenderSurface property the next time it is accessed. If you have set this property to an specific surface temporarily, you can automatically revert to the defaultRenderSurface by simply setting this property to nil.

This property is is not cleared at the end of the visitation run. It is retained so that this visitor can be used to render multiple node assemblies and complete multiple drawing passes without having to set the surface each time.

Declared In

CC3NodeVisitor.h

shouldDecorateNode

Indicates whether nodes should decorate themselves with their configured material, textures, or color arrays. In most cases, nodes should be drawn decorated. However, specialized visitors may turn off normal decoration drawing in order to do specialized coloring instead.

@property (nonatomic, assign) BOOL shouldDecorateNode

Discussion

The initial value of this property is YES.

Declared In

CC3NodeVisitor.h

surfaceManager

The surface manager that manages the surfaces to which this visitor can render.

@property (nonatomic, retain) CC3SceneDrawingSurfaceManager *surfaceManager

Discussion

Setting this property also clears the renderSurface property, so that, if not explicitly set to another surface, it will be initialized to a surface retrieved from the new surface manager.

During normal rendering, this property is set by the CC3Layer prior to rendering a CC3Scene.

Declared In

CC3NodeVisitor.h

viewMatrix

Returns the current view matrix.

@property (nonatomic, readonly) const CC3Matrix4x3 *viewMatrix

Declared In

CC3NodeVisitor.h

viewProjMatrix

Returns the current view-projection matrix.

@property (nonatomic, readonly) const CC3Matrix4x4 *viewProjMatrix

Declared In

CC3NodeVisitor.h

Instance Methods

alignShotWith:

Aligns this visitor to use the same camera and rendering surface as the specified visitor.

- (void)alignShotWith:(CC3NodeDrawingVisitor *)otherVisitor

Discussion

The camera, surfaceManager, and renderSurface properties of this visitor are set to those of the specified visitor.

You can use this method to ensure that a secondary visitor (such as a shadow visitor, or picking visitor), makes use of the same camera and surface as the primary visitor.

Declared In

CC3NodeVisitor.h

bindEnvironmentalTextures

Binds environmental textures, such as light probes.

- (void)bindEnvironmentalTextures

Declared In

CC3NodeVisitor.h

clearCCRenderers

Clears the ccRenderer and billboardCCRenderer properties.

- (void)clearCCRenderers

Declared In

CC3NodeVisitor.h

clearGL

Clears the reference in the gl property, so that it can be retrieved automatically on the next access of the property. You can use this method before using this visitor on a thread that is different (and therefore likely a different GL engine context) than the last thread on which this visitor was used.

- (void)clearGL

Declared In

CC3NodeVisitor.h

disableUnusedTextureUnits

Disables all texture units that do not have an associated texture.

- (void)disableUnusedTextureUnits

Discussion

The 2D texture are assigned to the lower texture units, and cube-map textures are assigned to texture units above all the 2D textures. This ensures that the same texture types are consistently assigned to the shader samplers, to avoid the shaders recompiling on the fly to adapt to changing texture types.

GL texture units of each type that were not used by the textures are disabled by this method. Since cube-map textures are assigned to texture units above all 2D textures, for nodes with fewer 2D textures than expected by the shader, one or more 2D texture units may be disabled in between the active 2D texture units and any cube-map texture units.

Declared In

CC3NodeVisitor.h

draw:

Draws the specified node. Invoked by the node itself when the node’s local content is to be drawn.

- (void)draw:(CC3Node *)aNode

Discussion

This implementation first caches the current lighting enablement state in case lighting is turned off during drawing of the material, then it double-dispatches back to the node’s drawWithVisitor: method to perform the drawing. Finally, this implementation updates the drawing performance statistics.

Subclass may override to enhance or modify this behaviour.

Declared In

CC3NodeVisitor.h

eyeSpaceBoneMatrixAt:

Returns a pointer to the bone matrix at the specified index, from the currentSkinSection, in the coordinate system of the eye-space of the camera in the camera property.

- (const CC3Matrix4x3 *)eyeSpaceBoneMatrixAt:(GLuint)index

Discussion

This method has meaning only during the drawing of the currentSkinSection. Attempting to access this method at any other time will produced undefined results.

Declared In

CC3NodeVisitor.h

globalBoneMatrixAt:

Returns a pointer to the bone matrix at the specified index, from the currentSkinSection, in the global coordinate system.

- (const CC3Matrix4x3 *)globalBoneMatrixAt:(GLuint)index

Discussion

This method has meaning only during the drawing of the currentSkinSection. Attempting to access this method at any other time will produced undefined results.

Declared In

CC3NodeVisitor.h

increment2DTextureUnit

Increments the value fo the current2DTextureUnit property.

- (void)increment2DTextureUnit

Declared In

CC3NodeVisitor.h

incrementCubeTextureUnit

Increments the value fo the currentCubeTextureUnit property.

- (void)incrementCubeTextureUnit

Declared In

CC3NodeVisitor.h

modelSpaceBoneMatrixAt:

Returns a pointer to the bone matrix at the specified index, from the currentSkinSection, in the coordinate system of the mesh node in the currentMeshNode property.

- (const CC3Matrix4x3 *)modelSpaceBoneMatrixAt:(GLuint)index

Discussion

This method has meaning only during the drawing of the currentSkinSection. Attempting to access this method at any other time will produced undefined results.

Declared In

CC3NodeVisitor.h

populateLayerTransformMatrixFrom:

Populates the current CC3Layer transform matrix from the specified GLKMatrix4 matrix.

- (void)populateLayerTransformMatrixFrom:(const GLKMatrix4 *)layerMtx

Declared In

CC3NodeVisitor.h

populateModelMatrixFrom:

Populates the current model-to-global matrix from the specified matrix.

- (void)populateModelMatrixFrom:(CC3Matrix *)modelMtx

Declared In

CC3NodeVisitor.h

populateProjMatrixFrom:

Populates the current projection matrix from the specified matrix.

- (void)populateProjMatrixFrom:(CC3Matrix *)projMtx

Discussion

This method is invoked automatically when the camera property is set.

Declared In

CC3NodeVisitor.h

populateViewMatrixFrom:

Populates the current view matrix from the specified matrix.

- (void)populateViewMatrixFrom:(CC3Matrix *)viewMtx

Discussion

This method is invoked automatically when the camera property is set.

Declared In

CC3NodeVisitor.h

resetTextureUnits

Sets the value of the current2DTextureUnit property to zero, and sets the value of the currentCubeTextureUnit property to either the value of the textureCubeStart property of the currentShaderProgram (OpenGL ES 2.0 & OpenGL), or to the same as the textureCount property of this instance (OpenGL ES 1.1).

- (void)resetTextureUnits

Discussion

The 2D texture are assigned to the lower texture units, and cube-map textures are assigned to texture units above all the 2D textures. This ensures that the same texture types are consistently assigned to the shader samplers, to avoid the shaders recompiling on the fly to adapt to changing texture types.

Additional environmental textures, such as light probes, are assigned to the texture units beyond the model’s cube textures.

GL texture units of each type that were not used by the textures are disabled via the disabledTextureUnits method.

Declared In

CC3NodeVisitor.h

transformGlobalLocationToEyeSpace:

Transforms the specified global location to the coordinate system of the camera (eye space).

- (CC3Vector)transformGlobalLocationToEyeSpace:(CC3Vector)globalLocation

Declared In

CC3NodeVisitor.h

transformGlobalLocationToModelSpace:

Transforms the specified global location to the coordinate system of the current node.

- (CC3Vector)transformGlobalLocationToModelSpace:(CC3Vector)globalLocation

Declared In

CC3NodeVisitor.h