1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_TransformAnimInterpolator.h 4 5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain proprietary 8 information of Nintendo and/or its licensed developers and are protected by 9 national and international copyright laws. They may not be disclosed to third 10 parties or copied or duplicated in any form, in whole or in part, without the 11 prior written consent of Nintendo. 12 13 The content herein is highly confidential and should be handled accordingly. 14 15 $Revision: 31311 $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_GFX_TRANSFORMANIMINTERPOLATOR_H_ 19 #define NW_GFX_TRANSFORMANIMINTERPOLATOR_H_ 20 21 #include <nw/gfx/gfx_AnimInterpolator.h> 22 23 namespace nw { 24 namespace gfx { 25 26 //--------------------------------------------------------------------------- 27 //! @brief トランスフォームアニメーション評価結果を補間ブレンドするクラスです。 28 //! 29 //! ブレンドは各メンバの移動・回転・スケール成分ごとに行われます。 30 //! 31 //! 動作の詳細は、 AnimInterpolator をご覧ください。 32 //--------------------------------------------------------------------------- 33 class TransformAnimInterpolator : public AnimInterpolator 34 { 35 public: 36 NW_UT_RUNTIME_TYPEINFO; 37 38 //---------------------------------------- 39 //! @name 作成 40 //@{ 41 42 //! @brief トランスフォームアニメーション補間を構築するクラスです。 43 //! 44 //! バージョン 1.0.1 以前の補間法に戻すためには、IsOldMethod か IgnoreNoAnimMember に true を指定してください。 45 //! 46 //! 1.0.1 以前の補間方法と現在の補間方法の違いの詳細については、アニメーションのドキュメント(高度な機能)を参照ください。 47 class Builder 48 { 49 public: 50 //! コンストラクタです。 Builder()51 Builder() 52 : m_MaxAnimObjects(2), 53 m_IgnoreNoAnimMember(false) {} 54 55 //! 最大アニメーションオブジェクト数を設定します。 MaxAnimObjects(int maxAnimObjects)56 Builder& MaxAnimObjects(int maxAnimObjects) 57 { 58 NW_ASSERT(maxAnimObjects > 0); 59 m_MaxAnimObjects = maxAnimObjects; 60 return *this; 61 } 62 63 //! @brief アニメーションが存在しないメンバを無視するかどうかを設定します。 64 //! 65 //! デフォルトでは、アニメーションが存在しないメンバはバインド時の値がブレンドされます。 66 //! IgnoreNoAnimMember に true を設定すると、 67 //! 重みの正規化がメンバ毎に行なわれ、アニメーションが存在しないメンバは重み 0 としてブレンドされます。 68 //! 69 //! この挙動は バージョン 1.0.1 以前の補間法と同じです。 70 //! IgnoreNoAnimMember(bool ignoreNoAnimMember)71 Builder& IgnoreNoAnimMember(bool ignoreNoAnimMember) { m_IgnoreNoAnimMember = ignoreNoAnimMember; return *this; } 72 73 //! @brief 生成時に必要なメモリサイズを取得します。 74 //! 75 //! メモリサイズは Builder の設定によって変化します。 76 //! すべての設定が終わった後にこの関数を呼び出してください。 77 //! 78 //! @param[in] alignment 計算に用いるアライメントです。2 のべき乗である必要があります。 79 size_t GetMemorySize(size_t alignment = os::IAllocator::DEFAULT_ALIGNMENT) const 80 { 81 os::MemorySizeCalculator size(alignment); 82 83 GetMemorySizeInternal(&size); 84 85 return size.GetSizeWithPadding(alignment); 86 } 87 88 //! @details :private GetMemorySizeInternal(os::MemorySizeCalculator * pSize)89 void GetMemorySizeInternal(os::MemorySizeCalculator* pSize) const 90 { 91 os::MemorySizeCalculator& size = *pSize; 92 93 size += sizeof(TransformAnimInterpolator); 94 TransformAnimInterpolator::GetMemorySizeForInitialize(pSize, m_MaxAnimObjects); 95 } 96 97 //! @brief トランスフォームアニメーション補間を生成します。 98 //! 99 //! @param[in] allocator アロケータです。 100 //! 101 //! @return 生成されたトランスフォームアニメーション補間です。 102 //! Create(os::IAllocator * allocator)103 TransformAnimInterpolator* Create(os::IAllocator* allocator) 104 { 105 void* buf = allocator->Alloc(sizeof(TransformAnimInterpolator)); 106 107 if (buf == NULL) 108 { 109 return NULL; 110 } 111 112 TransformAnimInterpolator* interpolator = new(buf) TransformAnimInterpolator(allocator); 113 114 Result result = interpolator->Initialize(m_MaxAnimObjects, m_IgnoreNoAnimMember); 115 NW_ASSERT(result.IsSuccess()); 116 117 return interpolator; 118 } 119 120 private: 121 int m_MaxAnimObjects; 122 bool m_IgnoreNoAnimMember; 123 }; 124 125 //@} 126 127 //---------------------------------------- 128 //! @name 評価 129 //@{ 130 131 //! @brief メンバ単位でアニメーション結果を取得します。 132 //! 133 //! @param[out] target アニメーション結果を書き込む対象です。 134 //! @param[in] memberIdx メンバインデックスです。 135 //! 136 //! @return アニメーション結果を適用した場合は NULL でない値を返します。 137 //! 138 virtual const anim::AnimResult* GetResult( 139 void* target, 140 int memberIdx) const; 141 142 //@} 143 144 protected: 145 //---------------------------------------- 146 //! @name コンストラクタ/デストラクタ 147 //@{ 148 149 //! コンストラクタです。 150 //! 151 //! :private TransformAnimInterpolator(os::IAllocator * allocator)152 TransformAnimInterpolator( 153 os::IAllocator* allocator) 154 : AnimInterpolator(allocator) 155 {} 156 157 //! デストラクタです。 158 //! 159 //! :private ~TransformAnimInterpolator()160 virtual ~TransformAnimInterpolator() {} 161 162 //@} 163 }; 164 165 } // namespace gfx 166 } // namespace nw 167 168 #endif // NW_GFX_TRANSFORMANIMINTERPOLATOR_H_ 169