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>Graphix Library (gfx) Sample Demos</title> 8 </head> 9 <body> 10 <h1><CODE>DynamicMaterialDemo</CODE></h1> 11 12 <div class="section"><img src="images/DynamicMaterialDemo1.png" border="0" width="400" height="240" /> <img src="images/DynamicMaterialDemo2.png" border="0" width="400" height="240" /></div> 13 14 <h2>Overview</h2> 15 <p> 16 This demo dynamically changes material settings.<BR> This demo can change four types of material settings.<BR> In order from top down, it can change materials, buffers, textures, and lookup tables. 17 </p> 18 19 <h2>How to Use</h2> 20 <p> 21 <ul> 22 <li>Demo-Specific Operations</li> 23 <ul> 24 <li>None.</li> 25 </ul> 26 <li>Common Operations</li> 27 <ul> 28 <li>Slide pad: Rotate the camera</li> 29 <li>Slide pad + A Button: Move the camera back and forth</li> 30 <li>Slide pad + B Button: Move the camera side to side</li> 31 <li>Slide pad + Y Button: Move the camera up and down</li> 32 <li>X Button: Reset the camera position</li> 33 <li>START Button: Restart the demo</li> 34 </ul> 35 </ul> 36 </p> 37 38 <h2>Description</h2> 39 <p> 40 This demo can change material settings.<BR> Each of the four methods of making changes will be described separately. 41 </p> 42 <h3>Changing Materials</h3> 43 <p> 44 In the past, separate material settings were applied without setting the material configured for the model.<BR> Run <CODE>StartMaterialChangeRenderCommand</CODE> before drawing a model whose material is to be changed. After rendering, run <CODE>EndMaterialChangeRenderCommand</CODE>. 45 </p> 46 <h3><CODE>StartMaterialChangeRenderCommand</CODE></h3> 47 <p> 48 Use the <a href="../../../nw/gfx/RenderContext/SetMaterial.html"><CODE>SetMaterial</CODE></a> function to set the material to swap. Set <a href="../../../nw/gfx/RenderContext/SetRenderMode.html"><CODE>SetRenderMode</CODE></a> to <CODE>RENDERMODE_IGNORE_MATERIAL</CODE> to not set the material of the model to be drawn is not set and to ignore the material settings. 49 </p> 50 <h3><CODE>EndMaterialChangeRenderCommand</CODE></h3> 51 <p> 52 This command restores the <CODE>RenderMode</CODE> changed by the <CODE>StartMaterialChangeRenderCommand</CODE> to its original state. Set <CODE>RENDERMODE_DEFAULT</CODE> to restore original status. 53 </p> 54 <h3>Changing by Buffer</h3> 55 <p> 56 Use the material buffer when changing material settings to change the material settings for each model instance.<BR> The demo changes the diffuse color of the material.<BR> To use the material buffer, use the model's <a href="../../../nw/gfx/Model/BufferOption.html"><CODE>BufferOption</CODE></a> to specify the options you want to use as the scene's <a href="../../../nw/gfx/SceneBuilder/BufferOption.html"><CODE>BufferOption</CODE></a>. 57 </p> 58 <h3>Changing Textures</h3> 59 <p> 60 To dynamically set textures, set <a href="../../../nw/gfx/res/ResTextureMapper/SetTexture.html"><CODE>SetTexture</CODE></a> to <a href="../../../nw/gfx/res/ResTexture/Overview.html"><CODE>ResTexture</CODE></a>. Ownership does not change even if you set <CODE>SetTexture</CODE>.<BR> After changing a texture, disable the hash by setting <CODE>SetTextureMappersHash</CODE> to <CODE>0</CODE>. 61 </p> 62 <h3>Changing the Lookup Table</h3> 63 <p> 64 To dynamically change lookup tables, set <a href="../../../nw/gfx/res/ResLightingLookupTable/SetSampler.html"><CODE>SetSampler</CODE></a> to <a href="../../../nw/gfx/res/ResLookupTable/Overview.html"><CODE>ResLookupTable</CODE></a>. Ownership does not change even if you set <CODE>SetSampler</CODE>.<BR> After changing a lookup table, disable the hash by setting <CODE>SetFragmentLightingTableHash</CODE> to <CODE>0</CODE>. 65 </p> 66 <hr><p>CONFIDENTIAL</p></body> 67</html> 68 69