1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_ResSceneObject.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 17337 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_GFX_RESSCENEOBJECT_H_ 17 #define NW_GFX_RESSCENEOBJECT_H_ 18 19 #include <nw/ut/ut_BinaryFileFormat.h> 20 #include <nw/ut/ut_ResUtil.h> 21 #include <nw/ut/ut_ResDictionary.h> 22 #include <nw/math/math_ResTypes.h> 23 #include <nw/gfx/gfx_Common.h> 24 #include <nw/anim/res/anim_ResAnimGroup.h> 25 #include <nw/gfx/res/gfx_ResTypeInfo.h> 26 #include <nw/ut/ut_ResMetaData.h> 27 28 namespace nw { 29 namespace gfx { 30 namespace res { 31 32 //! @details :private 33 struct ResSceneObjectData 34 { 35 nw::ut::ResTypeInfo typeInfo; 36 nw::ut::BinaryRevisionHeader m_Header; 37 nw::ut::BinString toName; 38 nw::ut::ResS32 m_UserDataDicCount; 39 nw::ut::Offset toUserDataDic; 40 }; 41 42 43 //! @details :private 44 struct ResSceneNodeData : public ResSceneObjectData 45 { 46 enum Flag 47 { 48 FLAG_IS_BRANCH_VISIBLE_SHIFT = 0, 49 FLAG_SHIFT_MAX, 50 51 FLAG_IS_BRANCH_VISIBLE = 0x1 << FLAG_IS_BRANCH_VISIBLE_SHIFT 52 }; 53 54 nw::ut::ResU32 m_Flags; 55 nw::ut::ResBool m_IsBranchVisible; 56 u8 padding_0[3]; 57 nw::ut::ResS32 m_ChildrenTableCount; 58 nw::ut::Offset toChildrenTable; 59 nw::ut::ResS32 m_AnimGroupsDicCount; 60 nw::ut::Offset toAnimGroupsDic; 61 }; 62 63 //! @details :private 64 struct ResTransformNodeData : public ResSceneNodeData 65 { 66 nw::ut::ResTransform3 m_Transform; 67 nw::ut::ResMtx34 m_LocalMatrix; 68 nw::ut::ResMtx34 m_WorldMatrix; 69 }; 70 71 //-------------------------------------------------------------------------- 72 //! @brief シーンオブジェクトを表すバイナリリソースクラスです。 73 //--------------------------------------------------------------------------- 74 class ResSceneObject : public nw::ut::ResCommon< ResSceneObjectData > 75 { 76 public: 77 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResSceneObject) }; 78 enum { SIGNATURE = NW_RES_SIGNATURE32('SOBJ') }; 79 80 NW_RES_CTOR( ResSceneObject ) 81 82 //--------------------------------------------------------------------------- 83 //! @fn void SetHeader(const nw::ut::BinaryRevisionHeader & value) 84 //! @brief ヘッダ情報を設定します。 85 //--------------------------------------------------------------------------- 86 //--------------------------------------------------------------------------- 87 //! @fn nw::ut::BinaryRevisionHeader & GetHeader() 88 //! @brief ヘッダ情報を取得します。 89 //--------------------------------------------------------------------------- NW_RES_FIELD_STRUCT_DECL(nw::ut::BinaryRevisionHeader,Header)90 NW_RES_FIELD_STRUCT_DECL( nw::ut::BinaryRevisionHeader, Header ) // GetHeader() 91 92 //--------------------------------------------------------------------------- 93 //! @fn const char * GetName() const 94 //! @brief リソースの名前を取得します。 95 //--------------------------------------------------------------------------- 96 NW_RES_FIELD_STRING_DECL( Name ) // GetName() 97 98 //--------------------------------------------------------------------------- 99 //! @fn s32 GetUserDataIndex(const char * key) const 100 //! @brief ユーザデータの辞書データ中でのインデックス番号を取得します。 101 //--------------------------------------------------------------------------- 102 //--------------------------------------------------------------------------- 103 //! @fn s32 GetUserDataCount() const 104 //! @brief ユーザデータの要素数を取得します。 105 //--------------------------------------------------------------------------- 106 //--------------------------------------------------------------------------- 107 //! @fn nw::ut::ResMetaData GetUserData(int idx) 108 //! @brief ユーザデータを取得します。 109 //--------------------------------------------------------------------------- 110 NW_RES_FIELD_CLASS_DIC_DECL( nw::ut::ResMetaData, UserData, nw::ut::ResDicPatricia ) // GetMetaData(int idx), GetMetaData(const char*), GetMetaDataIndex(const char*), GetMetaDataCount() 111 112 //--------------------------------------------------------------------------- 113 //! @brief インスタンスの型情報を取得します。 114 //! 115 //! @return 型情報です。 116 //--------------------------------------------------------------------------- 117 nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } 118 }; 119 120 //-------------------------------------------------------------------------- 121 //! @brief シーンノードを表すバイナリリソースクラスです。 122 //--------------------------------------------------------------------------- 123 class ResSceneNode : public ResSceneObject 124 { 125 public: 126 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResSceneNode) }; 127 enum { SIGNATURE = NW_RES_SIGNATURE32('CNOD') }; 128 NW_RES_CTOR_INHERIT(ResSceneNode,ResSceneObject)129 NW_RES_CTOR_INHERIT( ResSceneNode, ResSceneObject ) 130 131 //--------------------------------------------------------------------------- 132 //! @fn void SetFlags(u32 value) 133 //! @brief フラグの設定を設定します。 134 //--------------------------------------------------------------------------- 135 //--------------------------------------------------------------------------- 136 //! @fn u32 GetFlags() const 137 //! @brief フラグの設定を取得します。 138 //--------------------------------------------------------------------------- 139 //--------------------------------------------------------------------------- 140 //! @fn s32 GetChildrenCount() const 141 //! @brief 子のシーンオブジェクトの要素数を取得します。 142 //--------------------------------------------------------------------------- 143 //--------------------------------------------------------------------------- 144 //! @fn ResSceneObject GetChildren(int idx) 145 //! @brief 子のシーンオブジェクトを取得します。 146 //--------------------------------------------------------------------------- 147 //--------------------------------------------------------------------------- 148 //! @fn s32 GetAnimGroupsIndex(const char * key) const 149 //! @brief アニメーション対象のグループ情報の辞書データ中でのインデックス番号を取得します。 150 //--------------------------------------------------------------------------- 151 //--------------------------------------------------------------------------- 152 //! @fn s32 GetAnimGroupsCount() const 153 //! @brief アニメーション対象のグループ情報の要素数を取得します。 154 //--------------------------------------------------------------------------- 155 //--------------------------------------------------------------------------- 156 //! @fn nw::anim::ResAnimGroup GetAnimGroups(int idx) 157 //! @brief アニメーション対象のグループ情報を取得します。 158 //--------------------------------------------------------------------------- 159 NW_RES_FIELD_PRIMITIVE_DECL( u32, Flags ) // GetFlags(), SetFlags() 160 NW_RES_FIELD_CLASS_LIST_DECL( ResSceneObject, Children ) // GetChildren(int idx), GetChildrenCount() 161 NW_RES_FIELD_CLASS_DIC_DECL( nw::anim::ResAnimGroup, AnimGroups, nw::ut::ResDicPatricia ) // GetAnimGroups(int idx), GetAnimGroups(const char*), GetAnimGropuIndex(const char*), GetAnimGroupsCount() 162 163 //--------------------------------------------------------------------------- 164 //! @brief ノードのブランチを表示するかどうかのフラグを取得します。 165 //! 166 //! @return フラグの値を返します。 167 //--------------------------------------------------------------------------- 168 bool IsBranchVisible() const { return ref().m_Flags & ResSceneNodeData::FLAG_IS_BRANCH_VISIBLE; } 169 170 //--------------------------------------------------------------------------- 171 //! @brief ノードのブランチを表示するかどうかのフラグを設定します。 172 //! 173 //! @param flag 設定するフラグ値です。 174 //--------------------------------------------------------------------------- SetBranchVisible(bool flag)175 void SetBranchVisible(bool flag) 176 { 177 if (flag) 178 { 179 ref().m_Flags |= ResSceneNodeData::FLAG_IS_BRANCH_VISIBLE; 180 } 181 else 182 { 183 ref().m_Flags &= ~ResSceneNodeData::FLAG_IS_BRANCH_VISIBLE; 184 } 185 } 186 }; 187 188 //-------------------------------------------------------------------------- 189 //! @brief トランスフォームノードを表すバイナリリソースクラスです。 190 //--------------------------------------------------------------------------- 191 class ResTransformNode : public ResSceneNode 192 { 193 public: 194 enum Flag { 195 FLAG_SHIFT_MAX = ResSceneNodeData::FLAG_SHIFT_MAX 196 }; 197 198 enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResTransformNode) }; 199 enum { SIGNATURE = NW_RES_SIGNATURE32('CTFN') }; 200 201 NW_RES_CTOR_INHERIT( ResTransformNode, ResSceneNode ) 202 203 //--------------------------------------------------------------------------- 204 //! @fn void SetWorldMatrix(const nw::math::MTX34 & value) 205 //! @brief ワールド行列を設定します。 206 //--------------------------------------------------------------------------- 207 //--------------------------------------------------------------------------- 208 //! @fn void SetTransform(const nw::math::Transform3 & value) 209 //! @brief トランスフォーム情報を設定します。 210 //--------------------------------------------------------------------------- 211 //--------------------------------------------------------------------------- 212 //! @fn nw::math::MTX34 & GetWorldMatrix() 213 //! @brief ワールド行列を取得します。 214 //--------------------------------------------------------------------------- 215 //--------------------------------------------------------------------------- 216 //! @fn nw::math::Transform3 & GetTransform() 217 //! @brief トランスフォーム情報を取得します。 218 //--------------------------------------------------------------------------- 219 NW_RES_FIELD_STRUCT_DECL( nw::math::Transform3, Transform ) // GetTransform() 220 NW_RES_FIELD_STRUCT_DECL( nw::math::MTX34, WorldMatrix ) // GetWorldMatrix() 221 }; 222 223 } // namespace res 224 } // namespace gfx 225 } // namespace nw 226 227 #endif // NW_GFX_RESSCENEOBJECT_H_ 228