/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ResParticleUpdater.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: 19592 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_RESPARTICLEUPDATER_H_ #define NW_GFX_RESPARTICLEUPDATER_H_ #include #include #include #include #include #include #include #include //#define NW_GFX_PARTICLE_4KEY namespace nw { namespace gfx { class ParticleContext; class ParticleSet; namespace res { //--------------------------------------------------------------------------- //! @brief パーティクルストリームの使用種別の定義です。 //--------------------------------------------------------------------------- enum ParticleUsage { PARTICLEUSAGE_TRANSLATE = 0, //!< トランスレートです。 PARTICLEUSAGE_SCALE, //!< スケールです。 PARTICLEUSAGE_ROTATE, //!< ローテートです。 PARTICLEUSAGE_COLOR, //!< RGBカラーです。 PARTICLEUSAGE_ALPHA, //!< アルファです。 PARTICLEUSAGE_TEXTURETRANSLATE0, //!< テクスチャ座標のトランスレートです。 PARTICLEUSAGE_TEXTURESCALE0, //!< テクスチャ座標のスケールです。 PARTICLEUSAGE_TEXTUREROTATE0, //!< テクスチャ座標のローテートです。 PARTICLEUSAGE_SCALE_EXT, //!< スケール(拡張)です。 PARTICLEUSAGE_ID, //!< パーティクルIDです。 PARTICLEUSAGE_BIRTH, //!< 生成した時刻です。 PARTICLEUSAGE_LIFE, //!< 寿命です。 PARTICLEUSAGE_VELOCITY, //!< 速度です。 PARTICLEUSAGE_ACTIVEINDEX, //!< 使用中の要素への間接参照インデックスです。 PARTICLEUSAGE_FREEINDEX, //!< 使用可能な要素への間接参照インデックスです。 #ifdef NW_GFX_PARTICLE_COMPAT_1_1 PARTICLEUSAGE_NEG_TIMELIMIT, //!< 消滅する時刻の負数(高速化のため)です。 #endif PARTICLEUSAGE_COUNT, //!< 種別の個数です。 PARTICLEUSAGE_IS_INT = INT_MAX }; //! @details :private struct ResParticleUpdaterData { nw::ut::ResTypeInfo typeInfo; nw::ut::ResBool m_IsResourceCopyEnabled; nw::ut::ResBool m_UpdaterEnabled; u8 padding_0[2]; nw::ut::ResS32 m_TargetStream; nw::ut::Offset toParticleAnimation; }; //-------------------------------------------------------------------------- //! @brief パーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleUpdater : public nw::ut::ResCommon< ResParticleUpdaterData > { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('PUPD') }; NW_RES_CTOR( ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( bool, IsResourceCopyEnabled ) NW_RES_FIELD_PRIMITIVE_DECL( bool, UpdaterEnabled) NW_RES_FIELD_PRIMITIVE_DECL( ParticleUsage, TargetStream ) NW_RES_FIELD_CLASS_DECL( ResParticleAnimation, ParticleAnimation ) //--------------------------------------------------------------------------- //! @brief インスタンスの型情報を取得します。 //! //! @return 型情報です。 //--------------------------------------------------------------------------- nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } NW_DEPRECATED_FUNCTION(s32 GetTargetStreamsCount() const) { if (this->GetTargetStream() < 0) { return 0; } return 1; } NW_DEPRECATED_FUNCTION(ParticleUsage* GetTargetStreams()) { return (ParticleUsage*)&ref().m_TargetStream; } NW_DEPRECATED_FUNCTION(const ParticleUsage* GetTargetStreams() const) { return (const ParticleUsage*)&ref().m_TargetStream; } }; //! @details :private struct ResParticleAccelarationUpdaterData : public ResParticleUpdaterData { nw::ut::ResF32 m_Factor; }; //-------------------------------------------------------------------------- //! @brief f32を乗算で更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleAccelarationUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleAccelarationUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('ACCE') }; NW_RES_CTOR_INHERIT( ResParticleAccelarationUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Factor ) // GetFactor(), SetFactor() }; //! @details :private struct ResParticleFloatUpdaterData : public ResParticleUpdaterData { nw::ut::ResF32 m_DefaultValue; }; //-------------------------------------------------------------------------- //! @brief f32を更新するパーティクルアップデータを表すバイナリリソースクラスです(基底クラス)。 //-------------------------------------------------------------------------- class ResParticleFloatUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleFloatUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('FLOA') }; NW_RES_CTOR_INHERIT( ResParticleFloatUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( f32, DefaultValue ) }; //! @details :private struct ResParticleFloatImmediateUpdaterData : public ResParticleFloatUpdaterData { }; //-------------------------------------------------------------------------- //! @brief f32を即値で更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleFloatImmediateUpdater : public ResParticleFloatUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleFloatImmediateUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('FIMM') }; NW_RES_CTOR_INHERIT( ResParticleFloatImmediateUpdater, ResParticleFloatUpdater ) }; #ifdef NW_GFX_PARTICLE_4KEY //! @details :private struct ResParticleFloatImmediate4KeyUpdaterData : public ResParticleUpdaterData { nw::ut::ResU32 m_InTime; nw::ut::ResU32 m_OutTime; nw::ut::ResF32 m_Value0; nw::ut::ResF32 m_Value1; nw::ut::ResF32 m_Value2; nw::ut::ResF32 m_Value3; }; //-------------------------------------------------------------------------- //! @brief f32を4キーの即値で更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleFloatImmediate4KeyUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleFloatImmediate4KeyUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('FIM4') }; NW_RES_CTOR_INHERIT( ResParticleFloatImmediate4KeyUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( u32, InTime ) NW_RES_FIELD_PRIMITIVE_DECL( u32, OutTime ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Value0 ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Value1 ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Value2 ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Value3 ) }; #endif //! @details :private struct ResParticleGeneralUpdaterData : public ResParticleUpdaterData { }; //-------------------------------------------------------------------------- //! @brief 位置・速度を更新するパーティクルジェネラアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleGeneralUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleGeneralUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('GENE') }; NW_RES_CTOR_INHERIT( ResParticleGeneralUpdater, ResParticleUpdater ) }; //! @details :private struct ResParticleGravityUpdaterData : public ResParticleUpdaterData { nw::ut::ResF32 m_Power; nw::ut::ResVec3 m_Direction; }; //-------------------------------------------------------------------------- //! @brief 重力のパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleGravityUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleGravityUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('GRAV') }; NW_RES_CTOR_INHERIT( ResParticleGravityUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Power ) // GetPower(), SetPower() NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Direction ) // GetDirection() }; //! @details :private struct ResParticleSpinUpdaterData : public ResParticleUpdaterData { nw::ut::ResF32 m_Power; nw::ut::ResVec3 m_Axis; }; //-------------------------------------------------------------------------- //! @brief スピンのパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleSpinUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleSpinUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('SPIN') }; NW_RES_CTOR_INHERIT( ResParticleSpinUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Power ) // GetPower(), SetPower() NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Axis ) // GetAxis() }; //! @details :private struct ResParticleRandomUpdaterData : public ResParticleUpdaterData { nw::ut::ResVec3 m_Power; nw::ut::ResS32 m_Interval; }; //-------------------------------------------------------------------------- //! @brief Vector3をランダム付きで更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleRandomUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleRandomUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('RNDU') }; NW_RES_CTOR_INHERIT( ResParticleRandomUpdater, ResParticleUpdater ) NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, Power ) // GetPower() NW_RES_FIELD_PRIMITIVE_DECL( s32, Interval ) // GetInterval(), SetInterval() }; //! @details :private struct ResParticleVector2ImmediateUpdaterData : public ResParticleUpdaterData { nw::ut::ResVec2 m_DefaultValue; }; //-------------------------------------------------------------------------- //! @brief Vector2を即値で更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleVector2ImmediateUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleVector2ImmediateUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('V2IM') }; NW_RES_CTOR_INHERIT( ResParticleVector2ImmediateUpdater, ResParticleUpdater ) NW_RES_FIELD_VECTOR2_DECL( nw::math::VEC2, DefaultValue ) }; //! @details :private struct ResParticleVector3UpdaterData : public ResParticleUpdaterData { nw::ut::ResVec3 m_DefaultValue; }; //-------------------------------------------------------------------------- //! @brief Vector3を更新するパーティクルアップデータを表すバイナリリソースクラスです(基底クラス)。 //-------------------------------------------------------------------------- class ResParticleVector3Updater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleVector3Updater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('VEC3') }; NW_RES_CTOR_INHERIT( ResParticleVector3Updater, ResParticleUpdater ) NW_RES_FIELD_VECTOR3_DECL( nw::math::VEC3, DefaultValue ) }; //! @details :private struct ResParticleVector3AdditiveUpdaterData : public ResParticleVector3UpdaterData { }; //-------------------------------------------------------------------------- //! @brief Vector3を加算で更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleVector3AdditiveUpdater : public ResParticleVector3Updater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleVector3AdditiveUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('V3AD') }; NW_RES_CTOR_INHERIT( ResParticleVector3AdditiveUpdater, ResParticleVector3Updater ) }; //! @details :private struct ResParticleVector3ImmediateUpdaterData : public ResParticleVector3UpdaterData { }; //-------------------------------------------------------------------------- //! @brief Vector3を即値で更新するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleVector3ImmediateUpdater : public ResParticleVector3Updater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleVector3ImmediateUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('V3IM') }; NW_RES_CTOR_INHERIT( ResParticleVector3ImmediateUpdater, ResParticleVector3Updater ) }; //! @details :private struct ResParticleVector3RandomAdditiveUpdaterData : public ResParticleVector3UpdaterData { }; //-------------------------------------------------------------------------- //! @brief Vector3ランダム加算付きパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleVector3RandomAdditiveUpdater : public ResParticleVector3Updater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleVector3RandomAdditiveUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('V3RA') }; NW_RES_CTOR_INHERIT( ResParticleVector3RandomAdditiveUpdater, ResParticleVector3Updater ) }; //! @details :private struct ResParticleRotateUpVectorUpdaterData : public ResParticleUpdaterData { nw::ut::ResU32 m_Source; }; //-------------------------------------------------------------------------- //! @brief アップベクトル方向へ回転するパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleRotateUpVectorUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleRotateUpVectorUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('RUVU') }; enum ParticleRotateUpVectorSource { SOURCE_VELOCITY = 0, SOURCE_DISTANCE }; NW_RES_CTOR_INHERIT( ResParticleRotateUpVectorUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( ParticleRotateUpVectorSource, Source ) }; //! テクスチャの分割数の定義です。 enum ParticleTexturePatternUpdaterDivisionType { Division1 = 1, Division2 = 2, Division4 = 4, Division8 = 8, Division16 = 16 }; //! @details :private struct ResParticleTexturePatternUpdaterData : public ResParticleUpdaterData { nw::ut::ResU32 m_DivisionX; nw::ut::ResU32 m_DivisionY; nw::ut::ResS32 m_TextureIndex; }; //-------------------------------------------------------------------------- //! @brief テクスチャパターンパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleTexturePatternUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleTexturePatternUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('TPAT') }; NW_RES_CTOR_INHERIT( ResParticleTexturePatternUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( ParticleTexturePatternUpdaterDivisionType, DivisionX ) NW_RES_FIELD_PRIMITIVE_DECL( ParticleTexturePatternUpdaterDivisionType, DivisionY ) NW_RES_FIELD_PRIMITIVE_DECL( u32, TextureIndex ) }; //! @details :private struct ResParticleChildUpdaterOptionData { nw::ut::ResTypeInfo typeInfo; }; //-------------------------------------------------------------------------- //! @brief パーティクルチャイルドアップデータのオプションを表すバイナリリソースクラスです(基底クラス)。 //-------------------------------------------------------------------------- class ResParticleChildUpdaterOption : public nw::ut::ResCommon< ResParticleChildUpdaterOptionData > { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleChildUpdaterOption) }; enum { SIGNATURE = NW_RES_SIGNATURE32('COPT') }; NW_RES_CTOR( ResParticleChildUpdaterOption ) //--------------------------------------------------------------------------- //! @brief インスタンスの型情報を取得します。 //! //! @return 型情報です。 //--------------------------------------------------------------------------- nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } #ifdef NW_GFX_PARTICLE_COMPAT_1_1 bool CheckTiming(ParticleTime birth, ParticleTime life, ParticleTime limit, ParticleTime prevTime, ParticleTime currentTime); #else bool CheckTiming(ParticleTime birth, ParticleTime life, ParticleTime prevTime, ParticleTime currentTime); #endif }; //! @details :private struct ResParticleChildUpdaterFirstUpdateOptionData : public ResParticleChildUpdaterOptionData { }; //-------------------------------------------------------------------------- //! @brief パーティクルチャイルドで、親の生成時を表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleChildUpdaterFirstUpdateOption : public ResParticleChildUpdaterOption { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleChildUpdaterFirstUpdateOption) }; enum { SIGNATURE = NW_RES_SIGNATURE32('COBU') }; NW_RES_CTOR_INHERIT( ResParticleChildUpdaterFirstUpdateOption, ResParticleChildUpdaterOption ) }; //! @details :private struct ResParticleChildUpdaterFinalUpdateOptionData : public ResParticleChildUpdaterOptionData { }; //-------------------------------------------------------------------------- //! @brief パーティクルチャイルドで、親の消滅時を表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleChildUpdaterFinalUpdateOption : public ResParticleChildUpdaterOption { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleChildUpdaterFinalUpdateOption) }; enum { SIGNATURE = NW_RES_SIGNATURE32('COFU') }; NW_RES_CTOR_INHERIT( ResParticleChildUpdaterFinalUpdateOption, ResParticleChildUpdaterOption ) }; //! @details :private struct ResParticleChildUpdaterIntervalOptionData : public ResParticleChildUpdaterOptionData { nw::ut::ResF32 m_Start; nw::ut::ResF32 m_End; nw::ut::ResS32 m_Interval; }; //-------------------------------------------------------------------------- //! @brief パーティクルチャイルドで、寿命の割合で間隔を表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleChildUpdaterIntervalOption : public ResParticleChildUpdaterOption { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleChildUpdaterIntervalOption) }; enum { SIGNATURE = NW_RES_SIGNATURE32('COIN') }; NW_RES_CTOR_INHERIT( ResParticleChildUpdaterIntervalOption, ResParticleChildUpdaterOption ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Start ) NW_RES_FIELD_PRIMITIVE_DECL( f32, End ) NW_RES_FIELD_PRIMITIVE_DECL( s32, Interval ) }; //! @details :private struct ResParticleChildUpdaterFrameOptionData : public ResParticleChildUpdaterOptionData { nw::ut::ResS32 m_Start; nw::ut::ResS32 m_End; nw::ut::ResS32 m_Interval; }; //-------------------------------------------------------------------------- //! @brief パーティクルチャイルド、フレームで間隔を表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleChildUpdaterFrameOption : public ResParticleChildUpdaterOption { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleChildUpdaterFrameOption) }; enum { SIGNATURE = NW_RES_SIGNATURE32('COFN') }; NW_RES_CTOR_INHERIT( ResParticleChildUpdaterFrameOption, ResParticleChildUpdaterOption ) NW_RES_FIELD_PRIMITIVE_DECL( s32, Start ) NW_RES_FIELD_PRIMITIVE_DECL( s32, End ) NW_RES_FIELD_PRIMITIVE_DECL( s32, Interval ) }; //! @details :private struct ResParticleChildUpdaterData : public ResParticleUpdaterData { nw::ut::BinString toParticleSetPath; nw::ut::Offset toParticleForm; nw::ut::Offset toTiming; nw::ut::ResS32 m_EmissionRatio; }; //-------------------------------------------------------------------------- //! @brief パーティクルチャイルドアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleChildUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleChildUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('CHLD') }; NW_RES_CTOR_INHERIT( ResParticleChildUpdater, ResParticleUpdater ) NW_RES_FIELD_STRING_DECL( ParticleSetPath ) // GetParticleSetPath() NW_RES_FIELD_CLASS_DECL( ResParticleForm, ParticleForm) // GetParticleForm() NW_RES_FIELD_CLASS_DECL( ResParticleChildUpdaterOption, Timing) // GetTiming() NW_RES_FIELD_PRIMITIVE_DECL( s32, EmissionRatio ) // GetEmissionRatio() }; //! @details :private struct ResParticleUserUpdaterData : public ResParticleUpdaterData { nw::ut::ResU32 m_UserParameter; }; //-------------------------------------------------------------------------- //! @brief ユーザー定義のパーティクルアップデータを表すバイナリリソースクラスです。 //-------------------------------------------------------------------------- class ResParticleUserUpdater : public ResParticleUpdater { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResParticleUserUpdater) }; enum { SIGNATURE = NW_RES_SIGNATURE32('USER') }; typedef void (*UserFunctionType)( ParticleContext*, ParticleSet*, const ResParticleUserUpdater*, f32, f32 ); NW_RES_CTOR_INHERIT( ResParticleUserUpdater, ResParticleUpdater ) NW_RES_FIELD_PRIMITIVE_DECL( u32, UserParameter ) // GetUserParameter() }; } // namespace res } // namespace gfx } // namespace nw #endif // NW_GFX_RESPARTICLEUPDATER_H_