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>Graphics Library (gfx) Sample Demos</title>
8  </head>
9  <body>
10    <h1>ConstraintDemo</h1>
11      <div class="section"><img src="images/ConstraintDemo.png" border="0" width="400" height="240" /></div>
12      <h2>Overview</h2>
13      <p>
14        Demo for constraining nodes, such as emitters or lights, to the bones of a skeletal model.
15      </p>
16      <h2>How to Use</h2>
17      <p>
18        <ul>
19          <li>Demo-specific operations</li>
20          <ul>
21            <li>None.</li>
22          </ul>
23          <li>Common Operations</li>
24          <ul>
25            <li>Circle Pad: Rotate the camera</li>
26            <li>Circle Pad + A Button: Move the camera back and forth</li>
27            <li>Circle Pad + B Button: Translate the camera</li>
28            <li>Circle Pad + Y Button: Move the camera up and down</li>
29            <li>X Button: Reset the camera position</li>
30            <li>START Button: Restart the demo</li>
31          </ul>
32        </ul>
33      </p>
34      <h2>Description</h2>
35      <p>
36        To constrain a node to the bone of a skeletal model, you must set the world matrix for the bone as the world matrix of the node to be constrained. This can be done after scene update or by executing a callback.
37      </p>
38      <h3>Implementation after scene update</h3>
39      <p>
40        After it updates the world matrix of the nodes and/or skeletons in the scene, <a href="../../../nw/gfx/SceneUpdater/Overview.html">SceneUpdater</a> gets the world matrix from the bone to be constrained. Overwriting the world matrix of the node to be constrained with this one allows constraints on the bone.
41      </p>
42      <p>
43        Because the world matrix of the bone to be constrained is overwritten, code can be optimized by skipping world matrix calculations. World matrix calculations can be skipped by disabling <a href="../../../nw/gfx/CalculatedTransform/Flag.html">FLAG_IS_WORLDMATRIX_CALCULATION_ENABLED</a> using <a href="../../../nw/gfx/CalculatedTransform/DisableFlags.html">DisableFlags</a> of the <a href="../../../nw/gfx/TransformNode/Transform.html">Transform</a> member.
44      </p>
45      <p>
46        In this demo, constraints are applied in this way by two functions, SetupConstraint and ConstraintLight.
47      </p>
48      <h3>Implementation using a callback</h3>
49      <p>
50        Node constraints can be set even by setting a callback process for overwriting the world matrix in <a href="../../../nw/gfx/Skeleton/PostCalculateMatrixSignal.html">PostCalculateMatrixSignal</a> of the skeleton. A pointer to the skeleton and bone index are passed to the callback function. Target bones are determined based on this information and the world matrix is overwritten as described in the previous section if the bone is a target bone.
51      </p>
52      <p>
53        However, unlike the method described in the previous section, nodes may not be constrained correctly if the FLAG_IS_WORLDMATRIX_CALCULATION_ENABLED flag is not set appropriately. If the FLAG_IS_WORLDMATRIX_CALCULATION_ENABLED flag is left enabled and the node's world matrix is updated after the skeleton is updated, the world matrix written by the callback will be overwritten.
54      </p>
55      <p>
56        In this demo, the function SetupCallbackConstraint sets the callback.
57      </p>
58      <p>
59        Furthermore, you can use <a href="../../../nw/gfx/TransformNode/SetResourceBasedTransform.html">SetResourceBasedTransform</a> rather than overwriting the world matrix. This allows you to bind nodes while enabling transforms included in resources.
60      </p>
61  <hr><p>CONFIDENTIAL</p></body>
62</html>
63