/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ParticleContext.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: 25276 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_PARTICLECONTEXT_H_ #define NW_GFX_PARTICLECONTEXT_H_ #include #include #include #include #include namespace nw { namespace gfx { //--------------------------------------------------------------------------- //! @brief パーティクルの更新時の内容を保持させるためのクラスです。 //--------------------------------------------------------------------------- class ParticleContext : public GfxObject { private: NW_DISALLOW_COPY_AND_ASSIGN(ParticleContext); public: //! VEC3の Array の定義です。 typedef ut::MoveArray VEC3Array; //! F32の Array の定義です。 typedef ut::MoveArray F32Array; //! U16の Array の定義です。 typedef ut::MoveArray U16Array; //---------------------------------------- //! @name 作成 //@{ //! シーンコンテキストクラスを構築するためのクラスです。 //! //! IsFixedSizeMemory の初期値は true です。false に変更すると、各種最大数の設定は無視されます。 class Builder { public: //! @brief コンストラクタです。 Builder() : m_IsFixedSizeMemory(true), m_MaxEmission(1000), m_MaxStreamLength(10000){} //! @brief 生成時以外にもメモリを確保するかどうかのフラグを設定します。 //! //! true を指定すると、生成時のみ固定サイズのメモリ確保を行います。 //! //! false を指定すると、生成時以外にも必要に応じて動的にメモリ確保が行われます。 Builder& IsFixedSizeMemory(bool isFixedSizeMemory) { m_IsFixedSizeMemory = isFixedSizeMemory; return *this; } //! @brief 放出量の最大数を設定します。 //! @param[in] maxEmission 放出量の最大数です。 //! @return ビルダーを返します。 Builder& MaxEmission(int maxEmission) { m_MaxEmission = maxEmission; return *this; } //! @brief ストリーム長の最大数を設定します。 //! @param[in] maxStreamLength ストリーム長の最大数です。 //! @return ビルダーを返します。 Builder& MaxStreamLength(int maxStreamLength) { m_MaxStreamLength = maxStreamLength; return *this; } //! @brief シーンコンテキストを構築します。 //! @param[in] allocator メモリのアロケータです。 //! @return シーンコンテキストを返します。 ParticleContext* Create(os::IAllocator* allocator); private: bool m_IsFixedSizeMemory; int m_MaxEmission; int m_MaxStreamLength; }; //@} //---------------------------------------- //! @name 取得/設定 //@{ //! @brief 放出時の位置のワークメモリの容量を取得します。 //! @return ワークメモリの容量を返します。 int GetEmissionWorkCapacity() const { return m_EmissionPositionWork.Capacity(); } //! @brief 放出時の位置のワークメモリを取得します。 //! @return 放出時の位置のワークメモリを返します。 VEC3Array::iterator GetEmissionPositionWork() { return m_EmissionPositionWork.Begin(); } //! @brief 放出時の親パーティクルのワークメモリを取得します。 //! @return 放出時の親パーティクルのワークメモリを返します。 U16Array::iterator GetEmissionParentWork() { return m_EmissionParentWork.Begin(); } //! @brief パーティクルのストリーム処理用のワークメモリを取得します。 //! @return パーティクルのストリーム処理用のワークメモリを返します。 F32Array::iterator GetParticleWorkF32() { return m_ParticleWorkF32.Begin(); } //! @brief 乱数種を設定します。 //! //! @param[in] seed 乱数種です。 void Srand(u32 seed) { m_ParticleRandom.Srand(seed); } //! @details :private u16 GetRandom() { return m_ParticleRandom.Next(0xffff); } //@} private: ParticleContext( os::IAllocator* allocator, VEC3Array emissionPositionWork, U16Array emissionParentWork, F32Array particleWorkF32) : GfxObject(allocator), m_EmissionPositionWork(emissionPositionWork), m_EmissionParentWork(emissionParentWork), m_ParticleWorkF32(particleWorkF32) {} virtual ~ParticleContext() {} VEC3Array m_EmissionPositionWork; U16Array m_EmissionParentWork; F32Array m_ParticleWorkF32; ParticleRandom m_ParticleRandom; }; } // namespace gfx } // namespace nw #endif // NW_GFX_PARTICLECONTEXT_H_