/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ParticleUtil.h Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. 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. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_PARTICLE_UTIL_H_ #define NW_GFX_PARTICLE_UTIL_H_ #include #include #include #include namespace nw { namespace gfx { class SceneNode; class ParticleContext; namespace res { class ResParticleInitializer; struct ResParticleInitializerData; class ResParticleUpdater; struct ResParticleUpdaterData; } // namespace res //-------------------------------------------------------------------------- //! @brief パーティクルの各種ユーティリティです。 //--------------------------------------------------------------------------- class ParticleUtil { public: //! @brief パーティクルのオブジェクトの初期設定を行います。 //! 内部でResolveParticleObjectを呼びます。 //! //! @param[in] sceneNodeArray シーンノードのアレイです。 static void SetupParticleObject( ut::MoveArray* sceneNodeArray, ParticleContext* context); //! @brief パーティクルのオブジェクトの参照を解決します。 //! //! @param[in] sceneNodeArray シーンノードのアレイです。 static void ResolveParticleObject(ut::MoveArray* sceneNodeArray); //! @details :private static ResParticleInitializerData* DuplicateResParticleInitializer( const ResParticleInitializer* src, os::IAllocator* allocator); //! @details :private static void GetMemorySizeForDuplicateResParticleInitializerInternal( os::MemorySizeCalculator* pSize, const ResParticleInitializer* src); //! @details :private static ResParticleUpdaterData* DuplicateResParticleUpdater( const ResParticleUpdater* src, os::IAllocator* allocator); //! @details :private static void GetMemorySizeForDuplicateResParticleUpdaterInternal( os::MemorySizeCalculator* pSize, const ResParticleUpdater* src); }; //! @brief パーティクルセットの依存関係でソートするための関数オブジェクトです。 struct ParticleSetCompare : public std::binary_function { //! @brief パーティクルセットの依存関係でソートするための比較関数です。 //! @param[in] lhs 左辺値です。 //! @param[in] rhs 右辺値です。 //! @return 比較結果を返します。 bool operator() ( const ParticleSet* lhs, const ParticleSet* rhs); }; //--------------------------------------------------------------------------- //! @brief パーティクルのVBOフラッシュを設定する関数オブジェクトです。 //--------------------------------------------------------------------------- class ParticleSetIsBufferFlushEnabledSetter { public: //! @brief コンストラクタです //! @param[in] flat 設定するフラッシュの有無のフラグです。 ParticleSetIsBufferFlushEnabledSetter(bool flag) : m_Flag(flag) {} //! @brief ResModelを引数とするオペレータです //! @param[in] resModel 対象のResParticleModelです。 void operator()(ResModel resModel) const { ResParticleModel resParticleModel = ResDynamicCast(resModel); if (resParticleModel.IsValid()) { resParticleModel.ForeachParticleSet(ParticleSetIsBufferFlushEnabledSetter(m_Flag)); } } //! @brief ResParticleModelを引数とするオペレータです //! @param[in] resParticleModel 対象のResParticleModelです。 void operator()(ResParticleModel resParticleModel) const { if (resParticleModel.IsValid()) { resParticleModel.ForeachParticleSet(ParticleSetIsBufferFlushEnabledSetter(m_Flag)); } } //! @brief ResParticleSetを引数とするオペレータです //! @param[in] resParticleSet 対象のResParticleSetです。 void operator()(ResParticleSet resParticleSet) const { resParticleSet.SetIsBufferFlushEnabled(m_Flag); } private: bool m_Flag; }; } // namespace gfx } // namespace nw #endif // NW_GFX_PARTICLE_UTIL_H_