From a61b82fe1e37684577b6516abae977ff7129fbe8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 20 Sep 2011 16:21:37 +0200 Subject: [PATCH] Changed: #1092 Fixed several issues concerning export with lightmaps. --- .../3d/plugin_max/nel_mesh_lib/calc_lm.cpp | 40 ++++++++++++------- .../nel_mesh_lib/export_particle_system.cpp | 2 +- .../plugin_max/nel_mesh_lib/export_scene.cpp | 16 ++++++-- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp index e65b4ea56..03326cf44 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/calc_lm.cpp @@ -281,13 +281,21 @@ void SLightBuild::convertFromMaxLight (INode *node,TimeValue tvTime) } #if (MAX_RELEASE < 4000) - // Convert exclusion list - NameTab& ntExclu = maxLight->GetExclusionList(); - for( sint i = 0; i < ntExclu.Count(); ++i ) - { - string tmp = *ntExclu.Addr(i); - this->setExclusion.insert( tmp ); - } + // Convert exclusion list + NameTab& ntExclu = maxLight->GetExclusionList(); + for (sint i = 0; i < ntExclu.Count(); ++i) + { + string tmp = *ntExclu.Addr(i); + this->setExclusion.insert(tmp); + } +#else // (MAX_RELEASE < 4000) + ExclList& exclusionList = maxLight->GetExclusionList(); + for (sint i = 0; i < exclusionList.Count(); ++i) + { + INode *exclNode = exclusionList[i]; + string tmp = exclNode->GetName(); + this->setExclusion.insert(tmp); + } #endif // (MAX_RELEASE < 4000) // Get Soft Shadow informations @@ -1999,11 +2007,12 @@ void CExportNel::deleteLM(INode& ZeNode) sprintf( tmp, "%d", i ); sSaveName += tmp; sSaveName += ".tga"; - FILE *file; - if( file = fopen(sSaveName.c_str(),"rb") ) + if (CFile::fileExists(sSaveName)) { - fclose( file ); - DeleteFile( sSaveName.c_str() ); + if (!CFile::deleteFile(sSaveName)) + { + nlwarning("Failed to delete file %s.", sSaveName.c_str()); + } } } } @@ -2576,11 +2585,12 @@ bool CExportNel::calculateLM( CMesh::CMeshBuild *pZeMeshBuild, CMeshBase::CMeshB for (i = 0; i < 256; ++i) { string sLMName = sBaseName + NLMISC::toString(i) + ".tga"; - CIFile ifi; - if (ifi.open(sLMName)) + if (CFile::fileExists(sLMName)) { - ifi.close (); - DeleteFile (sLMName.c_str()); + if (!CFile::deleteFile(sLMName)) + { + nlwarning("Failed to delete file %s.", sLMName.c_str()); + } } } } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp index 4c6b6bc8b..e3504b324 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_particle_system.cpp @@ -36,7 +36,7 @@ IShape* CExportNel::buildParticleSystem(INode& node, TimeValue time) // if not found, get from the APP_DATAS shapeName = CExportNel::getNelObjectName(node); if (shapeName.empty()) return NULL; - shapeName = NLMISC::CPath::lookup("shapeName", false); + shapeName = NLMISC::CPath::lookup(shapeName, false); if (shapeName.empty()) return NULL; } diff --git a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp index 4e7edea8a..2d0268a74 100644 --- a/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp +++ b/code/nel/tools/3d/plugin_max/nel_mesh_lib/export_scene.cpp @@ -24,6 +24,7 @@ #include "../nel_patch_lib/rpo.h" #include "../../ig_lighter_lib/ig_lighter_lib.h" +#include "nel/misc/path.h" #include "nel/3d/scene_group.h" #include "nel/3d/scene.h" #include "nel/3d/shape_bank.h" @@ -418,12 +419,21 @@ CInstanceGroup* CExportNel::buildInstanceGroup(const vector& vectNode, v if (clid.PartA() == NEL_PARTICLE_SYSTEM_CLASS_ID) { // build the shape from the file name - std::string objName = CExportNel::getNelObjectName(*pNode); - if (!objName.empty()) + // std::string objName = CExportNel::getNelObjectName(*pNode); + std::string psFilePath; + // try to get the complete path + if (!CExportNel::getValueByNameUsingParamBlock2(*pNode, "ps_file_name", (ParamType2) TYPE_STRING, &psFilePath, 0)) + { + // if not found, get from the APP_DATAS + psFilePath = CExportNel::getNelObjectName(*pNode); + if (!psFilePath.empty()) + psFilePath = CPath::lookup(psFilePath, false); + } + if (!psFilePath.empty()) { NL3D::CShapeStream ss; NLMISC::CIFile iF; - if (iF.open(objName.c_str())) + if (iF.open(psFilePath.c_str())) { try {