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>Advanced Features</title>
8  </head>
9  <body>
10    <h1>Advanced Features</h1>
11    <h2 id="stereo">Standard Rendering and Stereo Rendering</h2>
12    <div class="section">
13        <p>
14        Commands can be re-used when performing stereo rendering.
15        </p>
16    <a href="images/Rendering.png"><img src="images/Rendering.png" border="0" alt="Rendering.png(122057 byte)" width="800" /></a>
17    <p>
18    Rendering is performed in the order given below in the case of standard rendering.
19    </p>
20    <ol>
21    <li>Camera configuration with <a href="../../nw/gfx/RenderContext/SetCameraMatrix.html">SetCameraMatrix</a></li>
22    <li>3D command creation with <a href="../../nw/gfx/MeshRenderer/RenderMesh.html">RenderMesh</a></li>
23    <li>Buffer transfer command configuration</li>
24    </ol>
25    <p>
26    In the case of stereo rendering, performance can be greatly improved compared to calling RenderMesh twice by re-using commands as follows to perform rendering.
27    </p>
28    <ol>
29    <li>
30      3D Command Generation Using <a href="../../nw/gfx/MeshRenderer/RenderMesh.html">RenderMesh</a><br /> As shown in the figure, lighting is influenced due to coordinate system conversion at this point.
31    </li>
32    <li>Save 3D command</li>
33    <li>Left-eye camera configuration with <a href="../../nw/gfx/RenderContext/SetCameraMatrix.html">SetCameraMatrix</a></li>
34    <li>Set access to saved 3D command</li>
35    <li>Buffer transfer command configuration</li>
36    <li>Right-eye camera configuration with <a href="../../nw/gfx/RenderContext/SetCameraMatrix.html">SetCameraMatrix</a></li>
37    <li>Set access to saved 3D command</li>
38    <li>Buffer transfer command configuration</li>
39    </ol>
40    </div>
41
42    <h2 id="callback">Interrupting Update and Rendering with Callbacks</h2>
43    <div class="section">
44    <p>
45    Callbacks can be called during the following processess.<br />
46    </p>
47    <img src="images/callback.png" />
48    <p>
49    There are two methods of implementing callbacks.
50    </p>
51    <ul>
52    <li>Create a function object inheriting <a href="../../nw/gfx/SceneNode/UpdateSignal.html">UpdateSignal</a> or other such class, and execute <a href="../../nw/ut/Signal2/Overview.html">Connect</a> for the signal obtained using <a href="../../nw/gfx/SceneNode/PreUpdateSignal.html">PreUpdateSignal</a> or other such function.</li>
53    <li>Pass a function pointer to <a href="../../nw/ut/Signal2/Overview.html">CreateAndConnect</a> for the signal obtained using <a href="../../nw/gfx/SceneNode/PreUpdateSignal.html">PreUpdateSignal</a> or other such function.</li>
54    </ul>
55    <p>
56    Specify the number of signals at time of creation using <a href="../../nw/gfx/Model/Overview.html">Model</a> or other such class.<br /> Specify the maximum number of callbacks using <a href="../../nw/gfx/SceneBuilder/MaxCallbacks.html">MaxCallbacks</a> of the <a href="../../nw/gfx/SceneBuilder/Overview.html">SceneBuilder class.</a> Or, automatically generate the signal when adding the callback by setting <a href="../../nw/gfx/SceneBuilder/IsFixedSizeMemory.html">IsFixedSizeMemory</a> to false.<br /> For details on RenderCommand, see <a href="../../nw/gfx/SceneBuilder/IsFixedSizeMemory.html">Interrupt Processing During Rendering</a>.
57    </p>
58    <p>The following are examples of setting a callbacks.</p>
59    <h3>Passing Arguments</h3>
60    <p>Functions such as those below can be set as callbacks (PreRenderSignal here).</p>
61    <pre>
62void PreRenderCallback(nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext)
63{
64    ....
65}
66    </pre>
67    <p>To set this function as a callback, create a slot and connect as given below.</p>
68<pre>
69model-&gt;PreRenderSignal().CreateAndConnect(PreRenderCallback);
70</pre>
71    <h3>Passing Function Objects</h3>
72    <p>Function objects such as those below can be set as callbacks (PreRenderSignal here).</p>
73    <pre>
74class RenderCallbackFunctor
75{
76public:
77    void operator () (nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext)
78    {
79        ....
80    }
81};
82    </pre>
83    <p>To set this function as a callback, create a slot and connect as given below.</p>
84<pre>
85model-&gt;PreRenderSignal().CreateAndConnect(RenderCallbackFunctor());
86</pre>
87    <h3>Passing a Slot</h3>
88    <p>A class that inherits a slot such as shown below can be set as a callback (PreRenderSignal here).</p>
89    <pre>
90class RenderCallbackSlot : public nw::gfx::Model::RenderSlot
91{
92public:
93    RenderCallbackSlot(nw::os::IAllocator* allocator)
94    : nw::gfx::Model::RenderSlot(allocator)
95    {
96    }
97    virtual void Invoke() (nw::gfx::Model* model, nw::gfx::ResMesh mesh, nw::gfx::RenderContext* renderContext)
98    {
99        ....
100    }
101};
102    </pre>
103    <p>To set this slot to a callback, connect as given below.</p>
104<pre>
105void* memory = allocator.Alloc(sizeof(RenderCallbackSlot));
106RenderCallbackSlot* slot = new(memory) RenderCallbackSlot(&amp;allocator);
107model-&gt;PreRenderSignal().Connect(slot);
108</pre>
109    <p>
110      The slot is automatically destroyed when the signal is destroyed by passing an allocator to the RenderSlot constructor. To prevent automatic destruction, pass NULL to the contructor.
111    </p>
112    </div>
113  <hr><p>CONFIDENTIAL</p></body>
114</html>
115