Node and skeleton coordinate system

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

Node Coordinate System

node_to_model.png(78913 byte)

Calculations for TransformNode and its sub-classes are all performed using WORLD_COORDINATE.
With Model, 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)

In the case of WORLD_COORDINATE, SkeletalModel's WorldMatrix is applied to the bone's WorldMatrix using UpdateWorld of SkeletonUpdater.
As such, WORLD_COORDINATE is used for the WorldMatrix of all bones that can be obtained using WorldMatrixPose.
Because WORLD_COORDINATE is used as the WorldMatrix of bones, the WorldMatrix of bones input to UnivReg by the vertex shader are used as-is.

MODEL_COORDINATE

model_coordinate.png(72987 byte)

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

Sharing Skeletons

To share skeletons, they must be calculated using MODEL_COORDINATE.
To set MODEL_COORDINATE, specify ResSkeleton::FLAG_MODEL_COORDINATE using SetFlags. After creating SkeletalModel, to be used as the base, get the skeleton to be shared using GetSkeleton, and then pass it to SharedSkeleton of the SkeletalModel::Builder class. By creating SkeletalModel in this way, a new SkeletalModel can be created while the base SkeletalModel maintains ownership rights.
A SkeletalModel that shares skeletons can be rendered by performing updating and rendering as usual after creation.
For details on implementation, see MultiInstanceDemo.

Overwriting the World Matrix of Nodes or Bones

For details on how to re-write a node bone world matrix, see ConstraintDemo. Usually, the scene must be updated first before overwriting the world matrix of a node or bone.
However, calculation of the world matrix can be skipped by setting FLAG_IS_WORLDMATRIX_CALCULATION_ENABLED using DisableFlags on 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 differs depending on the coordinate system.
When using WORLD_COORDINATE, get the matrix using WorldMatrixPose::GetMatrix and configure a WORLD_COORDINATE matrix.
When using WORLD_COORDINATE, get the matrix using WorldMatrixPose::GetMatrix and configure a WORLD_COORDINATE matrix.
In addition, WorldTransform of SkeletalModel must similarly be overwritten when using MODEL_COORDINATE.

Handling Scaling

Accumulated scaling, including one's own nodes and bones is calculated 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