cocos3d  2.0.0
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) - disableUnusedTextureUnits
 
(void) - draw:
 
(CC3Matrix4x3 *) - eyeSpaceBoneMatrixAt:
 
(CC3Matrix4x3 *) - globalBoneMatrixAt:
 
(CC3Matrix4x3 *) - modelSpaceBoneMatrixAt:
 
(void) - populateModelMatrixFrom:
 
(void) - populateProjMatrixFrom:
 
(void) - populateViewMatrixFrom:
 
(void) - resetTextureUnits
 
- Instance Methods inherited from CC3NodeVisitor
(CC3TextureUnit *) - currentTextureUnitAt:
 
(NSString *) - fullDescription
 
(CC3Light *) - lightAt:
 
(void) - requestRemovalOf:
 
(BOOL) - visit:
 

Properties

GLuint current2DTextureUnit
 
ccColor4F currentColor
 
ccColor4B currentColor4B
 
GLuint currentCubeTextureUnit
 
CC3SkinSectioncurrentSkinSection
 
id< CC3RenderSurfacedefaultRenderSurface
 
ccTime deltaTime
 
CC3OpenGLgl
 
BOOL isDrawingEnvironmentMap
 
CC3Matrix4x3modelMatrix
 
CC3Matrix4x3modelViewMatrix
 
CC3Matrix4x4modelViewProjMatrix
 
CC3Matrix4x4projMatrix
 
id< CC3RenderSurfacerenderSurface
 
BOOL shouldDecorateNode
 
CC3Matrix4x3viewMatrix
 
CC3Matrix4x4viewProjMatrix
 
- Properties inherited from CC3NodeVisitor
CC3Cameracamera
 
CC3MaterialcurrentMaterial
 
CC3MeshcurrentMesh
 
CC3MeshNodecurrentMeshNode
 
CC3NodecurrentNode
 
CC3ShaderProgramcurrentShaderProgram
 
CC3CameradefaultCamera
 
NSUInteger lightCount
 
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 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.

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

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

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

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

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

Property Documentation

- (GLuint) current2DTextureUnit
readwritenonatomicassign

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
readwritenonatomicassign

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
readwritenonatomicstrong

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
readnonatomicstrong

Template property that returns the initial value of the renderSurface property.

This implementation returns the scene's viewSurface. Since it relies on the scene property haveing a value, this property will be nil unless a visitation run is in progress.

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
readwritenonatomicstrong

The OpenGL state.

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

If not set directly, this is lazily initialized to the sharedGL (CC3OpenGL) singleton.

- (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 certain more complex content when creating an environment map.

The initial value of this property is NO.

- (CC3Matrix4x3*) modelMatrix
readnonatomicassign

Returns the current model-to-global transform matrix.

- (CC3Matrix4x3*) modelViewMatrix
readnonatomicassign

Returns the current model-view matrix.

- (CC3Matrix4x4*) modelViewProjMatrix
readnonatomicassign

Returns the current model-view-projection matrix.

- (CC3Matrix4x4*) projMatrix
readnonatomicassign

Returns the current projection matrix.

- (id<CC3RenderSurface>) renderSurface
readwritenonatomicstrong

The rendering surface to which this visitor is rendering.

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

If not set beforehand, this property will be initialized to the value of the defaultRenderSurface property the first time it is accessed.

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.

- (CC3Matrix4x3*) viewMatrix
readnonatomicassign

Returns the current view matrix.

- (CC3Matrix4x4*) viewProjMatrix
readnonatomicassign

Returns the current view-projection matrix.


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