Public Member Functions | Properties

CC3SkinMeshNode Class Reference

CC3SkinMeshNode is a CC3MeshNode specialized to use vertex skinning to draw the contents of its mesh. More...

#import <CC3VertexSkinning.h>

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

List of all members.

Public Member Functions

(void) - boneWasTransformed:
(GLuint) - matrixIndexForVertexUnit:at:
(void) - setMatrixIndex:forVertexUnit:at:
(void) - setVertexMatrixIndex:forVertexUnit:at:
(void) - setVertexMatrixIndices:at:
(void) - setVertexWeight:forVertexUnit:at:
(void) - setVertexWeights:at:
(void) - setWeight:forVertexUnit:at:
(CC3SkinSection *) - skinSectionForFaceIndex:
(CC3SkinSection *) - skinSectionForVertexIndexAt:
(void) - updateVertexMatrixIndicesGLBuffer
(void) - updateVertexWeightsGLBuffer
(GLuint) - vertexMatrixIndexForVertexUnit:at:
(GLvoid *) - vertexMatrixIndicesAt:
(GLfloat) - vertexWeightForVertexUnit:at:
(GLfloat *) - vertexWeightsAt:
(GLfloat) - weightForVertexUnit:at:

Properties

CC3DeformedFaceArraydeformedFaces
GLenum matrixIndexType
CC3MatrixrestPoseTransformMatrix
CC3SkinMeshskinnedMesh
CCArray * skinSections
GLuint vertexUnitCount

Detailed Description

CC3SkinMeshNode is a CC3MeshNode specialized to use vertex skinning to draw the contents of its mesh.

It is one of the key structural descendant nodes of a CC3SoftBodyNode instance.

Like all mesh nodes, a CC3SkinMeshNode contains a material and a mesh. For a CC3SkinMeshNode, the mesh must be a CC3SkinMesh, which manages the mesh vertices, including the vertex weights that determine, for each vertex, how the location of that vertex is influenced by the location and orientation of each skeleton bone.

This CC3MeshNode subclass adds a number of methods for accessing and managing the weights and matrix index data associated with each vertex.

In addition, the CC3SkinMeshNode contains a collection of skin sections, in the form of CC3SkinSection instances. Each CC3SkinSection instance relates a section of the mesh, in the form of a range of vertices, to a set of bones in the skeleton.

Each CC3SkinSection applies the transformations in the referenced bones to the the vertices in the section of the mesh that it controls, and draws that section of the mesh by drawing the vertices within its range in a single GL call.

After copying a CC3SkinMeshNode, the newly created copy will still be influenced by the original skeleton. The result is that both the original mesh and the copy will move and be deformed in tandem as the skeleton moves.

If you are creating a chorus line of dancing characters, this may be the effect you are after. However, if you are creating a squadron of similar, but independently moving characters, each CC3SkinMeshNode copy should be controlled by a separate skeleton.

After creating a copy of the skeleton bone node assembly as well, you can use the reattachBonesFrom: method to attach the skin mesh node to the new skeleton.

When copying a CC3SkinMeshNode as part of copying a CC3SoftBodyNode instance, a copy of the skeleton is also created, and the reattachBonesFrom: method is automatically invoked. When copying CC3SoftBodyNode, you do not need to invoke the reattachBonesFrom: method on the new CC3SkinMeshNode directly.


Member Function Documentation

- (void) boneWasTransformed: (CC3Bone *)  aBone

Callback method that will be invoked when the transformMatrix of the specified bone has changed.

The transform matrix of this node is marked as dirty, so that the changes are propagated to descendant nodes, such as shadow volumes, and to update the deformedFaces property.

This callback is implemented as distinct from the general notification mechanism of the bone because of its importance, and so that this class and its subclasses do not need to distiguish this callback from other notifications that this instance might register for.

- (GLuint) matrixIndexForVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  DEPRECATED_ATTRIBUTE 
Deprecated:
Renamed to vertexMatrixIndexForVertexUnit:at:
- (void) setMatrixIndex: (GLuint)  aMatrixIndex
forVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  DEPRECATED_ATTRIBUTE 
Deprecated:
Renamed to setVertexMatrixIndex:forVertexUnit:at:
- (void) setVertexMatrixIndex: (GLuint)  aMatrixIndex
forVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  index 

Sets the matrix index element, for the specified vertex unit, at the specified index in the underlying vertex data, to the specified value.

Several matrix indices are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The specified vertexUnit parameter must be between zero inclusive, and the vertexUnitCount property, exclusive.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.

When all vertex changes have been made, be sure to invoke the updateVertexMatrixIndicesGLBuffer method to ensure that the GL VBO that holds the vertex data is updated.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (void) setVertexMatrixIndices: (GLvoid *)  mtxIndices
at: (GLuint)  index 

Sets the matrix index elements at the specified vertex index in the underlying vertex data, to the values in the specified array.

Several matrix index values are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The number of elements is the same for all vertices in this mesh, and can be retrieved from the vertexUnitCount property. The number of elements in the specified input array must therefore be at least as large as the value of the vertexUnitCount property.

The matrix indices can be stored in this mesh as either type GLushort or type GLubyte. The specified array must be of the type of index stored by this mesh, and it is up to the application to know which type is required, and provide that type of array accordingly. The type can be determined by the matrixIndexType property of this mesh, which will return one of GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE, respectively.

To avoid checking the matrixIndexType property altogether, you can use the setVertexMatrixIndex:forVertexUnit:at: method, which sets the matrix index values one at a time, and automatically converts the input type to the correct stored type.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.

When all vertex changes have been made, be sure to invoke the updateVertexMatrixIndicesGLBuffer method to ensure that the GL VBO that holds the vertex data is updated.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (void) setVertexWeight: (GLfloat)  aWeight
forVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  index 

