1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
2<html xml:lang="en-US" lang="en-US">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../css/document.css" type="text/css" />
7    <title>Node and Skeleton Coordinate System</title>
8  </head>
9  <body>
10    <h1>Node and Skeleton Coordinate System</h1>
11    <div class="section">
12    In NW4C, the world coordinate system (<CODE>WORLD_COORDINATE</CODE>) and model coordinate system both exist in the matrix coordinate system.<br /> Calculations are usually made using <CODE>WORLD_COORDINATE</CODE>. However, <CODE>MODEL_COORDINATE</CODE> can be used when sharing animations among more than one model. <br /> To set <CODE>MODEL_COORDINATE</CODE>, use <CODE>SetFlags</CODE> to specify <CODE>ResSkeleton::FLAG_MODEL_COORDINATE</CODE>.
13    </div>
14    <h2>Node Coordinate System</h2>
15    <img src="images/node_to_model.png" border="0" alt="node_to_model.png(78913 byte)" width="397" height="516" />
16    <p class="info">
17    All calculations for <a href="../../nw/gfx/TransformNode/Overview.html"><CODE>TransformNode</CODE></a> and its sub-classes use <CODE>WORLD_COORDINATE</CODE>.<br /> With <a href="../../nw/gfx/Model/Overview.html"><CODE>Model</CODE></a> objects, <a href="../../nw/gfx/Model/Overview.html"><CODE>WorldMatrix</CODE></a> is input to <CODE>UnivReg</CODE> of the vertex shader and applied to vertices.</a> Meanwhile, with <a href="../../nw/gfx/SkeletalModel/Overview.html"><CODE>SkeletalModel</CODE></a>, vertex shader processing differs depending on the coordinate system.<br />
18    </p>
19    <h2>Skeleton Coordinate System</h2>
20    <h3>WORLD_COORDINATE</h3>
21    <img src="images/world_coordinate.png" border="0" alt="world_coordinate.png(64514 byte)" width="398" height="439" />
22    <p class="info">
23    For <CODE>WORLD_COORDINATE</CODE>, the <a href="../../nw/gfx/SkeletalModel/Overview.html"><CODE>SkeletalModel</CODE></a>'s <a href="../../nw/gfx/TransformNode/WorldMatrix.html"><CODE>WorldMatrix</CODE></a> is applied to the bone's <CODE>WorldMatrix</CODE> using the <a href="../../nw/gfx/SkeletonUpdater/UpdateWorld.html"><CODE>UpdateWorld</CODE></a> function of the <a href="../../nw/gfx/SkeletonUpdater/Overview.html"><CODE>SkeletonUpdater</CODE></a> object.<br /> <CODE>WORLD_COORDINATE</CODE> is thus used for the <CODE>WorldMatrix</CODE> of all bones that can be obtained using the <a href="../../nw/gfx/Skeleton/WorldMatrixPose.html"><CODE>WorldMatrixPose</CODE></a> function.<br /> Because <CODE>WORLD_COORDINATE</CODE> is used as the <CODE>WorldMatrix</CODE> for bones, the <CODE>WorldMatrix</CODE> objects for bones input to <CODE>UnivReg</CODE> by the vertex shader are used as-is.
24    </p>
25    <h3>MODEL_COORDINATE</h3>
26    <img src="images/model_coordinate.png" border="0" alt="model_coordinate.png(72987 byte)" width="398" height="439" />
27    <p class="info">
28    For <CODE>MODEL_COORDINATE</CODE>, the model coordinate system is used for the <CODE>WorldMatrix</CODE> for bones when calculating using the <a href="../../nw/gfx/SkeletonUpdater/UpdateWorld.html"><CODE>UpdateWorld</CODE></a> function.<br /> The model coordinate system is used for transforms from the root bone.<br /> Because the <CODE>WorldMatrix</CODE> for bones uses <CODE>MODEL_COORDINATE</CODE>, the <a href="../../nw/gfx/TransformNode/WorldMatrix.html"><CODE>WorldMatrix</CODE></a> of the <a href="../../nw/gfx/SkeletalModel/Overview.html"><CODE>SkeletalModel</CODE></a> is applied to the <CODE>WorldMatrix</CODE> for bones input to <CODE>UnivReg</CODE> by the vertex shader.<br />
29    </p>
30    <h2 id="shared_skeleton">Sharing Skeletons</h2>
31    <div class="section">
32    To share skeletons, they must be calculated using <CODE>MODEL_COORDINATE</CODE>.<br /> To set <CODE>MODEL_COORDINATE</CODE>, use <CODE>SetFlags</CODE> to specify <CODE>ResSkeleton::FLAG_MODEL_COORDINATE</CODE>. After creating a <a href="../../nw/gfx/SkeletalModel/Overview.html"><CODE>SkeletalModel</CODE></a> to use as the base, get the skeleton to share using the <a href="../../nw/gfx/SkeletalModel/GetSkeleton.html"><CODE>GetSkeleton</CODE></a> function, and then pass it to the <a href="../../nw/gfx/SkeletalModel/Builder/SharedSkeleton.html"><CODE>SharedSkeleton</CODE></a> of <a href="../../nw/gfx/SkeletalModel/Builder/Overview.html"><CODE>SkeletalModel::Builder</CODE></a>. By creating a <CODE>SkeletalModel</CODE> in this way, you can create a new <CODE>SkeletalModel</CODE> while the base <CODE>SkeletalModel</CODE> maintains ownership rights.<br />
33    <p class="info">
34    When sharing skeletons, you must render the base <CODE>SkeletalModel</CODE> used for sharing. If you will not render the base skeleton used for sharing, use the <a href="../../nw/gfx/SkeletalModel/SwapSkeleton.html"><CODE>SwapSkeleton</CODE></a> function to transfer ownership rights to another <CODE>SkeletonModel</CODE>.
35    </p>
36    You can render a <CODE>SkeletalModel</CODE> that shares skeletons by updating and rendering as usual after creation.<br /> See <a href="demo/MultiInstanceDemo.html"><CODE>MultiInstanceDemo</CODE></a> for implementation details.<br />
37    </div>
38    <h2 id="world_matrix">Overwriting the World Matrix of Nodes or Bones</h2>
39    <div class="section">
40    See <a href="demo/ConstraintDemo.html"><CODE>ConstraintDemo</CODE></a> 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.<br /> However, you can skip calculation of the world matrix by using the <a href="../../nw/gfx/CalculatedTransform/DisableFlags.html"><CODE>DisableFlags</CODE></a> function to set <CODE>FLAG_IS_WORLDMATRIX_CALCULATION_ENABLED</CODE> on the <a href="../../nw/gfx/CalculatedTransform/Overview.html"><CODE>CalculatedTransform</CODE></a> obtained using either <a href="../../nw/gfx/TransformNode/WorldTransform.html"><CODE>WorldTransform</CODE></a> or <a href="../../nw/gfx/Skeleton/WorldTransformPose.html"><CODE>WorldTransformPose</CODE></a>.<br /> To overwrite the world matrix of <a href="../../nw/gfx/TransformNode/Overview.html"><CODE>TransformNode</CODE></a>, set a <CODE>WORLD_COORDINATE</CODE> matrix for <a href="../../nw/gfx/TransformNode/WorldMatrix.html"><CODE>TransformNode::WorldMatrix</CODE></a>. Note that the method used to overwrite the world matrix of a bone depends on the coordinate system. <br /> When using <CODE>WORLD_COORDINATE</CODE>, get the matrix using <CODE><a href="../../nw/gfx/Skeleton/WorldMatrixPose.html">WorldMatrixPose</a>::<a href="../../nw/gfx/Skeleton/MatrixPose/GetMatrix.html">GetMatrix</a></CODE> and configure a <CODE>WORLD_COORDINATE</CODE> matrix.<br /> When using <CODE>MODEL_COORDINATE</CODE>, get the matrix using <CODE><a href="../../nw/gfx/Skeleton/WorldMatrixPose.html">WorldMatrixPose</a>::<a href="../../nw/gfx/Skeleton/MatrixPose/GetMatrix.html">GetMatrix</a></CODE> and configure the matrix from the root bone.<br /> When using <CODE>MODEL_COORDINATE</CODE>, you must also overwrite the <a href="../../nw/gfx/SkeletalModel/Overview.html"><CODE>SkeletalModel</CODE></a>'s <a href="../../nw/gfx/TransformNode/WorldTransform.html"><CODE>WorldTransform</CODE></a>.<br />
41    </div>
42    <h2 id="node_bone_scale">Handling Scaling</h2>
43    <div class="section">
44    The library calculates accumulated scaling, including for one's own nodes and bones, when the world matrix is updated by <CODE>SkeletonUpdater</CODE>. The scale given by <a href="../../nw/gfx/TransformNode/Transform.html"><CODE>Transform</CODE></a> and <a href="../../nw/gfx/Skeleton/LocalTransformPose.html"><CODE>LocalTransformPose</CODE></a> is for one's own nodes and bones, while the scale given by <a href="../../nw/gfx/TransformNode/WorldTransform.html"><CODE>WorldTransform</CODE></a> and <a href="../../nw/gfx/TransformNode/WorldTransform.html"><CODE>WorldTransformPose</CODE></a> is an accumulation of scaling factors from the root node to one's own node.
45    </div>
46  <hr><p>CONFIDENTIAL</p></body>
47</html>