#import <CC3VertexSkinning.h>
Instance Methods | |
(id) | - initWithSkin:onBone: |
(void) | - markTransformDirty |
Instance Methods inherited from <CC3NodeTransformListenerProtocol> | |
(void) | - nodeWasTransformed: |
Instance Methods inherited from <CC3NodeListenerProtocol> | |
(void) | - nodeWasDestroyed: |
Instance Methods inherited from <CC3Object> | |
(id) | - asWeakReference |
(NSString *) | - fullDescription |
(id) | - resolveWeakReference |
Class Methods | |
(id) | + skinnedBoneWithSkin:onBone: |
Properties | |
CC3Bone * | bone |
CC3SkinMeshNode * | skinNode |
CC3Matrix * | transformMatrix |
CC3SkinnedBone combines the transforms of a bone and a skin mesh node, and applies these transforms to deform the vertices during rendering, or when the deformed location of a vertex is accessed programmatically.
An instance keeps track of two related transform matrices, a transformMatrix, which is used by the GL engine to deform the vertices during drawing, and a skinTransformMatrix, which is used to deform a vertex into the local coordinate system of the skin mesh node, so that it can be used programmatically.
The CC3SkinnedBone instance registers as a transform listener with both the bone and the skin mesh node, and lazily recalculates the transformMatrix and skinTransformMatrix whenever the transform of either the bone or the skin mesh node changes.
- (id) initWithSkin: | (CC3SkinMeshNode *) | aNode | |
onBone: | (CC3Bone *) | aBone | |
Initializes this instance to apply the specified bone to the specified skin mesh node.
- (void) markTransformDirty |
Marks the transform matrix as dirty.
Once marked as dirty, the matrix will be lazily recalculated the next time the transformMatrix property is accessed.
This method is invoked automatically when the transform of either the bone or the skin mesh node being tracked by this instance is transformed. The application should never need to invoke this method directly.
+ (id) skinnedBoneWithSkin: | (CC3SkinMeshNode *) | aNode | |
onBone: | (CC3Bone *) | aBone | |
Allocates and initializes an instance to apply the specified bone to the specified skin mesh node.
|
readnonatomicassign |
Returns the bone whose transforms are being tracked.
|
readnonatomicassign |
Returns the skin mesh node whose transforms are being tracked.
|
readnonatomicretain |
Returns the transform matrix used to draw the deformed vertices during mesh rendering.
This transform matrix combines the transform of the bone, the rest pose of the bone, and the rest pose of the skin mesh node.
This transform matrix is lazily recomputed the first time this property is accessed after the transform is marked dirty via the markTransformDirty method. This occurs automatically when either the bone or the skin mesh node being tracked by this instance is transformed.
The matrix in this property (T) is derived from a combination of:
as follows, with * representing matrix multiplication:
T = Ms(-1) * Bs * Bsrp(-1) * Ms
Reading this equation right to left, we can see that when used on a vertex in the skin mesh node, this has the effect of transforming the vertex: 1) From skin-mesh-space to soft-body-space. 2) From soft-body-space to the joint-space of the bone in its rest-pose. 3) From joint-space back to soft-body-space using the transform of the bone in its current pose. 4) From soft-body-space back to the skin-mesh-space.
These steps are performed because the soft-body node represents the common root of the skin mesh nodes and the bones in the skeleton.