Node and Skeleton Coordinate System

In NW4C, the world coordinate system (WORLD_COORDINATE) and model coordinate system both exist in the matrix coordinate system.
Calculations are usually made using WORLD_COORDINATE. However, MODEL_COORDINATE can be used when sharing animations among more than one model.
To set MODEL_COORDINATE, use SetFlags to specify ResSkeleton::FLAG_MODEL_COORDINATE.

Node Coordinate System

node_to_model.png(78913 byte)

All calculations for TransformNode and its sub-classes use WORLD_COORDINATE.
With Model objects, WorldMatrix is input to UnivReg of the vertex shader and applied to vertices. Meanwhile, with SkeletalModel, vertex shader processing differs depending on the coordinate system.

Skeleton Coordinate System

WORLD_COORDINATE

world_coordinate.png(64514 byte)

For WORLD_COORDINATE, the SkeletalModel's WorldMatrix is applied to the bone's WorldMatrix using the UpdateWorld function of the SkeletonUpdater object.
WORLD_COORDINATE is thus used for the WorldMatrix of all bones that can be obtained using the WorldMatrixPose function.
Because WORLD_COORDINATE is used as the WorldMatrix for bones, the WorldMatrix objects for bones input to UnivReg by the vertex shader are used as-is.

MODEL_COORDINATE

model_coordinate.png(72987 byte)

For MODEL_COORDINATE, the model coordinate system is used for the WorldMatrix for bones when calculating using the UpdateWorld function.
The model coordinate system is used for transforms from the root bone.
Because the WorldMatrix for bones uses MODEL_COORDINATE, the WorldMatrix of the SkeletalModel is applied to the WorldMatrix for bones input to UnivReg by the vertex shader.

Sharing Skeletons

To share skeletons, they must be calculated using MODEL_COORDINATE.
To set MODEL_COORDINATE, use SetFlags to specify ResSkeleton::FLAG_MODEL_COORDINATE. After creating a SkeletalModel to use as the base, get the skeleton to share using the GetSkeleton function, and then pass it to the SharedSkeleton of SkeletalModel::Builder. By creating a SkeletalModel in this way, you can create a new SkeletalModel while the base SkeletalModel maintains ownership rights.

When sharing skeletons, you must render the base SkeletalModel used for sharing. If you will not render the base skeleton used for sharing, use the SwapSkeleton function to transfer ownership rights to another SkeletonModel.

You can render a SkeletalModel that shares skeletons by updating and rendering as usual after creation.
See MultiInstanceDemo for implementation details.

Overwriting the World Matrix of Nodes or Bones

See ConstraintDemo for details on how to rewrite a node bone world matrix. You must usually update the scene first before overwriting the world matrix of a node or bone.
However, you can skip calculation of the world matrix by using the DisableFlags function to set FLAG_IS_WORLDMATRIX_CALCULATION_ENABLED on the CalculatedTransform obtained using either WorldTransform or WorldTransformPose.
To overwrite the world matrix of TransformNode, set a WORLD_COORDINATE matrix for TransformNode::WorldMatrix. Note that the method used to overwrite the world matrix of a bone depends on the coordinate system.
When using WORLD_COORDINATE, get the matrix using WorldMatrixPose::GetMatrix and configure a WORLD_COORDINATE matrix.
When using MODEL_COORDINATE, get the matrix using WorldMatrixPose::GetMatrix and configure the matrix from the root bone.
When using MODEL_COORDINATE, you must also overwrite the SkeletalModel's WorldTransform.

Handling Scaling

The library calculates accumulated scaling, including for one's own nodes and bones, when the world matrix is updated by SkeletonUpdater. The scale given by Transform and LocalTransformPose is for one's own nodes and bones, while the scale given by WorldTransform and WorldTransformPose is an accumulation of scaling factors from the root node to one's own node.

CONFIDENTIAL