v2.0.2
Instance Methods | Class Methods | Properties | List of all members
CC3SkinnedBone Class Reference

#import <CC3VertexSkinning.h>

Inheritance diagram for CC3SkinnedBone:
Inheritance graph
[legend]

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

CC3Bonebone
 
CC3SkinMeshNodeskinNode
 
CC3MatrixtransformMatrix
 

Detailed Description

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.

Method Documentation

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

Property Documentation

- (CC3Bone*) bone
readnonatomicassign

Returns the bone whose transforms are being tracked.

- (CC3SkinMeshNode*) skinNode
readnonatomicassign

Returns the skin mesh node whose transforms are being tracked.

- (CC3Matrix*) transformMatrix
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:

  • The transform matrix of the skin mesh node, relative to the soft-body node, as retrieved by invoking self.skinNode.skeletalTransformMatrix (Ms).
  • The inverse of that matrix, as retrieved by invoking self.skinNode.skeletalTransformMatrixInverted (Ms(-1)).
  • The transform matrix of the bone, relative to the soft-body node, as retrieved by invoking self.bone.skeletalTransformMatrix (Bs).
  • The inverse of that matrix, when the skeleton is in its rest pose, as retrieved by invoking self.bone.restPoseSkeletalTransformMatrixInverted (Bsrp(-1)).

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.


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