/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ResModel.cpp 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: 19452 $ *---------------------------------------------------------------------------*/ #include "../precompiled.h" #include #include #include #include #include #include #include #include #include #include namespace nw { namespace gfx { namespace res { //---------------------------------------------------------------------------- Result ResModel::Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile) { Result result = RESOURCE_RESULT_OK; NW_ASSERT( this->IsValid() ); NW_ASSERT( internal::ResCheckRevision( *this ) ); NW_ASSERT( internal::ResCheckRevision( graphicsFile ) ); s32 shapeNum = this->GetShapesCount(); for ( int i = 0; i < shapeNum; ++i ) { if (!ut::CheckFlag(this->GetShapes(i).GetFlags(), ResShape::FLAG_HAS_BEEN_SETUP)) { result |= this->GetShapes( i ).Setup(allocator); } } s32 materialNum = this->GetMaterialsCount(); for ( int i = 0; i < materialNum; ++i ) { if (!ut::CheckFlag(this->GetMaterials( i ).GetFlags(), ResMaterialData::FLAG_HAS_BEEN_SETUP)) { result |= this->GetMaterials( i ).Setup(allocator, graphicsFile); } } #if defined(NW_CALL_DRAW_ELEMENTS_MANUALLY) // シェーダーの参照解決が終わるまでは頂点用のコマンド生成ができない。 if ( (result.GetDescription() & RESOURCE_RESULT_NOT_FOUND_SHADER) == 0 ) { // 各メッシュに対して、頂点アトリビュートの設定コマンドを生成する。 s32 meshNum = this->GetMeshesCount(); for ( int i = 0; i < meshNum; ++ i ) { ResMesh mesh = this->GetMeshes( i ); if (!ut::CheckFlag(mesh.GetFlags(), ResMesh::FLAG_HAS_BEEN_SETUP)) { mesh.Setup( *this, allocator, graphicsFile ); } } } #endif return result; } //---------------------------------------------------------------------------- void ResModel::Cleanup() { s32 shapeNum = this->GetShapesCount(); for ( int i = 0; i < shapeNum; ++i ) { if (ut::CheckFlag(this->GetShapes(i).GetFlags(), ResShape::FLAG_HAS_BEEN_SETUP)) { this->GetShapes( i ).Cleanup(); } } s32 materialNum = this->GetMaterialsCount(); for ( int i = 0; i < materialNum; ++i ) { this->GetMaterials( i ).Cleanup(); } s32 meshNum = this->GetMeshesCount(); for ( int i = 0; i < meshNum; ++ i ) { this->GetMeshes( i ).Cleanup(); } } } /* namespace res */ } /* namespace gfx */ } /* namespace nw */