diff --git a/nel/tools/ligo/CMakeLists.txt b/nel/tools/ligo/CMakeLists.txt index 9a7f24ebe..230e4c74a 100644 --- a/nel/tools/ligo/CMakeLists.txt +++ b/nel/tools/ligo/CMakeLists.txt @@ -2,5 +2,8 @@ IF(WITH_LIGO) IF(WITH_3D) ADD_SUBDIRECTORY(unbuild_land) + IF(WITH_GEORGES) + ADD_SUBDIRECTORY(unbuild_flora) + ENDIF() ENDIF() ENDIF() diff --git a/nel/tools/ligo/unbuild_flora/CMakeLists.txt b/nel/tools/ligo/unbuild_flora/CMakeLists.txt new file mode 100644 index 000000000..6c9dc99c4 --- /dev/null +++ b/nel/tools/ligo/unbuild_flora/CMakeLists.txt @@ -0,0 +1,11 @@ +FILE(GLOB SRC *.cpp *.h *.rc) + +SOURCE_GROUP("" FILES ${SRC}) + +ADD_EXECUTABLE(nl_unbuild_flora ${SRC}) + +TARGET_LINK_LIBRARIES(nl_unbuild_flora nel3d nelmisc nelligo nelgeorges) +NL_DEFAULT_PROPS(nl_unbuild_flora "NeL, Tools, Ligo: Unbuild Flora") +NL_ADD_RUNTIME_FLAGS(nl_unbuild_flora) + +INSTALL(TARGETS nl_unbuild_flora RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsligo) diff --git a/nel/tools/ligo/unbuild_flora/gold_pill.ico b/nel/tools/ligo/unbuild_flora/gold_pill.ico new file mode 100644 index 000000000..618b67a5d Binary files /dev/null and b/nel/tools/ligo/unbuild_flora/gold_pill.ico differ diff --git a/nel/tools/ligo/unbuild_flora/main.rc b/nel/tools/ligo/unbuild_flora/main.rc new file mode 100644 index 000000000..b01178a11 --- /dev/null +++ b/nel/tools/ligo/unbuild_flora/main.rc @@ -0,0 +1,42 @@ +#include +#include "config.h" + +IDI_MAIN_ICON ICON DISCARDABLE "gold_pill.ico" + +#ifdef _DEBUG +#define NL_FILEEXT "_d" +#else +#define NL_FILEEXT "" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION NL_VERSION_RC + PRODUCTVERSION NL_VERSION_RC + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", AUTHOR + VALUE "FileDescription", "NeL Unbuild Flora" + VALUE "FileVersion", NL_VERSION + VALUE "LegalCopyright", COPYRIGHT + VALUE "OriginalFilename", "nl_unbuild_flora" NL_FILEEXT ".exe" + VALUE "ProductName", "NeL Tools" + VALUE "ProductVersion", NL_PRODUCT_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp b/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp new file mode 100644 index 000000000..7aeb404b4 --- /dev/null +++ b/nel/tools/ligo/unbuild_flora/unbuild_flora.cpp @@ -0,0 +1,259 @@ +// NeL - MMORPG Framework +// Copyright (C) 2019 Jan BOON (Kaetemi) +// +// 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 . +// +// This utility is intended to rescue a lost flora .primitive file. +// It only recovers the generated flora positions, it cannot recover +// the flora zones. +// +// Author: Jan BOON (Kaetemi) + +// #include "../../3d/zone_lib/zone_utility.h" + +#include + +#include +#include +//#include +#include +#include +//#include + +#include +#include +#include + +//#include +//#include +//#include +//#include +//#include +//#include +//#include +#include + +#include +//#include +#include + +using namespace std; +using namespace NLMISC; +//using namespace NL3D; +using namespace NLGEORGES; +//using namespace NLLIGO; + +namespace /* anonymous */ +{ + +/* + +Process: +- Load all .plant sheets, map from .shape to .plant and bounding radius +- Load all source igs +- Load all reference igs, remove matching entries from source igs +- Generate primitives + +*/ + +std::string s_DfnDir; /* R:\leveldesign\DFN */ +std::string s_LeveldesignDir; /* R:\leveldesign\game_elem\plant\ecosystem */ +std::string s_SourceDir; /* R:\reference\2008_july\data\r2_desert2 */ +std::string s_ReferenceDir; /* R:\pipeline\export\continents\r2_desert\zone_lighted_ig_land */ +std::string s_PrimitiveFile; /* R:\graphics\primitive\r2_desert\r2_desert.primitive */ + +/* + +Debug arguments: + +"R:\leveldesign\DFN" "R:\leveldesign\game_elem\plant\ecosystem" "R:\reference\2008_july\data\r2_desert2" "R:\pipeline\export\continents\r2_desert\zone_lighted_ig_land" "R:\graphics\primitive\r2_desert\r2_desert.primitive" + +*/ + +struct CPoint +{ + CVector Pos; /* Position, height not necessarily specified (X="26218.738281" Y="-1092.078979" Z="0.000000") */ + float Angle; /* (2.827213) */ + std::string Form; /* (FY_S2_savantree_B) */ + std::string Name; /* Generated unique name (ilot_008_savantree 13) */ + float Radius; /* Bounding radius (from plant sheet and scale) (0.450252) */ + float Scale; /* Scale (0.643217) */ +}; + +/* + + + + + class + prim + + + form + FY_S2_savantree_B + + + layer + 0 + + + name + ilot_008_savantree 15 + + + radius + 0.784730 + + + scale + 1.121043 + + +*/ + +/* +* + + + + + + class + flora + + + name + R2 flora 1 + + + + + ... + + + +*/ + +/* +instance fy_s2_savantree_c.shape : x = 23031.2, y = -1269.2, z = 75.8, sx = 0.5, sy = 0.5, sz = 0.5 +instance fy_s2_savantree_c.shape : x = 22906.6, y = -1148.1, z = 79.6, sx = 0.6, sy = 0.6, sz = 0.6 +*/ + +struct CPlant +{ + std::string Form; + std::string Shape; + float Radius; +}; + +std::map s_ShapeToForm; + +bool loadLeveldesign() +{ + UFormLoader *formLoader = UFormLoader::createLoader(); + struct CRel0 { CRel0(UFormLoader *v) : m(v) {} ~CRel0() { UFormLoader::releaseLoader(m); } UFormLoader *m; } rel0(formLoader); + + std::vector plants; + CPath::getFileList("plant", plants); + + for (std::vector::iterator it(plants.begin()), end(plants.end()); it != end; ++it) + { + printf("%s\n", (*it).c_str()); + CSmartPtr form = formLoader->loadForm(*it); + if (!form) + continue; + CPlant plant; + plant.Form = toLowerAscii(*it); + if (!form->getRootNode().getValueByName(plant.Shape, "3D.Shape")) + continue; + if (plant.Shape.empty()) + { + if (!form->getRootNode().getValueByName(plant.Shape, "3D.SpringFX.FXName")) + continue; + } + if (plant.Shape.empty()) + continue; + plant.Shape.c_str(); + toLowerAscii(&plant.Shape[0]); + if (!form->getRootNode().getValueByName(plant.Radius, "3D.Bounding Radius")) + continue; + printf(" = '%s', %f\n", plant.Shape.c_str(), plant.Radius); + s_ShapeToForm[plant.Shape] = plant; + } + + return true; +} + +bool unbuildFlora() +{ + CPath::addSearchPath(s_DfnDir, true, false); + CPath::addSearchPath(s_LeveldesignDir, true, false); + + if (!loadLeveldesign()) + return false; + + + /* + CInstanceGroup ig; + CIFile inputStream; + if (!inputStream.open(string(argv[1]))) + { + printf("unable to open %s\n", argv[1]); + return -1; + } + */ + + return false; +} + +bool unbuildFlora(NLMISC::CCmdArgs &args) +{ + s_DfnDir = args.getAdditionalArg("dfn")[0]; + s_LeveldesignDir = args.getAdditionalArg("leveldesign")[0]; + s_SourceDir = args.getAdditionalArg("source")[0]; + s_ReferenceDir = args.getAdditionalArg("reference")[0]; + s_PrimitiveFile = args.getAdditionalArg("primitive")[0]; + + return unbuildFlora(); +} + +} /* anonymous namespace */ + +int main(int argc, char **argv) +{ + NLMISC::CApplicationContext myApplicationContext; + + NLMISC::CCmdArgs args; + + args.addAdditionalArg("dfn", "Input folder with DFN"); + args.addAdditionalArg("leveldesign", "Input folder with plant sheets"); + args.addAdditionalArg("source", "Input folder with IGs containing flora"); + args.addAdditionalArg("reference", "Input folder with IGs missing flora"); + args.addAdditionalArg("primitive", "Output flora primitive file"); + + if (!args.parse(argc, argv)) + { + return EXIT_FAILURE; + } + + if (!unbuildFlora(args)) + { + args.displayHelp(); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +/* end of file */