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 <h2 id="multimodel_anim">Applying Animations to Multiple Models</h2> 12 <div class="section"> 13 <p> 14 Sharing skeletons when the bone configuration is the same, and applying animations to shared skeletons can be very effecient. 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>. 15 </p> 16 <p class="info"> 17 Information on how to do this when bone configurations differ is scheduled as a future addition. 18 </p> 19 </div> 20 <h2 id="anim_cache">Animation Result Cache</h2> 21 <div class="section"> 22 <p> 23 Using a cache can reduce the processing load when applying animation results to more than one model.<br /> Use of a cache can be enabled by setting true for </a>AllocCache using options available4 when creating <a href="../../../nw/gfx/AnimEvaluator/Overview.html">AnimEvaluator<a href="../../../nw/gfx/AnimEvaluator/Builder/AllocCache.html">. 24 </p> 25 <p> 26 If the cache is enabled, cached results can be returned by <a href="../../../nw/gfx/AnimEvaluator/Builder/AllocCache.html">GetResult</a>. To update the cache, call <a href="../../../nw/gfx/AnimEvaluator/UpdateCache.html">UpdateCache</a>. 27 </p> 28 <p> 29 Note that some overhead occurs because memory copies increase if the cache is enabled.<br /> Be sure to disable use of the cache if it is not required, such as when there is only one model or frame format data is being used. 30 </p> 31 </div> 32 <h2 id="partial_anim">Partial Animation</h2> 33 <div class="section"> 34 <p> 35 Separate animations can be configured by registering multiple animations for a single model so that elements to be animated do not overlap.<BR> 36 </p> 37 <p> 38 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> 39 </p> 40 <p> 41 This can be implented using code like the following. 42 </p> 43 <pre> 44// You can configure several animations when creating models from resources. 45nw::gfx::SceneBuilder builder; 46nw::gfx::SkeletalModel* model = 47 builder.Resource(resource) 48 .MaxAnimObjectPerGroup(2) // This line sets the maximum number of animations per model. 49 .CreateObject(&allocator, &deviceAllocator) 50// evaluator0 and evaluator1 represent the AnimEvaluator for the upper and lower body, respectively. 51// Set two animations for the model. 52model->SetSkeletalAnimObject(evaluator0, 0); 53model->SetSkeletalAnimObject(evaluator1, 1);</pre> 54 <p> 55 For details, see <a href="../demo/PartialAnimationDemo.html" target="_self">PartialAnimationDemo</a>. 56 </p> 57 </div> 58 59 <h2 id="anim_interpolate_oldmethod">(Appendix) Changes to Behavior of AnimInterpolator Beginning from Version 1.0.1</h2> 60 <div class="section"> 61 <p> 62 Under AnimInterpolator version 1.0.1 and earlier, members that were not to be animated were skipped during the blending process. On the other hand, under the current implementation, OriginalValue (status when the model was loaded) is used in blend calculations for members without animations. Members without animations are also included when normalizing weights. 63 </p> 64 <p> 65 In the case of the implementation used in version 1.0.1 and earlier, weights are normalized for all members every frame. We hope for improved performance because now the operation is performed only when necessary. 66 </p> 67 <pre> 68Upper body animation: A, B (neither includes lower body animation) 69Lower body animation: C, D (neither includes upper body animation)</pre> 70 <p> 71 If we were to blend four animations of this type, under the method using in version 1.0.1 and earlier the ultimate result is the blending A and B for the upper body and the blending of C and D for the lower body. (Note that old behavior can be restored by enabling IsOldMethod or IgnoreNoAnimMember.) If you want to get results such as in the past using the current implementation, blend A and B using one interpolator and blend C and D with a different interpolator. The same results as previous versions can be obtained by registering two Interpolators for target models when performing partial animations. 72 </p> 73 <p> 74 The IsOldMethod option is scheduled for abolishment in 1.3.0. To perform equivalent blending, use the <a href="../../../nw/gfx/AnimInterpolator/Builder/IgnoreNoAnimMember.html">IgnoreNoAnimMember</a> option. 75 </p> 76 77 <pre> 78// The following represents the above description expressed in code form. 79AnimEvaluator* evaluator_lower_0; // Lower body animation:1 80AnimEvaluator* evaluator_lower_1; // Lower body animation: 2 81AnimEvaluator* evaluator_upper_0; // Upper body animation 1 82AnimEvaluator* evaluator_upper_1; // Upper Body Animation 2 83// Code in 1.0.1 and earlier 84{ 85 AnimInterpolator* blender = AnimIntrerpolator::Builder() 86 .MaxAnimObjects(4) 87 .Create(&allocator); 88 89 blender->Bind(animGroup); 90 91 // In the old code, membes that were not animated were skipped during blending, so 92 // Animations for the upper and lower body are blended separately. 93 blender->AddAnimObject(evaluator_lower_0); 94 blender->AddAnimObject(evaluator_lower_1); 95 blender->AddAnimObject(evaluator_upper_0); 96 blender->AddAnimObject(evaluator_upper_1); 97 98 blender->SetWeight(0, 0.5f); 99 blender->SetWeight(1, 0.5f); 100 blender->SetWeight(2, 0.1f); 101 blender->SetWeight(3, 0.9f); 102 103 // Register AnimObject with the model. 104 model->SetSkeletalAnimObject(blender); 105} 106// Current code 107{ 108 // Because members without animations are blended using OriginalValue in new code, 109 // provide separate blenders for the upper and lower bodies. 110 AnimInterpolator* blender_lower = AnimInterpolator::Builder() 111 .MaxAnimObject(2) 112 .Create(&allocator); 113 AnimInterpolator* blender_upper = AnimInterpolator::Builder() 114 .MaxAnimObject(2) 115 .Create(&allocator); 116 117 blender_lower->AddAnimObject(evaluator_lower_0); 118 blender_lower->AddAnimObject(evaluator_lower_1); 119 120 blender_upper->AddAnimObject(evaluator_upper_0); 121 blender_upper->AddAnimObject(evaluator_upper_1); 122 123 blender_lower->SetWeight(0, 0.5f); 124 blender_lower->SetWeight(1, 0.5f); 125 126 blender_upper->SetWeight(0, 0.1f); 127 blender_upper->SetWeight(1, 0.9f); 128 129 // Set so that multiple AnimObject instances can be reigstered per model. 130 // Apply the blend results for the upper and lower body to each model using partial animation. 131 model->SetAnimObject(blender_lower, 0); 132 model->SetAnimObject(blender_upper, 1); 133}</pre> 134 </div> 135 <hr><p>CONFIDENTIAL</p></body> 136</html> 137