1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_ResMesh.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: 13145 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_GFX_RESMESH_H_ 17 #define NW_GFX_RESMESH_H_ 18 19 #include <nw/ut/ut_ResUtil.h> 20 #include <nw/ut/ut_ResDictionary.h> 21 #include <nw/gfx/res/gfx_ResSceneObject.h> 22 #include <nw/gfx/res/gfx_ResShape.h> 23 #include <nw/gfx/res/gfx_ResMaterial.h> 24 25 namespace nw { 26 namespace gfx { 27 namespace res { 28 29 //! @details :private 30 struct ResMeshData : public ResSceneObjectData 31 { 32 enum { IR_SCALE_COMMAND_SIZE = 2 + 1 + 2 * 4 + 1 }; 33 34 nw::ut::ResS32 m_ShapeIndex; 35 nw::ut::ResS32 m_MaterialIndex; 36 nw::ut::Offset toOwnerModel; 37 nw::ut::ResBool m_IsVisible; 38 nw::ut::ResU8 m_RenderPriority; 39 nw::ut::ResS16 m_MeshNodeVisibilityIndex; 40 nw::ut::ResS32 m_CurrentPrimitiveIndex; 41 nw::ut::ResU32 m_Flags; 42 nw::ut::ResU32 m_IrScaleCommand[ IR_SCALE_COMMAND_SIZE ]; 43 void* m_ActivateCommandCache; 44 s32 m_ActivateCommandCacheSize; 45 void* m_DeactivateCommandCache; 46 s32 m_DeactivateCommandCacheSize; 47 nw::ut::BinString toMeshNodeName; 48 u64 m_RenderKeyCache; 49 nw::os::IAllocator* m_CommandAllocator; 50 }; 51 52 //-------------------------------------------------------------------------- 53 //! @brief メッシュを表すバイナリリソースクラスです。 54 //--------------------------------------------------------------------------- 55 class ResMesh : public ResSceneObject 56 { 57 public: 58 enum Flag 59 { 60 FLAG_HAS_VERTEX_ALPHA = 0x1, 61 FLAG_HAS_BONE_WEIGHT_W = 0x1 << 1, 62 FLAG_VALID_RENDER_KEY_CACHE = 0x1 << 2, 63 FLAG_HAS_BEEN_SETUP = 0x1 << 3 64 }; 65 NW_RES_CTOR_INHERIT(ResMesh,ResSceneObject)66 NW_RES_CTOR_INHERIT( ResMesh, ResSceneObject ) 67 68 //--------------------------------------------------------------------------- 69 //! @fn void SetVisible(bool value) 70 //! @brief 表示されるかどうかのフラグを設定します。 71 //--------------------------------------------------------------------------- 72 //--------------------------------------------------------------------------- 73 //! @fn void SetShapeIndex(s32 value) 74 //! @brief 使用するシェイプのインデックスを設定します。 75 //--------------------------------------------------------------------------- 76 //--------------------------------------------------------------------------- 77 //! @fn void SetRenderPriority(u8 value) 78 //! @brief 描画優先度を設定します。 79 //--------------------------------------------------------------------------- 80 //--------------------------------------------------------------------------- 81 //! @fn void SetMaterialIndex(s32 value) 82 //! @brief 使用するマテリアルのインデックスを設定します。 83 //--------------------------------------------------------------------------- 84 //--------------------------------------------------------------------------- 85 //! @fn void SetFlags(u32 value) 86 //! @brief フラグの値を設定します。 87 //! 設定されなかったフラグは無効になります。 88 //--------------------------------------------------------------------------- 89 //--------------------------------------------------------------------------- 90 //! @fn void EnaleFlags(u32 value) 91 //! @brief 指定された Flag の値を有効にします。 92 //! 設定されなかったフラグは変更されません。 93 //--------------------------------------------------------------------------- 94 //--------------------------------------------------------------------------- 95 //! @fn void DisableFlags(u32 value) 96 //! @brief 指定された Flag の値を無効にします。 97 //! 設定されなかったフラグは変更されません。 98 //--------------------------------------------------------------------------- 99 //--------------------------------------------------------------------------- 100 //! @fn void SetCurrentPrimitiveIndex(s32 value) 101 //! @brief 現在有効なプリミティブのインデックス番号を設定します。 102 //--------------------------------------------------------------------------- 103 //--------------------------------------------------------------------------- 104 //! @fn bool IsVisible() const 105 //! @brief 表示されるかどうかのフラグを取得します。 106 //--------------------------------------------------------------------------- 107 //--------------------------------------------------------------------------- 108 //! @fn s32 GetShapeIndex() const 109 //! @brief 使用するシェイプのインデックスを取得します。 110 //--------------------------------------------------------------------------- 111 //--------------------------------------------------------------------------- 112 //! @fn u8 GetRenderPriority() const 113 //! @brief 描画優先度を取得します。 114 //--------------------------------------------------------------------------- 115 //--------------------------------------------------------------------------- 116 //! @fn ResTransformNode GetOwnerModel() 117 //! @brief 親モデルへを取得します。 118 //--------------------------------------------------------------------------- 119 //--------------------------------------------------------------------------- 120 //! @fn s32 GetMaterialIndex() const 121 //! @brief 使用するマテリアルのインデックスを取得します。 122 //--------------------------------------------------------------------------- 123 //--------------------------------------------------------------------------- 124 //! @fn u32 GetFlags() const 125 //! @brief フラグの値を取得します。 126 //--------------------------------------------------------------------------- 127 //--------------------------------------------------------------------------- 128 //! @fn s32 GetCurrentPrimitiveIndex() const 129 //! @brief 現在有効なプリミティブのインデックス番号を取得します。 130 //--------------------------------------------------------------------------- 131 //--------------------------------------------------------------------------- 132 //! @fn const char * GetMeshNodeName() const 133 //! @brief DCC 上でのノード名を取得します。 134 //--------------------------------------------------------------------------- 135 //--------------------------------------------------------------------------- 136 //! @fn void GetMeshNodeVisibilityIndex(s32 value) 137 //! @brief 親モデルが持つビジビリティテーブルのインデックス番号を取得します。 138 //--------------------------------------------------------------------------- 139 NW_RES_FIELD_PRIMITIVE_DECL( s32, ShapeIndex ) // GetShapeIndex(), SetShapeIndex() 140 NW_RES_FIELD_PRIMITIVE_DECL( s32, MaterialIndex ) // GetMaterialIndex(), SetMaterialIndex() 141 NW_RES_FIELD_CLASS_DECL( ResTransformNode, OwnerModel ) // GetOwnerModel() 142 NW_RES_FIELD_BOOL_PRIMITIVE_DECL( Visible ) // IsVisible(), SetVisible() 143 NW_RES_FIELD_PRIMITIVE_DECL( u8, RenderPriority ) // GetRenderPriority(), SetRenderPriority() 144 NW_RES_FIELD_PRIMITIVE_DECL( s32, CurrentPrimitiveIndex ) // GetCurrentPrimitiveIndex(), SetCurrentPrimitiveIndex() 145 NW_RES_FIELD_FLAGS_DECL( u32, Flags ) // GetFlags(), SetFlags(), EnableFlags(), DisableFlags() 146 // TODO: Name が取れないのを修正する。 147 // NW_RES_FIELD_STRING_DECL( MeshNodeName ) // GetMeshNodeName() 148 NW_RES_FIELD_PRIMITIVE_DECL( s32, MeshNodeVisibilityIndex ) // GetMeshNodeVisibilityIndex(), SetMeshNodeVisibilityIndex() 149 150 //--------------------------------------------------------------------------- 151 //! @brief キャッシュされたレンダーキーの値を取得します。 152 //! 153 //! @return レンダーキーの値です。 154 //--------------------------------------------------------------------------- 155 u64 GetRenderKeyCache() const { return ref().m_RenderKeyCache; } 156 157 //--------------------------------------------------------------------------- 158 //! @brief レンダーキーの値をキャッシュに保存します。 159 //! 160 //! @param[in] renderKey レンダーキーの値です。 161 //--------------------------------------------------------------------------- SetRenderKeyCache(u64 renderKey)162 void SetRenderKeyCache(u64 renderKey) { ref().m_RenderKeyCache = renderKey; } 163 164 165 //--------------------------------------------------------------------------- 166 //! @brief リソースのセットアップをおこないます。 167 //! 168 //! @param[in] owner 所有者となるモデルリソースです。 169 //! @param[in] allocator アロケータです。 170 //! @param[in] graphicsFile グラフィックスリソースです。 171 //--------------------------------------------------------------------------- 172 Result Setup(ResModel owner, os::IAllocator* allocator, ResGraphicsFile graphicsFile); 173 174 //--------------------------------------------------------------------------- 175 //! @brief リソースの後始末をおこないます。 176 //--------------------------------------------------------------------------- 177 void Cleanup(); 178 }; 179 180 typedef nw::ut::ResArrayClass<ResMesh>::type ResMeshArray; 181 182 } // namespace res 183 } // namespace gfx 184 } // namespace nw 185 186 #endif // NW_GFX_RESMESH_H_ 187