From 607a4bcb3b14ad3666ac7fc9e326a671e3417bb2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 19 Sep 2015 18:08:25 +0200 Subject: [PATCH] Command line options --- code/nel/tools/3d/mesh_export/main.cpp | 39 +++++++++++++++++++-- code/nel/tools/3d/mesh_utils/mesh_utils.cpp | 7 ++-- code/nel/tools/3d/mesh_utils/mesh_utils.h | 12 ++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/code/nel/tools/3d/mesh_export/main.cpp b/code/nel/tools/3d/mesh_export/main.cpp index be527719b..e83727a5c 100644 --- a/code/nel/tools/3d/mesh_export/main.cpp +++ b/code/nel/tools/3d/mesh_export/main.cpp @@ -15,12 +15,47 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include #include "../mesh_utils/mesh_utils.h" +#include +#include + +int printHelp(const NLMISC::CCmdArgs &args) +{ + printf("NeL Mesh Export\n"); + return EXIT_SUCCESS; +} + int main(int argc, char *argv[]) { - mesh_utils_placeholder(); - return 0; + NLMISC::CCmdArgs args; + args.setArgs(argc, (const char **)argv); + + if (args.getArgs().size() == 1 + || args.haveArg('h') + || args.haveLongArg("help")) + return printHelp(args); + + const NLMISC::CSString &filePath = args.getArgs().back(); + if (!NLMISC::CFile::fileExists(filePath)) + { + printHelp(args); + nlerror("File '%s' does not exist", filePath); + return EXIT_FAILURE; + } + + CMeshUtilsSettings settings; + settings.SourceFilePath = filePath; + + settings.DestinationDirectory = args.getArg('d'); + if (settings.DestinationDirectory.empty()) + settings.DestinationDirectory = args.getLongArg("dst"); + if (settings.DestinationDirectory.empty()) + settings.DestinationDirectory = filePath + "_export"; + settings.DestinationDirectory += "/"; + + return exportScene(settings); } /* end of file */ diff --git a/code/nel/tools/3d/mesh_utils/mesh_utils.cpp b/code/nel/tools/3d/mesh_utils/mesh_utils.cpp index f3dfaef84..2430b1dc9 100644 --- a/code/nel/tools/3d/mesh_utils/mesh_utils.cpp +++ b/code/nel/tools/3d/mesh_utils/mesh_utils.cpp @@ -15,9 +15,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -void mesh_utils_placeholder() +#include +#include "mesh_utils.h" + +int exportScene(CMeshUtilsSettings &settings) { - + return EXIT_SUCCESS; } /* end of file */ diff --git a/code/nel/tools/3d/mesh_utils/mesh_utils.h b/code/nel/tools/3d/mesh_utils/mesh_utils.h index 8110ef8f4..f021f66f8 100644 --- a/code/nel/tools/3d/mesh_utils/mesh_utils.h +++ b/code/nel/tools/3d/mesh_utils/mesh_utils.h @@ -15,6 +15,16 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -void mesh_utils_placeholder(); +#include + +#include + +struct CMeshUtilsSettings +{ + std::string SourceFilePath; + std::string DestinationDirectory; +}; + +int exportScene(CMeshUtilsSettings &settings); /* end of file */