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>High-Speed Features</title> 8 </head> 9 <body> 10 <h1>High-Speed Features</h1> 11 12 <h2 id="full_baked">Use Fully Baked Skeletal Animations</h2> 13 <div class="section"> 14 <p> 15 Use fully baked skeletal animation data to reduce the processor load for animation evaluation compared to frame format.<br /> However, there are major functional limitations, and the data size is larger. 16 </p> 17 <p> 18 The fully baked format outputs the frame format data using the model coordinate system. (Frame format usually uses the bone coordinate system.)<br />The skeletal structure is calculated on binary output so the skeleton does not need updating at runtime, reducing the processing load. 19 </p> 20 <p> 21 Use this mode as follows. 22 </p> 23 <ol> 24 <li>Specify the <CODE>--use_full_baked_anim</CODE> option to the command-line version of CreativeStudio to output the data.</li> 25 <li>Use the <a href="../../../nw/gfx/SkeletalModel/SetFullBakedAnimEnabled.html"><CODE>SetFullBakedAnimEnabled</CODE></a> function to enable fully-baked output.</li> 26 <li>Bind the animation.</li> 27 </ol> 28 <p> 29 Use the <a href="../../../nw/anim/res/ResAnim/IsFullBakedAnim.html"><CODE>IsFullBakedAnim</CODE></a> function to check that the animation is fully baked. 30 </p> 31 <p> 32 Note that fully baked animations are subject to the following functional restrictions, and are only suited to simple playback. 33 </p> 34 <ul> 35 <li>No blending possible.</li> 36 <li> 37 Playback rate cannot be changed. 38 <ul> 39 <li>Doing so results in the evaluation of an even number of frames.</li> 40 </ul> 41 </li> 42 <li>Partial animations cannot be used.</li> 43 <li>Cannot use <a href="../../../nw/gfx/BaseAnimEvaluator/Reset.html"><CODE>Reset</CODE></a> on bound poses.</li> 44 <li> 45 Cannot change scaling rules at runtime. 46 <ul> 47 <li>Uses the settings described in a <CODE>.cskla</CODE> file.</li> 48 </ul> 49 </li> 50 </ul> 51 <p> 52 This outputs an animation of all bone and SRT elements, resulting in larger file sizes compared to regular frame format. 53 </p> 54 </div> 55 56 <h2 id="skeletal_anim_kind">Differences Between Types of Skeletal Animation</h2> 57 <div class="section"> 58 <p> 59 There are multiple skeletal animation formats.<br /> Each has different characteristics, making each better suited to specific uses. 60 </p> 61 <table> 62 <tbody> 63 <tr> 64 <th>Type</th> 65 <th>Animation Evaluation</th> 66 <th>Binary Size</th> 67 <th>Comments</th> 68 </tr> 69 <tr> 70 <td>Key Frame Animation</td> 71 <td> - </td> 72 <td> - </td> 73 <td>Key frame animation as the standard.</td> 74 </tr> 75 <tr> 76 <td>Frame-format Animation</td> 77 <td>High speed</td> 78 <td>Bigger file size</td> 79 <td>Playback may be choppy for low numbers of frames. See the <a href="../FAQ.html#koma_precision">FAQ</a> for details.</td> 80 </tr> 81 <tr> 82 <td>Fully Baked Animation</td> 83 <td>Faster still than frame format</td> 84 <td>Bigger file sizes than frame format</td> 85 <td>Various restrictions. See <a href="#full_baked">Fully Baked Format Description</a> for details.</td> 86 </tr> 87 </tbody> 88 </table> 89 </div> 90 91 <h2 id="multimodel_anim">Applying Animations to Multiple Models</h2> 92 <div class="section"> 93 <p> 94 Sharing skeletons when the bone configuration is the same and applying animations to shared skeletons can be very efficient. For details on sharing skeletons, see <a href="../Coordinate.html#shared_skeleton">Sharing skeletons</a>. After sharing, be sure to bind the animation to any one <a href="../../../nw/gfx/SkeletalModel/Overview.html">SkeletalModel</a>. 95 </p> 96 <p class="info"> 97 Information on how to do this when bone configurations differ is scheduled as a future addition. 98 </p> 99 </div> 100 101 <h2 id="anim_cache">Animation Result Cache</h2> 102 <div class="section"> 103 <p> 104 Use a cache to reduce the processing load when applying animation results to more than one model.<br /> Enable cache use setting true for <a href="../../../nw/gfx/AnimEvaluator/Builder/AllocCache.html"><CODE>AllocCache</CODE></a> using options available when creating <a href="../../../nw/gfx/AnimEvaluator/Overview.html"><CODE>AnimEvaluator</CODE></a>. 105 </p> 106 <p> 107 If the cache is enabled, call the <a href="../../../nw/gfx/AnimEvaluator/Builder/AllocCache.html"><CODE>GetResult</CODE></a> function to get cached results. Call the <a href="../../../nw/gfx/AnimEvaluator/UpdateCache.html"><CODE>UpdateCache</CODE></a> function to update the cache. 108 </p> 109 <p> 110 Note that enabling cache use entails some overhead due to an increase in memory copying.<br /> Be sure to disable cache use if it is not required, such as when there is only one model or when frame format data is being used. 111 </p> 112 </div> 113 114 <h2 id="partial_anim">Partial Animation</h2> 115 <div class="section"> 116 <p> 117 To configure separate animations, register multiple animations for a single model such that animated elements do not overlap.<BR> 118 </p> 119 <p> 120 For example, you can manage animations of the upper and lower body separately, or split the ambient color and diffuse color of a material into separate animations.<BR> 121 </p> 122 <p> 123 Implement this using code like the following. 124 </p> 125 <pre> 126// You can configure several animations when creating models from resources. 127nw::gfx::SceneBuilder builder; 128nw::gfx::SkeletalModel* model = 129 builder.Resource(resource) 130 .MaxAnimObjectPerGroup(2) // This line sets the maximum number of animations per model. 131 .CreateObject(&allocator, &deviceAllocator) 132 133// evaluator0 and evaluator1 represent the AnimEvaluator for the upper and lower body, respectively. 134// Set two animations for the model. 135model->SetSkeletalAnimObject(evaluator0, 0); 136model->SetSkeletalAnimObject(evaluator1, 1);</pre> 137 <p> 138 For details, see <a href="../demo/PartialAnimationDemo.html" target="_self"><CODE>PartialAnimationDemo</CODE></a>. 139 </p> 140 </div> 141 142 <h2 id="anim_interpolate_oldmethod">(Appendix) Changes to Behavior of AnimInterpolator Beginning from Version 1.0.1</h2> 143 <div class="section"> 144 <p> 145 In AnimInterpolator version 1.0.1 and earlier, members that are not animated are skipped during the blending process. Meanwhile, the current implementation uses the <CODE>OriginalValue</CODE> (the status when the model was loaded) in blend calculations for members without animations. Members without animations are also included when normalizing weights. 146 </p> 147 <p> 148 In version 1.01 and earlier, weights are normalized for all members every frame. The current implementation only does this when necessary in the aim of improving performance. 149 </p> 150 <pre> 151Upper body animation: A, B (neither includes lower body animation) 152Lower body animation: C, D (neither includes upper body animation)</pre> 153 <p> 154 Blending all four of these animations in version 1.01 or earlier would produce the ultimate result of blending A and B for the upper body and blending C and D for the lower body. (Note that this behavior can be restored in the current version by enabling <CODE>IgnoreNoAnimMember</CODE>.)<br /> To get similar results using the current implementation, blend A and B using one interpolator and blend C and D with a different interpolator. Register two <CODE>Interpolator</CODE> objects for target models when performing partial animations to achieve the same results as for previous versions. 155 </p> 156 157 <pre> 158// The following represents the above description in code form. 159 160AnimEvaluator* evaluator_lower_0; // Lower body animation:1 161AnimEvaluator* evaluator_lower_1; // Lower body animation: 2 162AnimEvaluator* evaluator_upper_0; // Upper body animation 1 163AnimEvaluator* evaluator_upper_1; // Upper Body Animation 2 164 165// Code in version 1.0.1 and earlier 166{ 167 AnimInterpolator* blender = AnimIntrerpolator::Builder() 168 .MaxAnimObjects(4) 169 .Create(&allocator); 170 171 blender->Bind(animGroup); 172 173 // In the old code, members that were not animated were skipped during blending, so... 174 // Animations for the upper and lower body are blended separately. 175 blender->AddAnimObject(evaluator_lower_0); 176 blender->AddAnimObject(evaluator_lower_1); 177 blender->AddAnimObject(evaluator_upper_0); 178 blender->AddAnimObject(evaluator_upper_1); 179 180 blender->SetWeight(0, 0.5f); 181 blender->SetWeight(1, 0.5f); 182 blender->SetWeight(2, 0.1f); 183 blender->SetWeight(3, 0.9f); 184 185 // Register AnimObject with the model. 186 model->SetSkeletalAnimObject(blender); 187} 188 189// Current code 190{ 191 // Members without animations are blended using OriginalValue in new code. 192 // Consequently, provide separate blenders for the upper and lower bodies. 193 AnimInterpolator* blender_lower = AnimInterpolator::Builder() 194 .MaxAnimObject(2) 195 .Create(&allocator); 196 AnimInterpolator* blender_upper = AnimInterpolator::Builder() 197 .MaxAnimObject(2) 198 .Create(&allocator); 199 200 blender_lower->AddAnimObject(evaluator_lower_0); 201 blender_lower->AddAnimObject(evaluator_lower_1); 202 203 blender_upper->AddAnimObject(evaluator_upper_0); 204 blender_upper->AddAnimObject(evaluator_upper_1); 205 206 blender_lower->SetWeight(0, 0.5f); 207 blender_lower->SetWeight(1, 0.5f); 208 209 blender_upper->SetWeight(0, 0.1f); 210 blender_upper->SetWeight(1, 0.9f); 211 212 // Set so that multiple AnimObject instances can be registered per model. 213 // Apply the blend results for the upper and lower body to each model using partial animation. 214 model->SetAnimObject(blender_lower, 0); 215 model->SetAnimObject(blender_upper, 1); 216}</pre> 217 </div> 218 <hr><p>CONFIDENTIAL</p></body> 219</html> 220