// NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include #include #include "nel/misc/config_file.h" #include "nel/misc/time_nl.h" #include "nel/misc/file.h" #include "nel/pacs/collision_mesh_build.h" #include "nel/pacs/local_retriever.h" #include "nel/pacs/retriever_instance.h" #include "nel/pacs/global_retriever.h" #include "nel/pacs/retriever_bank.h" #include "nel/pacs/u_global_position.h" #include "mouline.h" using namespace std; using namespace NLPACS; using namespace NLMISC; #ifndef NL_BIRB_CFG #define NL_BIRB_CFG "." #endif // NL_BIB_CFG bool AddToRetriever = true; bool Merge = true; string MergePath = "c:/data_test/"; string MergeInputPrefix = "fyros"; string MergeOutputPrefix = "city_landscape_fyros"; string MeshPath = "c:/data_test/"; vector Meshes; string OutputPath = "c:/data_test/"; string OutputPrefix = "city_fyros"; CVector getZoneCenterById(uint16 id) { CAABBox bbox; uint x, y; const float zdim = 160.0f; x = id%256; y = id/256; return CVector(zdim*((float)x+0.5f), -zdim*((float)y+0.5f), 0.0f); } uint32 getIdByCoord(uint x, uint y) { return y*256+x; } uint16 getZoneIdByName(string &name) { sint y = 0, x = 0; const char *str = name.c_str(); while (*str != '_') y = y*10 + *(str++)-'0'; ++str; x = (str[0]-'A')*26+(str[1]-'A'); return (y-1)*256+x; } template void serialAndSave(A &a, string fn) { COFile f; f.open(fn); f.serial(a); f.close(); } template void openAndSerial(A &a, string fn) { CIFile f; f.open(fn); f.serial(a); f.close(); } // config management int getInt(CConfigFile &cf, const string &varName) { CConfigFile::CVar &var = cf.getVar(varName); return var.asInt(); } string getString(CConfigFile &cf, const string &varName) { CConfigFile::CVar &var = cf.getVar(varName); return var.asString(); } void initConfig() { try { #ifdef NL_OS_UNIX NLMISC::CPath::addSearchPath(NLMISC::CPath::getApplicationDirectory("NeL")); #endif // NL_OS_UNIX NLMISC::CPath::addSearchPath(NL_BIRB_CFG); CConfigFile cf; cf.load("build_indoor_rbank.cfg"); Merge = getInt(cf, "Merge") != 0; AddToRetriever = getInt(cf, "AddToRetriever") != 0; MergePath = getString(cf, "MergePath"); MergeInputPrefix = getString(cf, "MergeInputPrefix"); MergeOutputPrefix = getString(cf, "MergeOutputPrefix"); MeshPath = getString(cf, "MeshPath"); OutputPath = getString(cf, "OutputPath"); OutputPrefix = getString(cf, "OutputPrefix"); CConfigFile::CVar &meshes = cf.getVar("Meshes"); uint i; for (i=0; i<(uint)meshes.size(); i++) Meshes.push_back(meshes.asString(i)); } catch (const EConfigFile &e) { printf ("Problem in config file : %s\n", e.what ()); } } // void makeGlobalRetriever(vector &translation) { CGlobalRetriever gr; CRetrieverBank rb; if (Merge) { openAndSerial(rb, MergePath+MergeInputPrefix+".rbank"); gr.setRetrieverBank(&rb); openAndSerial(gr, MergePath+MergeInputPrefix+".gr"); } else { gr.setRetrieverBank(&rb); gr.init(); } TTime start, end; start = CTime::getLocalTime(); vector ninst; uint i; for (i=0; i &translation) { uint i; translation.resize(Meshes.size()); for (i=0; i usedMaterials; uint j; uint maxMat = 0; for (j=0; j (sint)maxMat) maxMat = cmb.Faces[j].Material; usedMaterials.resize(maxMat+1); for (j=0; j StoredPosition; void loadAndDumpPositions() { CIFile f; f.open("backup.position"); f.serialCont(StoredPosition); f.close(); uint i; for (i=0; i translation; TTime start, end; createDebug (); ErrorLog->removeDisplayer("DEFAULT_MBD"); initConfig(); start = CTime::getLocalTime(); createRetriever(translation); // translation[0] = CVector(-4670.0f, 3579.0f, 0.0f); makeGlobalRetriever(translation); end = CTime::getLocalTime(); nlinfo("%.3f seconds work", (double)(end-start)/1000.0); uint i; for (i=0; i