/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ResFog.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: 18106 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_RESFOG_H_ #define NW_GFX_RESFOG_H_ #include #include #include #include #include #include namespace nw { namespace gfx { namespace res { //! @details :private struct ResFogUpdaterData { nw::ut::ResS32 m_FogUpdaterType; nw::ut::ResF32 m_MinFogDepth; nw::ut::ResF32 m_MaxFogDepth; nw::ut::ResF32 m_Density; }; //! @details :private struct ResFogData : public ResTransformNodeData { enum Flag { FLAG_ZFLIP_ENABLED_SHIFT = ResTransformNode::FLAG_SHIFT_MAX, FLAG_ATTENUATE_DISTANCE_ENABLED_SHIFT, FLAG_SHIFT_MAX, FLAG_ZFLIP_ENABLED = 0x1 << FLAG_ZFLIP_ENABLED_SHIFT, FLAG_ATTENUATE_DISTANCE_ENABLED = 0x1 << FLAG_ATTENUATE_DISTANCE_ENABLED_SHIFT }; nw::ut::ResFloatColor m_Color; nw::ut::Offset toFogSampler; nw::ut::Offset toFogUpdater; }; //-------------------------------------------------------------------------- //! @brief フォグアップデータを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResFogUpdater : public nw::ut::ResCommon { public: //! @brief フォグアップデータの種類です。 enum FogUpdaterType { FOG_UPDATER_TYPE_NONE, //!< 使用しません。 FOG_UPDATER_TYPE_LINEAR, //!< 線形関数を利用したフォグです。 FOG_UPDATER_TYPE_EXPONENT, //!< 指数関数を利用したフォグです。 FOG_UPDATER_TYPE_EXPONENT_SQUARE //!< 二乗の指数関数を利用したフォグです。 }; NW_RES_CTOR( ResFogUpdater ) //--------------------------------------------------------------------------- //! @fn void SetMinFogDepth(f32 value) //! @brief フォグがかかり始める視点座標系におけるデプス値を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn void SetMaxFogDepth(f32 value) //! @brief フォグ濃度が最大になる視点座標系におけるデプス値を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn void SetFogUpdaterType(FogUpdaterType value) //! @brief フォグアップデータのタイプを設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn void SetDensity(f32 value) //! @brief フォグの濃度を調整するパラメータを設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn f32 GetMinFogDepth() const //! @brief フォグがかかり始める視点座標系におけるデプス値を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn f32 GetMaxFogDepth() const //! @brief フォグ濃度が最大になる視点座標系におけるデプス値を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn FogUpdaterType GetFogUpdaterType() const //! @brief フォグアップデータのタイプを取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn f32 GetDensity() const //! @brief フォグの濃度を調整するパラメータを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_PRIMITIVE_DECL( FogUpdaterType, FogUpdaterType ) NW_RES_FIELD_PRIMITIVE_DECL( f32, MinFogDepth ) NW_RES_FIELD_PRIMITIVE_DECL( f32, MaxFogDepth ) NW_RES_FIELD_PRIMITIVE_DECL( f32, Density ) }; //-------------------------------------------------------------------------- //! @brief フォグを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResFog : public ResTransformNode { public: enum { BINARY_REVISION = REVISION_RES_FOG }; enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResFog) }; enum { SIGNATURE = NW_RES_SIGNATURE32('CFOG') }; NW_RES_CTOR_INHERIT( ResFog, ResTransformNode ) //--------------------------------------------------------------------------- //! @fn void SetColor(f32 r, f32 g, f32 b) //! @brief フォグカラーを設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn const nw::ut::FloatColor & GetColor() const //! @brief フォグカラーを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_FLOAT_COLOR_DECL( nw::ut::FloatColor, Color ) // FloatColor& GetColor() //--------------------------------------------------------------------------- //! @fn ResImageLookupTable GetFogSampler() //! @brief フォグの参照テーブルを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_CLASS_DECL( ResImageLookupTable, FogSampler ) // GetFogSampler() //--------------------------------------------------------------------------- //! @fn ResFogUpdater GetFogUpdater() //! @brief フォグアップデータを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_CLASS_DECL( ResFogUpdater, FogUpdater ) // GetFogUpdater //--------------------------------------------------------------------------- //! @brief リビジョンを取得します。 //! //! @return リソースのリビジョン情報です。 //--------------------------------------------------------------------------- u32 GetRevision() const { return this->GetHeader().revision; } //--------------------------------------------------------------------------- //! @brief Zフリップフラグを取得します。 //! //! @return Zフリップフラグの値です。 //--------------------------------------------------------------------------- bool IsZFlip() const { return (ref().m_Flags & ResFogData::FLAG_ZFLIP_ENABLED) != 0; } //--------------------------------------------------------------------------- //! @brief Zフリップフラグを取得します。 //! //! @return Zフリップフラグの値です。 //--------------------------------------------------------------------------- bool IsAttenuateDistance() const { return (ref().m_Flags & ResFogData::FLAG_ATTENUATE_DISTANCE_ENABLED) != 0; } //--------------------------------------------------------------------------- //! @brief リソースのセットアップをおこないます。 //! //! @param[in] allocator アロケータです。 //! @param[in] graphicsFile グラフィックスリソースです。 //--------------------------------------------------------------------------- Result Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile); //--------------------------------------------------------------------------- //! @brief リソースの後始末をおこないます。 //--------------------------------------------------------------------------- void Cleanup(); }; typedef nw::ut::ResArrayPatricia::type ResFogArray; } // namespace res } // namespace gfx } // namespace nw #endif // NW_GFX_RESFOG_H_