1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_Light.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 28419 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_GFX_LIGHT_H_ 17 #define NW_GFX_LIGHT_H_ 18 19 #include <nw/gfx/gfx_TransformNode.h> 20 #include <nw/gfx/res/gfx_ResLight.h> 21 22 namespace nw 23 { 24 namespace gfx 25 { 26 27 //--------------------------------------------------------------------------- 28 //! @brief ライトを表すクラスです。 29 //--------------------------------------------------------------------------- 30 class Light : public TransformNode 31 { 32 private: 33 NW_DISALLOW_COPY_AND_ASSIGN(Light); 34 35 public: 36 NW_UT_RUNTIME_TYPEINFO; 37 38 //! @brief 設定内容です。 39 struct Description : public TransformNode::Description 40 { 41 //! @brief コンストラクタです。 DescriptionDescription42 Description(){} 43 }; 44 45 46 //---------------------------------------- 47 //! @name シーンツリー 48 //@{ 49 50 //! @brief ビジターを受け付けます。 51 //! 52 //! @param[in] visitor ビジターです。 53 //! 54 virtual void Accept(ISceneVisitor* visitor); 55 56 //@} 57 58 //---------------------------------------- 59 //! @name アニメーション 60 //@{ 61 62 //! @brief アニメーショングループを取得します。 63 //! 64 //! ライトを DynamicBuilder で生成した場合は NULL を返します。 65 //! その場合、アニメーションは設定できません。 GetAnimGroup()66 AnimGroup* GetAnimGroup() { return m_AnimGroup; } 67 68 //! @brief アニメーショングループを取得します。 69 //! 70 //! ライトを DynamicBuilder で生成した場合は NULL を返します。 71 //! その場合、アニメーションは設定できません。 GetAnimGroup()72 const AnimGroup* GetAnimGroup() const { return m_AnimGroup; } 73 74 //! @brief アニメーションオブジェクトを取得します。 GetAnimObject()75 AnimObject* GetAnimObject() 76 { 77 NW_NULL_ASSERT(m_AnimBinding); 78 return m_AnimBinding->GetAnimObject(0); 79 } 80 81 //! @brief アニメーションオブジェクトを取得します。 GetAnimObject()82 const AnimObject* GetAnimObject() const 83 { 84 NW_NULL_ASSERT(m_AnimBinding); 85 return m_AnimBinding->GetAnimObject(0); 86 } 87 88 //! @brief アニメーションオブジェクトを設定します。 89 //! 90 //! @param[in] animObject 設定するアニメーションオブジェクトです。NULL を指定するとアニメーションを解除します。 SetAnimObject(AnimObject * animObject)91 void SetAnimObject(AnimObject* animObject) 92 { 93 NW_NULL_ASSERT(m_AnimBinding); 94 NW_FAILSAFE_IF(!ValidateLightAnimType(animObject)) 95 { 96 NW_LOG("type mismatch between Light and Animation. Animation did not set.\n"); 97 return; 98 } 99 m_AnimBinding->SetAnimObject(0, animObject); 100 } 101 102 //@} 103 104 protected: 105 //---------------------------------------- 106 //! @name コンストラクタ/デストラクタ 107 //@{ 108 109 //! コンストラクタです。 Light(os::IAllocator * allocator,ResTransformNode resObj,const Light::Description & description)110 Light( 111 os::IAllocator* allocator, 112 ResTransformNode resObj, 113 const Light::Description& description) 114 : TransformNode( 115 allocator, 116 resObj, 117 description), 118 m_OriginalValue(NULL), 119 m_AnimGroup(NULL) 120 {} 121 122 //! デストラクタです。 ~Light()123 virtual ~Light() 124 { 125 ut::SafeDestroy(m_AnimGroup); 126 } 127 128 //@} 129 130 //! @brief アニメーショングループを作成します。 131 Result CreateAnimGroup(os::IAllocator* allocator); 132 133 //! @brief アニメーションに登録するモデルデータのポインタを取得します。 134 void* GetAnimTargetObject(const anim::ResAnimGroupMember& anim); 135 136 //! @brief OriginalValueを破棄します。 137 void DestroyOriginalValue(); 138 139 // ValidateLightAnimTypeで使用します。 140 virtual u32 GetLightType() const = 0; //!< :private 141 virtual u32 GetLightKind() const = 0; //!< :private 142 143 ResLight m_OriginalValue; 144 math::Transform3 m_OriginalTransform; 145 146 private: 147 //! バインドするアニメーションのライト種類と、 148 //! インスタンスのライト種類が等しいかチェックします。 149 //! :private 150 bool ValidateLightAnimType(AnimObject* animObject); 151 152 AnimGroup* m_AnimGroup; 153 }; 154 155 } // namespace gfx 156 } // namespace nw 157 158 #endif // NW_GFX_LIGHT_H_ 159