CC3SkinMesh is a CC3VertexArrayMesh that, in addition to the familiar vertex data such as locations, normals and texture coordinates, adds vertex arrays for bone weights and bone matrix indices. More...
#import <CC3VertexSkinning.h>
Public Member Functions | |
(void) | - doNotBufferVertexMatrixIndices |
(void) | - doNotBufferVertexWeights |
(GLushort) | - matrixIndexForVertexUnit:at: |
(void) | - retainVertexMatrixIndices |
(void) | - retainVertexWeights |
(void) | - setMatrixIndex:forVertexUnit:at: |
(void) | - setWeight:forVertexUnit:at: |
(void) | - updateVertexMatrixIndicesGLBuffer |
(void) | - updateVertexWeightsGLBuffer |
(GLfloat) | - weightForVertexUnit:at: |
Properties | |
CC3VertexMatrixIndices * | boneMatrixIndices |
CC3VertexWeights * | boneWeights |
CC3SkinMesh is a CC3VertexArrayMesh that, in addition to the familiar vertex data such as locations, normals and texture coordinates, adds vertex arrays for bone weights and bone matrix indices.
Each element of the CC3VertexMatrixIndices vertex array in the boneMatrixIndices property is a set of index values that reference a set of bones that influence the location of that vertex.
Each element of the CC3VertexWeights vertex array in the boneWeights property contains a corresponding set of weighting values that determine the relative influence that each of the bones identified in the boneMatrixIndices has on transforming the location of the vertex.
For each vertex, there is a one-to-one correspondence between each bone index values and the weights. The first weight is applied to the bone identified by the first index. Therefore, the elementSize property of the vertex arrays in the boneWeights and boneMatrixIndices properties must be the same. The value of these elementSize properties therefore effectively defines how many bones influence each vertex in these arrays, and this value must be the same for all vertices in these arrays.
Since the bone indexes can change from vertex to vertex, different vertices can be influenced by a different set of bones, but the absolute number of bones influencing each vertex must be consistent, and is defined by the elementSize properties. For any vertex, the weighting values define the influe that each of the bones has on the vertex. A zero value for a bone weight in a vertex indicates that location of that vertex is not affected by the tranformation of that bone.
There is a limit to how many bones may be assigned to each vertex, and this limit is defined by the number of vertex units supported by the platform, and the elementSize property of each of the boneMatrixIndices and boneWeights vertex arrays must not be larger than the number of available vertex units. This value can be retrieved from [CC3OpenGLES11Engine engine].platform.maxVertexUnits.value.
This CC3Mesh subclass adds a number of methods for accessing and managing the weights and matrix index data associated with each vertex.
- (void) doNotBufferVertexMatrixIndices |
Convenience method to cause the vertex matrix index data to be skipped when createGLBuffers is invoked.
The vertex data is not buffered to a GL VBO, is retained in application memory, and is submitted to the GL engine on each frame render.
Only the vertex matrix index will not be buffered to a GL VBO. Any other vertex data, such as locations, or texture coordinates, will be buffered to a GL VBO when createGLBuffers is invoked.
This method causes the vertex data to be retained in application memory, so, if you have invoked this method, you do NOT also need to invoke the retainVertexMatrixIndices method.
- (void) doNotBufferVertexWeights |
Convenience method to cause the vertex weight data to be skipped when createGLBuffers is invoked.
The vertex data is not buffered to a GL VBO, is retained in application memory, and is submitted to the GL engine on each frame render.
Only the vertex weight will not be buffered to a GL VBO. Any other vertex data, such as locations, or texture coordinates, will be buffered to a GL VBO when createGLBuffers is invoked.
This method causes the vertex data to be retained in application memory, so, if you have invoked this method, you do NOT also need to invoke the retainVertexWeights method.
- (GLushort) matrixIndexForVertexUnit: | (GLuint) | vertexUnit | |
at: | (GLsizei) | index | |
Returns the matrix index 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 elementStride and elementOffset properties to access the correct element.
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 elementSize property, exclusive.
If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.
- (void) retainVertexMatrixIndices |
Convenience method to cause the vertex matrix index data to be retained in application memory when releaseRedundantData is invoked, even if it has been buffered to a GL VBO.
Only the vertex matrix index will be retained. Any other vertex data, such as locations, or texture coordinates, that has been buffered to GL VBO's, will be released from application memory when releaseRedundantData is invoked.
- (void) retainVertexWeights |
Convenience method to cause the vertex weight data to be retained in application memory when releaseRedundantData is invoked, even if it has been buffered to a GL VBO.
Only the vertex weight will be retained. Any other vertex data, such as locations, or texture coordinates, that has been buffered to GL VBO's, will be released from application memory when releaseRedundantData is invoked.
- (void) setMatrixIndex: | (GLushort) | aMatrixIndex | |
forVertexUnit: | (GLuint) | vertexUnit | |
at: | (GLsizei) | index | |
Sets the matrix index 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 elementStride and elementOffset properties to access the correct element.
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 elementSize property, exclusive.
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) setWeight: | (GLfloat) | aWeight | |
forVertexUnit: | (GLuint) | vertexUnit | |
at: | (GLsizei) | 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 elementStride 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 elementSize 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) 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.
- (GLfloat) weightForVertexUnit: | (GLuint) | vertexUnit | |
at: | (GLsizei) | 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 elementStride 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 elementSize property, exclusive.
If the releaseRedundantData method has been invoked and the underlying vertex data has been released, this method will raise an assertion exception.
- (CC3VertexMatrixIndices *) boneMatrixIndices [read, write, retain] |
The vertex array that manages the indices of the bones that influence each vertex.
Each element of the vertex array in this property is a small set of index values that reference a set of bones that influence the location of that vertex.
The elementSize property of the vertex arrays in the boneWeights and boneMatrixIndices properties must be the same, and must not be larger than the maximum number of available vertex units for the platform, which can be retreived from [CC3OpenGLES11Engine engine].platform.maxVertexUnits.value.
- (CC3VertexWeights *) boneWeights [read, write, retain] |
The vertex array that manages the weighting that each bone has in influencing each vertex.
Each element of the vertex array in this property contains a small set of weighting values that determine the relative influence that each of the bones identified for that vertex in the boneMatrixIndices property has on transforming the location of the vertex.
The elementSize property of the vertex arrays in the boneWeights and boneMatrixIndices properties must be the same, and must not be larger than the maximum number of available vertex units for the platform, which can be retreived from [CC3OpenGLES11Engine engine].platform.maxVertexUnits.value.