/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ResSceneObject.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: 17337 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_RESSCENEOBJECT_H_ #define NW_GFX_RESSCENEOBJECT_H_ #include #include #include #include #include #include #include #include namespace nw { namespace gfx { namespace res { //! @details :private struct ResSceneObjectData { nw::ut::ResTypeInfo typeInfo; nw::ut::BinaryRevisionHeader m_Header; nw::ut::BinString toName; nw::ut::ResS32 m_UserDataDicCount; nw::ut::Offset toUserDataDic; }; //! @details :private struct ResSceneNodeData : public ResSceneObjectData { enum Flag { FLAG_IS_BRANCH_VISIBLE_SHIFT = 0, FLAG_SHIFT_MAX, FLAG_IS_BRANCH_VISIBLE = 0x1 << FLAG_IS_BRANCH_VISIBLE_SHIFT }; nw::ut::ResU32 m_Flags; nw::ut::ResBool m_IsBranchVisible; u8 padding_0[3]; nw::ut::ResS32 m_ChildrenTableCount; nw::ut::Offset toChildrenTable; nw::ut::ResS32 m_AnimGroupsDicCount; nw::ut::Offset toAnimGroupsDic; }; //! @details :private struct ResTransformNodeData : public ResSceneNodeData { nw::ut::ResTransform3 m_Transform; nw::ut::ResMtx34 m_LocalMatrix; nw::ut::ResMtx34 m_WorldMatrix; }; //-------------------------------------------------------------------------- //! @brief シーンオブジェクトを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResSceneObject : public nw::ut::ResCommon< ResSceneObjectData > { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResSceneObject) }; enum { SIGNATURE = NW_RES_SIGNATURE32('SOBJ') }; NW_RES_CTOR( ResSceneObject ) //--------------------------------------------------------------------------- //! @fn void SetHeader(const nw::ut::BinaryRevisionHeader & value) //! @brief ヘッダ情報を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn nw::ut::BinaryRevisionHeader & GetHeader() //! @brief ヘッダ情報を取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_STRUCT_DECL( nw::ut::BinaryRevisionHeader, Header ) // GetHeader() //--------------------------------------------------------------------------- //! @fn const char * GetName() const //! @brief リソースの名前を取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_STRING_DECL( Name ) // GetName() //--------------------------------------------------------------------------- //! @fn s32 GetUserDataIndex(const char * key) const //! @brief ユーザデータの辞書データ中でのインデックス番号を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn s32 GetUserDataCount() const //! @brief ユーザデータの要素数を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn nw::ut::ResMetaData GetUserData(int idx) //! @brief ユーザデータを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_CLASS_DIC_DECL( nw::ut::ResMetaData, UserData, nw::ut::ResDicPatricia ) // GetMetaData(int idx), GetMetaData(const char*), GetMetaDataIndex(const char*), GetMetaDataCount() //--------------------------------------------------------------------------- //! @brief インスタンスの型情報を取得します。 //! //! @return 型情報です。 //--------------------------------------------------------------------------- nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } }; //-------------------------------------------------------------------------- //! @brief シーンノードを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResSceneNode : public ResSceneObject { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResSceneNode) }; enum { SIGNATURE = NW_RES_SIGNATURE32('CNOD') }; NW_RES_CTOR_INHERIT( ResSceneNode, ResSceneObject ) //--------------------------------------------------------------------------- //! @fn void SetFlags(u32 value) //! @brief フラグの設定を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn u32 GetFlags() const //! @brief フラグの設定を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn s32 GetChildrenCount() const //! @brief 子のシーンオブジェクトの要素数を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn ResSceneObject GetChildren(int idx) //! @brief 子のシーンオブジェクトを取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn s32 GetAnimGroupsIndex(const char * key) const //! @brief アニメーション対象のグループ情報の辞書データ中でのインデックス番号を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn s32 GetAnimGroupsCount() const //! @brief アニメーション対象のグループ情報の要素数を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn nw::anim::ResAnimGroup GetAnimGroups(int idx) //! @brief アニメーション対象のグループ情報を取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_PRIMITIVE_DECL( u32, Flags ) // GetFlags(), SetFlags() NW_RES_FIELD_CLASS_LIST_DECL( ResSceneObject, Children ) // GetChildren(int idx), GetChildrenCount() NW_RES_FIELD_CLASS_DIC_DECL( nw::anim::ResAnimGroup, AnimGroups, nw::ut::ResDicPatricia ) // GetAnimGroups(int idx), GetAnimGroups(const char*), GetAnimGropuIndex(const char*), GetAnimGroupsCount() //--------------------------------------------------------------------------- //! @brief ノードのブランチを表示するかどうかのフラグを取得します。 //! //! @return フラグの値を返します。 //--------------------------------------------------------------------------- bool IsBranchVisible() const { return ref().m_Flags & ResSceneNodeData::FLAG_IS_BRANCH_VISIBLE; } //--------------------------------------------------------------------------- //! @brief ノードのブランチを表示するかどうかのフラグを設定します。 //! //! @param flag 設定するフラグ値です。 //--------------------------------------------------------------------------- void SetBranchVisible(bool flag) { if (flag) { ref().m_Flags |= ResSceneNodeData::FLAG_IS_BRANCH_VISIBLE; } else { ref().m_Flags &= ~ResSceneNodeData::FLAG_IS_BRANCH_VISIBLE; } } }; //-------------------------------------------------------------------------- //! @brief トランスフォームノードを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResTransformNode : public ResSceneNode { public: enum Flag { FLAG_SHIFT_MAX = ResSceneNodeData::FLAG_SHIFT_MAX }; enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResTransformNode) }; enum { SIGNATURE = NW_RES_SIGNATURE32('CTFN') }; NW_RES_CTOR_INHERIT( ResTransformNode, ResSceneNode ) //--------------------------------------------------------------------------- //! @fn void SetWorldMatrix(const nw::math::MTX34 & value) //! @brief ワールド行列を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn void SetTransform(const nw::math::Transform3 & value) //! @brief トランスフォーム情報を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn nw::math::MTX34 & GetWorldMatrix() //! @brief ワールド行列を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn nw::math::Transform3 & GetTransform() //! @brief トランスフォーム情報を取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_STRUCT_DECL( nw::math::Transform3, Transform ) // GetTransform() NW_RES_FIELD_STRUCT_DECL( nw::math::MTX34, WorldMatrix ) // GetWorldMatrix() }; } // namespace res } // namespace gfx } // namespace nw #endif // NW_GFX_RESSCENEOBJECT_H_