/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_HemiSphereLight.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 24209 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_HEMISPHERELIGHT_H_ #define NW_GFX_HEMISPHERELIGHT_H_ #include #include #include #include namespace nw { namespace gfx { //--------------------------------------------------------------------------- //! @brief 半球ライトを表すクラスです。 //--------------------------------------------------------------------------- class HemiSphereLight : public Light { private: NW_DISALLOW_COPY_AND_ASSIGN(HemiSphereLight); public: NW_UT_RUNTIME_TYPEINFO; //! @brief 設定内容です。 struct Description : public Light::Description { //! @brief コンストラクタです。 Description(){} }; //---------------------------------------- //! @name 作成/破棄 //@{ //! @brief 半球ライトを動的に構築するためのクラスです。 //! //! IsFixedSizeMemory の初期値は true です。false に変更すると、各種最大数の設定は無視されます。 class DynamicBuilder { public: //! コンストラクタです。 DynamicBuilder() {} //! デストラクタです。 ~DynamicBuilder() {} //! @brief 生成時以外にもメモリを確保するかどうかのフラグを設定します。 //! //! true を指定すると、生成時のみ固定サイズのメモリ確保を行います。 //! //! false を指定すると、生成時以外にも必要に応じて動的にメモリ確保が行われます。 DynamicBuilder& IsFixedSizeMemory(bool isFixedSizeMemory) { m_Description.isFixedSizeMemory = isFixedSizeMemory; return *this; } //! 子の最大数を設定します。 DynamicBuilder& MaxChildren(int maxChildren) { m_Description.maxChildren = maxChildren; return *this; } //! 管理できるコールバックの最大数を設定します。 DynamicBuilder& MaxCallbacks(int maxCallbacks) { m_Description.maxCallbacks = maxCallbacks; return *this; } //! @brief 半球ライトを生成します。 //! //! @param[in] allocator アロケータです。 //! //! @return 生成した半球ライトを返します。 //! HemiSphereLight* Create(os::IAllocator* allocator); private: HemiSphereLight::Description m_Description; }; //! @brief 半球ライトを生成します。 //! //! @param[in] parent 親のノードです。 //! @param[in] resource リソースです。 //! @param[in] description 設定内容です。 //! @param[in] allocator アロケータです。 //! //! @return 生成された半球ライトです。 //! static HemiSphereLight* Create( SceneNode* parent, ResSceneObject resource, const HemiSphereLight::Description& description, os::IAllocator* allocator); //@} //---------------------------------------- //! @name シーンツリー //@{ //! @brief ビジターを受け付けます。 //! //! @param[in] visitor ビジターです。 //! virtual void Accept(ISceneVisitor* visitor); //@} //---------------------------------------- //! @name リソース //@{ //! 半球ライトのリソースを取得します。 ResHemiSphereLight GetResHemiSphereLight() { return ResStaticCast(this->GetResSceneObject()); } //! 半球ライトのリソースを取得します。 const ResHemiSphereLight GetResHemiSphereLight() const { return ResStaticCast(this->GetResSceneObject()); } //@} protected: struct ResHemiSphereLightDataDestroyer : public std::unary_function { ResHemiSphereLightDataDestroyer(os::IAllocator* allocator = 0) : m_Allocator(allocator) {} result_type operator()(argument_type data) { DestroyResHemiSphereLight(m_Allocator, data); } os::IAllocator* m_Allocator; }; //! 動的生成したライトリソースを破棄するための MovePtr の定義です。 typedef ut::MovePtr ResPtr; //---------------------------------------- //! @name コンストラクタ/デストラクタ //@{ //! コンストラクタです。 HemiSphereLight( os::IAllocator* allocator, ResHemiSphereLight resObj, const HemiSphereLight::Description& description) : Light( allocator, resObj, description) {} //! コンストラクタです。 HemiSphereLight( os::IAllocator* allocator, ResPtr resource, const HemiSphereLight::Description& description) : Light( allocator, ResHemiSphereLight(resource.Get()), description), m_Resource(resource) {} //! デストラクタです。 virtual ~HemiSphereLight() { DestroyOriginalValue(); } //@} private: virtual Result Initialize(os::IAllocator* allocator); //--------------------------------------------------------------------------- //! @brief ResHemiSphereLightData のリソースを生成します。 //! //! @param[in] allocator リソース用のメモリを確保するアロケータです。 //! @param[in] name リソースにつける名前へのポインタです。名前が必要ない場合には NULL を指定してください。 //! //! @return ResHemiSphereLightData へのポインタです。 //--------------------------------------------------------------------------- static ResHemiSphereLightData* CreateResHemiSphereLight(os::IAllocator* allocator, const char* name = NULL); //--------------------------------------------------------------------------- //! @brief ResHemiSphereLightData のリソースを破棄します。 //! //! @param[in] resHemiSphereLight ResHemiSphereLightData へのポインタです。 //! @param[in] allocator リソース用のメモリを開放するアロケータです。 //--------------------------------------------------------------------------- static void DestroyResHemiSphereLight(os::IAllocator* allocator, ResHemiSphereLightData* resHemiSphereLight); //! アニメーションを初期状態に戻すため、初期化時の状態を保存します。 Result CreateOriginalValue(os::IAllocator* allocator); ResPtr m_Resource; }; } // namespace gfx } // namespace nw #endif // NW_GFX_HEMISPHERELIGHT_H_