Instance Methods | Properties | List of all members
CC3Node(Skinning) Category Reference

#import <CC3VertexSkinning.h>

Instance Methods

(void) - bindRestPose
(void) - createSkinnedBoundingVolumes
(void) - ensureRigidSkeleton
(void) - reattachBonesFrom:
(void) - setSkeletalBoundingVolume:


BOOL hasSoftBodyContent
CC3Vector skeletalScale

Detailed Description

CC3Node extension to support ancestors and descendants that make use of vertex skinning.

Method Documentation

- (void) bindRestPose

Binds the rest pose of any skeletons contained within the descendants of this node.

This method must be invoked after the initial locations and rotations of each bone in the skeletons are set.

These initial bone orientations are those that align with the native structure of the vertices in the mesh, and collectively are known as the rest pose of the skeleton. Changes to the transform properties of the individual bone nodes, relative to the rest pose, will deform the mesh from its natural structure.

The bone transforms must be calculated locally from the perspective of the CC3SoftBodyNode that contains a skeleton and skin mesh. This method should only be invoked on the CC3SoftBodyNode or a structural ancestor of that node,

This implementation simply passes this invocation along to the children of this node. Subclasses contained in the soft-body node will add additional functionality.

Extends class CC3Node.

- (void) createSkinnedBoundingVolumes

Invokes the createBoundingVolume method on any skinned mesh node descendants.

Skinned mesh nodes are designed to move vertices under the control of external bone nodes. Because of this, the vertices might move well beyond the bounds of a static bounding volume created from the rest pose of the skinned mesh node. For this reason, bounding volumes are not generally automatically created for skinned mesh nodes by the createBoundingVolumes method, and the bounding volumes of skinned mesh nodes are typically created by the app, by determining the maximal extent that the vertices will move, and manually assigning a larger bounding volume to cover that full extent.

However, if you know that the vertices of the skinned mesh nodes descendants of this node will not move beyond the static bounding volume defined by the vertices in their rest poses, you can invoke this method to have bounding volumes created automatically from the rest poses of each descendant skinned mesh nodes. This method will not affect the bounding volumes of any non-skinned descendant nodes.

Extends class CC3Node.

- (void) ensureRigidSkeleton

Ensures the skeletal structures controlling any descendant skinned mesh nodes are composed of bones that undergo only rigid transforms, relative to their nearest ancestor soft-body node.

Typically, you invoke this method on the resource node, soft-body node, or other ancestor node that contains the animated skinned character model.

When the bones in a skeleton contain only rigid transforms, the vertices in the skinned mesh node can be transformed within a shader using rotations and transforms only, instead of requiring a full transform matrix. This allows for many more bones to be transferred to the shader program during a single GL draw call, which increases performance in many larger meshes.

Consequently, invoking this method affects the choice of shader that will be selected automatically for descendant skinned mesh nodes.

You must invoke this method in order to have such a shader automatically selected for each skinned mesh node, even if you know that all bones contain, and are animated by, only unit scales. Otherwise, automatic shader selection will select a shader that transforms vertices using bone transform matrices, instead. Alternately, if you know all bones contain, and are animated by, only unit scales, you can manually assign the appropriate shader program, and in that case, you do not need to invoke this method.

For each descendant bone node, this method sets the uniformScale property to 1.0, and invokes the disableScaleAnimation method to ensure that no changes will be made to the scale property during animation. You should invoke this method after all animation tracks have been added to the bone nodes, or anytime a new animation track is added.

After this method has been invoked, the hasRigidSkeleton properties of all descendant skinned mesh nodes will return YES.

Extends class CC3Node.

- (void) reattachBonesFrom: (CC3Node *)  aNode

After copying a skin mesh node, 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 skin mesh node copy should be controlled by a separate skeleton.

After creating a copy of the skeleton bone node assembly, you can use this method to attach the skin mesh node to the new skeleton. The node that is provided as the argument to this method is the root bone node of the skeleton, or a structural ancestor of the skeleton that does not also include the original skeleton as a descendant.

This method iterates through all the bones referenced by any descendant skin mesh nodes, and retrieves a bone with the same name from the structural descendants of the specified node.

When copying a CC3SoftBodyNode instance, this method is automatically invoked as part of the copying of the soft-body object, and you do not need to invoke this method directly.

Extends class CC3Node.

- (void) setSkeletalBoundingVolume: (CC3NodeBoundingVolume *)  boundingVolume

Mesh nodes whose vertices are deformable by bones are not automatically assigned a bounding volume, because the vertices are not completely under control of the mesh node, complicating the definition of the boundary.

Creating bounding volumes for skinned mesh nodes is left to the application.

If the bones are animated independently from the mesh node, it is possible that the bones will move the entire mesh far away from the mesh node. In this situation, it is better to have the bounding volume controlled by one of the root bones of the model, but still allow the skinned mesh nodes use this bounding volume to determine if the vertices are within the camera's field of view.

To do this, manually create a bounding volume of the right size and shape for the movement of the vertices from the perspective of a root bone of the skeleton. Assign the bounding volume to the root bone by using the boundingVolume property, and once it has been assigned to the skeleton, use this method on an ancestor node of all of the skinned mesh nodes that are to use that bounding volume, to assign that bounding volume to all of the appropriate skinned mesh nodes. A good choice to target for the invocation of this method might be the CC3SoftBodyNode of the model, or even the CC3ResourceNode above it, if loaded from a file.

During development, you can use the shouldDrawBoundingVolume property to make the bounding volume visible, to aid in determining and setting the right size and shape for it.

Extends class CC3Node.

Property Documentation

- (BOOL) hasSoftBodyContent

Returns whether this structural node contains any descendant nodes that are used for soft-body vertex skinning.

This would include nodes of type CC3SkinMeshNode or CC3Bone.

This property is a convenience used to identify nodes that should be grouped together structurally under a CC3SoftBodyNode.

Extends class CC3Node.

- (CC3Vector) skeletalScale

Returns the aggregate scale of this node relative to its closest soft-body ancestor.

Extends class CC3Node.

- (CC3SoftBodyNode*) softBodyNode

Returns the nearest structural ancestor node that is a soft-body node, or returns nil if no ancestor nodes are soft-body nodes.

Extends class CC3Node.

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