Sets the weight element, for the specified vertex unit, at the specified index in the underlying vertex data, to the specified value.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.

Several weights are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The specified vertexUnit parameter must be between zero inclusive, and the vertexUnitCount property, exclusive.

When all vertex changes have been made, be sure to invoke the updateVertexWeightsGLBuffer method to ensure that the GL VBO that holds the vertex data is updated.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (void) setVertexWeights: (GLfloat *)  weights
at: (GLuint)  index 

Sets the weight elements at the specified vertex index in the underlying vertex data, to the values in the specified array.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.

Several weights are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The number of weight elements is the same for all vertices in this mesh, and can be retrieved from the vertexUnitCount property. The number of elements in the specified input array must therefore be at least as large as the value of the vertexUnitCount property.

When all vertex changes have been made, be sure to invoke the updateVertexWeightsGLBuffer method to ensure that the GL VBO that holds the vertex data is updated.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (void) setWeight: (GLfloat)  aWeight
forVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  DEPRECATED_ATTRIBUTE 
Deprecated:
Renamed to setVertexWeight:forVertexUnit:at:
- (CC3SkinSection*) skinSectionForFaceIndex: (GLint)  faceIndex

Returns the skin section that deforms the specified face.

The specified faceIndex value refers to the index of the face, not the vertices themselves. So, a value of 5 will retrieve the three vertices that make up the fifth triangular face in this mesh. The specified index must be between zero, inclusive, and the value of the faceCount property, exclusive.

- (CC3SkinSection*) skinSectionForVertexIndexAt: (GLint)  index

Returns the skin section that deforms the specified vertex.

Each skin section operates on a consecutive array of vertex indices. If this mesh uses vertex indexing, the specified index should be an index into the vertex index array.

If this mesh does not use vertex indexing, then the specified index should be the index of the vertex in the vertex locations array.

- (void) updateVertexMatrixIndicesGLBuffer

Updates the GL engine buffer with the vertex weight data in this mesh.

- (void) updateVertexWeightsGLBuffer

Updates the GL engine buffer with the vertex weight data in this mesh.

- (GLuint) vertexMatrixIndexForVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  index 

Returns the matrix index element, for the specified vertex unit, at the specified index in the underlying vertex data.

Several matrix indices are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The specified vertexUnit parameter must be between zero inclusive, and the vertexUnitCount property, exclusive.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (GLvoid*) vertexMatrixIndicesAt: (GLuint)  index

Returns a pointer to an array of the matrix indices at the specified vertex index in the underlying vertex data.

Several matrix index values are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The number of elements in the returned array is the same for all vertices in this mesh, and can be retrieved from the vertexUnitCount property.

The matrix indices can be stored in this mesh as either type GLushort or type GLubyte. The returned array will be of the type of index stored by this vertex array, and it is up to the application to know which type will be returned, and cast the returned array accordingly. The type can be determined by the matrixIndexType property of this mesh, which will return one of GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE, respectively.

To avoid checking the matrixIndexType property altogether, you can use the vertexMatrixIndexForVertexUnit:at: method, which retrieves the matrix index values one at a time, and automatically converts the stored type to GLushort.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct elements.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (GLfloat) vertexWeightForVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  index 

Returns the weight element, for the specified vertex unit, at the specified index in the underlying vertex data.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct element.

Several weights are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The specified vertexUnit parameter must be between zero inclusive, and the vertexUnitCount property, exclusive.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (GLfloat*) vertexWeightsAt: (GLuint)  index

Returns a pointer to an array of the weight elements at the specified vertex index in the underlying vertex data.

Several weights are stored for each vertex, one per vertex unit, corresponding to one for each bone that influences the location of the vertex. The number of elements in the returned array is the same for all vertices in this mesh, and can be retrieved from the vertexUnitCount property.

The index refers to vertices, not bytes. The implementation takes into consideration the vertexStride and elementOffset properties to access the correct elements.

If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.

- (GLfloat) weightForVertexUnit: (GLuint)  vertexUnit
at: (GLuint)  DEPRECATED_ATTRIBUTE 
Deprecated:
Renamed to vertexWeightForVertexUnit:at:

Property Documentation

- (CC3DeformedFaceArray *) deformedFaces [read, write, retain]

Contains information about the faces and vertices in the mesh that have been deformed by the current position of the underlying bones.

This property contains deformed vertex information for the faces, and additional information about the faces that can be used in certain customized lighting and shadowing effects.

If this property is not set directly, it will be lazily initialized on first access.

- (GLenum) matrixIndexType [read, assign]

Returns the type of data stored for each bone matrix index.

The value returned by this property will be either GL_UNSIGNED_SHORT or GL_UNSIGNED_BYTE, corresponding to each matrix index being stored in either a type GLushort or type GLubyte, respectively.

- (CC3Matrix *) restPoseTransformMatrix [read, retain]

Returns the cached rest pose matrix, relative to the soft-body ancestor node.

This is the transform matrix of this node when it is in its rest pose, which is the location and rotation that corresponds to the rest pose of the bones.

The value of this property is set when the bindRestPose method is invoked.

- (CC3SkinMesh*) skinnedMesh [read, assign]

The CC3Mesh used by this node, cast as a CC3SkinMesh, for convenience in accessing the additional behavour available to support bone vertices.

- (CCArray *) skinSections [read, retain]

The collection of CC3SkinSections that are managed by this node.

- (GLuint) vertexUnitCount [read, assign]

Returns the number of vertex units used by this skin mesh.

This value indicates how many bones influence each vertex, and corresponds to the number of weights and matrix indices attached to each vertex.


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