Cocos3D  2.0.1
Instance Methods | Properties | List of all members
CC3NodeDrawingVisitor Class Reference

#import <CC3NodeVisitor.h>

Inheritance diagram for CC3NodeDrawingVisitor:
Inheritance graph
[legend]

Instance Methods

(void) - alignShotWith:
 
(void) - bindEnvironmentalTextures
 
(void) - clearCCRenderers
 
(void) - clearGL
 
(void) - disableUnusedTextureUnits
 
(void) - draw:
 
(const CC3Matrix4x3 *) - eyeSpaceBoneMatrixAt:
 
(const CC3Matrix4x3 *) - globalBoneMatrixAt:
 
(void) - increment2DTextureUnit
 
(void) - incrementCubeTextureUnit
 
(const CC3Matrix4x3 *) - modelSpaceBoneMatrixAt:
 
(void) - populateLayerTransformMatrixFrom:
 
(void) - populateModelMatrixFrom:
 
(void) - populateProjMatrixFrom:
 
(void) - populateViewMatrixFrom:
 
(void) - resetTextureUnits
 
(CC3Vector- transformGlobalLocationToEyeSpace:
 
(CC3Vector- transformGlobalLocationToModelSpace:
 
- Instance Methods inherited from CC3NodeVisitor
(CC3TextureUnit *) - currentTextureUnitAt:
 
(NSString *) - fullDescription
 
(CC3Light *) - lightAt:
 
(CC3LightProbe *) - lightProbeAt:
 
(void) - requestRemovalOf:
 
(BOOL) - visit:
 

Properties

CCRendererbillboardCCRenderer
 
CCRendererccRenderer
 
GLuint current2DTextureUnit
 
ccColor4F currentColor
 
ccColor4B currentColor4B
 
GLuint currentCubeTextureUnit
 
CC3SkinSectioncurrentSkinSection
 
id< CC3RenderSurfacedefaultRenderSurface
 
CCTime deltaTime
 
CC3OpenGLgl
 
BOOL isDrawingEnvironmentMap
 
const GLKMatrix4 * layerTransformMatrix
 
const CC3Matrix4x3modelMatrix
 
const CC3Matrix4x3modelViewMatrix
 
const CC3Matrix4x4modelViewProjMatrix
 
const CC3Matrix4x4projMatrix
 
id< CC3RenderSurfacerenderSurface
 
BOOL shouldDecorateNode
 
CC3SceneDrawingSurfaceManagersurfaceManager
 
const CC3Matrix4x3viewMatrix
 
const CC3Matrix4x4viewProjMatrix
 
- Properties inherited from CC3NodeVisitor
CC3Cameracamera
 
CC3MaterialcurrentMaterial
 
CC3MeshcurrentMesh
 
CC3MeshNodecurrentMeshNode
 
CC3NodecurrentNode
 
CC3ShaderProgramcurrentShaderProgram
 
CC3CameradefaultCamera
 
GLuint lightCount
 
GLuint lightProbeCount
 
CC3PerformanceStatisticsperformanceStatistics
 
CC3Scenescene
 
BOOL shouldVisitChildren
 
CC3NodestartingNode
 
GLuint textureCount
 

Additional Inherited Members

- Class Methods inherited from CC3NodeVisitor
(id) + visitor
 

Detailed Description

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.

Method Documentation

- (void) alignShotWith: (CC3NodeDrawingVisitor *)  otherVisitor

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

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.

Implemented in CC3NodePickingVisitor.

- (void) bindEnvironmentalTextures

Binds environmental textures, such as light probes.

- (void) clearCCRenderers

Clears the ccRenderer and billboardCCRenderer properties.

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

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

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.

- (void) draw: (CC3Node *)  aNode

Draws the specified node.

Invoked by the node itself when the node's local content is to be drawn.

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.

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

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.

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

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

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

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

- (void) increment2DTextureUnit

Increments the value fo the current2DTextureUnit property.

- (void) incrementCubeTextureUnit

Increments the value fo the currentCubeTextureUnit property.

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

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.

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

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

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

- (void) populateModelMatrixFrom: (CC3Matrix *)  modelMtx

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

- (void) populateProjMatrixFrom: (CC3Matrix *)  projMtx

Populates the current projection matrix from the specified matrix.

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

- (void) populateViewMatrixFrom: (CC3Matrix *)  viewMtx

Populates the current view matrix from the specified matrix.

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

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

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.

- (CC3Vector) transformGlobalLocationToEyeSpace: (CC3Vector globalLocation

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

- (CC3Vector) transformGlobalLocationToModelSpace: (CC3Vector globalLocation

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

Property Documentation

- (CCRenderer*) billboardCCRenderer
readwritenonatomicretain

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

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.

- (CCRenderer*) ccRenderer
readwritenonatomicretain

The Cocos2D renderer.

Available when using Cocos2D 3.1 and above.

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.

- (GLuint) current2DTextureUnit
readnonatomicassign

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

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

- (ccColor4F) currentColor
readwritenonatomicassign

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

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

- (ccColor4B) currentColor4B
readwritenonatomicassign

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

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

- (GLuint) currentCubeTextureUnit
readnonatomicassign

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

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.

- (CC3SkinSection*) currentSkinSection
readwritenonatomicassign

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

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

- (id<CC3RenderSurface>) defaultRenderSurface
readnonatomicassign

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

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.

- (CCTime) deltaTime
readwritenonatomicassign

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

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

- (CC3OpenGL*) gl
readnonatomicassign

Returns the OpenGL engine context.

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.

- (BOOL) isDrawingEnvironmentMap
readwritenonatomicassign

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

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.

- (const GLKMatrix4*) layerTransformMatrix
readnonatomicassign

Returns the current CC3Layer GLKMatrix4 transform matrix.

Available when using Cocos2D 3.1 and higher.

- (const CC3Matrix4x3*) modelMatrix
readnonatomicassign

Returns the current model-to-global transform matrix.

- (const CC3Matrix4x3*) modelViewMatrix
readnonatomicassign

Returns the current model-view matrix.

- (const CC3Matrix4x4*) modelViewProjMatrix
readnonatomicassign

Returns the current model-view-projection matrix.

- (const CC3Matrix4x4*) projMatrix
readnonatomicassign

Returns the current projection matrix.

- (id<CC3RenderSurface>) renderSurface
readwritenonatomicretain

The rendering surface to which this visitor is rendering.

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.

- (BOOL) shouldDecorateNode
readwritenonatomicassign

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.

The initial value of this property is YES.

- (CC3SceneDrawingSurfaceManager*) surfaceManager
readwritenonatomicretain

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

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.

- (const CC3Matrix4x3*) viewMatrix
readnonatomicassign

Returns the current view matrix.

- (const CC3Matrix4x4*) viewProjMatrix
readnonatomicassign

Returns the current view-projection matrix.


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