|
|
RpSkinCreate creates an RpSkin which defines the skinning data for a RpGeometry. The skin can then be attached to the geometry with RpSkinGeometrySetSkin.
A skin maps a geometry's vertices to a set of bones that can be animated. The bones are defined by an RpHAnimHierarchy, and the animations are normally defined by an RtAnimAnimation.
The skin mapping can assign up to four "weights" per vertex to allow subtle blending between bones.
Skins use the RwMatrix structures of the RpHAnimHierarchy to define the initial bone transformations. - Parameters:
-
| numVertices |
The number of vertices in the skin. This be equal to the number of vertices in the geometry. |
| numBones |
The number of bones in the skin (the maximum number is platform specific). This is used to define the array of inverse bones matrices. |
| vertexWeights |
An array of weights, one per vertex. Each bone weight should be in the range 0.0f to 1.0f. The total weight for a vertex should always sum to 1.0f. Process of the weights will stop when the weight of a bone is 0.0f. The vertex indices must reflect any reordering of the weights. |
| vertexIndices |
A pointer to an array of bone indices, one per vertex. The 4 8-bit indices are packed into each RwUInt32 value, with the least significant mapping to w0 in the vertex weight array. |
| inverseMatrices |
A pointer to an array of RwMatrix's, one per bone. The matrices are often known as inverse bone matrices, and define the transformation from object-space (or skin-space) to bone-space for that bone. |
The inverse bone matrices are used to transform the vertices from their object-space into their bone-space. The key-frame based animation for the bone in the hierarchy then transforms the vertex position back into object-space in it's animated pose. The model is then rendered.
- Note:
-
A skin should be generated in exactly the same way for a RpPatchMesh. The number of vertices is replaced by the number of control points. Instead of attaching the skin to a geometry the skin is attached to the patch mesh with RpPatchMeshSetSkin.
- Returns:
-
Returns a pointer to the skin that is generated if successful, or NULL if there is an error.
- See also:
-
RpSkinDestroy
|