1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_AnimOverrider.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_ANIMOVERRIDER_H_ 19 #define NW_GFX_ANIMOVERRIDER_H_ 20 21 #include <nw/gfx/gfx_AnimBlender.h> 22 #include <nw/ut/ut_RuntimeTypeInfo.h> 23 24 namespace nw { 25 namespace gfx { 26 27 //--------------------------------------------------------------------------- 28 //! @brief 汎用アニメーション評価結果を上書きブレンドするクラスです。 29 //! 30 //! AddAnimObject() で登録された順番にアニメーションオブジェクトを評価します。 31 //! 同じメンバに複数のアニメーションがあった場合、後に登録されたアニメーションの結果で上書きされます。 32 //! アニメーションを持っていないメンバについては、上書き処理は行われません。 33 //--------------------------------------------------------------------------- 34 class AnimOverrider : public AnimBlender 35 { 36 public: 37 NW_UT_RUNTIME_TYPEINFO; 38 39 //---------------------------------------- 40 //! @name 作成 41 //@{ 42 43 //! 汎用アニメーション上書きを構築するクラスです。 44 class Builder 45 { 46 public: 47 //! コンストラクタです。 Builder()48 Builder() 49 : m_MaxAnimObjects(2) {} 50 51 //! 最大アニメーションオブジェクト数を設定します。 MaxAnimObjects(int maxAnimObjects)52 Builder& MaxAnimObjects(int maxAnimObjects) 53 { 54 NW_ASSERT(maxAnimObjects > 0); 55 m_MaxAnimObjects = maxAnimObjects; 56 return *this; 57 } 58 59 //! @brief 生成時に必要なメモリサイズを取得します。 60 //! 61 //! メモリサイズは Builder の設定によって変化します。 62 //! すべての設定が終わった後にこの関数を呼び出してください。 63 //! 64 //! @param[in] alignment 計算に用いるアライメントです。2 のべき乗である必要があります。 65 size_t GetMemorySize(size_t alignment = os::IAllocator::DEFAULT_ALIGNMENT) const 66 { 67 os::MemorySizeCalculator size(alignment); 68 69 GetMemorySizeInternal(&size); 70 71 return size.GetSizeWithPadding(alignment); 72 } 73 74 //! @details :private GetMemorySizeInternal(os::MemorySizeCalculator * pSize)75 void GetMemorySizeInternal(os::MemorySizeCalculator* pSize) const 76 { 77 os::MemorySizeCalculator& size = *pSize; 78 79 size += sizeof(AnimOverrider); 80 AnimOverrider::GetMemorySizeForInitialize(pSize, m_MaxAnimObjects); 81 } 82 83 //! @brief 汎用アニメーション上書きを生成します。 84 //! 85 //! @param[in] allocator アロケータです。 86 //! 87 //! @return 生成された汎用アニメーション上書きです。 88 //! Create(os::IAllocator * allocator)89 AnimOverrider* Create(os::IAllocator* allocator) 90 { 91 void* buf = allocator->Alloc(sizeof(AnimOverrider)); 92 93 if (buf == NULL) 94 { 95 return NULL; 96 } 97 98 AnimOverrider* animOverrider = new(buf) AnimOverrider(allocator); 99 100 Result result = animOverrider->Initialize(m_MaxAnimObjects); 101 NW_ASSERT(result.IsSuccess()); 102 103 return animOverrider; 104 } 105 106 private: 107 int m_MaxAnimObjects; 108 }; 109 110 //@} 111 112 //---------------------------------------- 113 //! @name 評価 114 //@{ 115 116 //! @brief メンバ単位でアニメーション結果を取得します。 117 //! 118 //! @param[out] target アニメーション結果を書き込む対象です。 119 //! @param[in] memberIdx メンバインデックスです。 120 //! 121 //! @return アニメーション結果を返します。 122 //! ブレンドオペレーションを使用する場合は、返り値のアニメーション結果を使用してください。 123 //! 124 virtual const anim::AnimResult* GetResult( 125 void* target, 126 int memberIdx) const; 127 128 //@} 129 130 protected: 131 //---------------------------------------- 132 //! @name コンストラクタ/デストラクタ 133 //@{ 134 135 //! コンストラクタです。 136 //! 137 //! :private AnimOverrider(os::IAllocator * allocator)138 AnimOverrider( 139 os::IAllocator* allocator) 140 : AnimBlender(allocator) 141 {} 142 143 //! デストラクタです。 144 //! 145 //! :private ~AnimOverrider()146 virtual ~AnimOverrider() {} 147 148 //@} 149 }; 150 151 } // namespace gfx 152 } // namespace nw 153 154 #endif // NW_GFX_ANIMOVERRIDER_H_ 155