khanat-opennel-code/code/nel/tools/3d/mesh_export/main.cpp

89 lines
2.7 KiB
C++
Raw Normal View History

2015-09-19 15:14:35 +00:00
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2015 Winch Gate Property Limited
// Author: Jan Boon <jan.boon@kaetemi.be>
//
// 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 <http://www.gnu.org/licenses/>.
2015-09-19 16:08:25 +00:00
#include <nel/misc/types_nl.h>
2015-09-19 15:14:35 +00:00
#include "../mesh_utils/mesh_utils.h"
2015-09-19 16:08:25 +00:00
#include <nel/misc/cmd_args.h>
#include <nel/misc/path.h>
2015-09-19 17:35:57 +00:00
#include <nel/3d/register_3d.h>
#include <nel/3d/scene.h>
2015-09-19 15:14:35 +00:00
int main(int argc, char *argv[])
{
2015-09-19 17:35:57 +00:00
NLMISC::CApplicationContext app;
2015-09-19 16:08:25 +00:00
NLMISC::CCmdArgs args;
args.addArg("d", "dst", "destination", "Destination directory path");
args.addArg("", "dependlog", "log", "Dependencies log path");
args.addArg("", "errorlog", "log", "Errors log path");
2016-01-18 20:48:00 +00:00
args.addAdditionalArg("input", "Filename of 3D model to convert", false);
2015-09-19 16:08:25 +00:00
if (!args.parse(argc, argv)) return EXIT_SUCCESS;
2015-09-19 16:08:25 +00:00
2016-01-18 20:48:00 +00:00
const std::vector<std::string> &filePathes = args.getAdditionalArg("input");
2015-09-20 12:08:38 +00:00
2015-09-19 17:35:57 +00:00
NL3D::CScene::registerBasics();
NL3D::registerSerial3d();
2015-09-19 16:08:25 +00:00
sint res = 0;
for(uint i = 0; i < filePathes.size(); ++i)
{
std::string filePath = filePathes[i];
if (!NLMISC::CFile::fileExists(filePath))
{
nlerror("File '%s' does not exist", filePath.c_str());
return EXIT_FAILURE;
}
CMeshUtilsSettings settings;
settings.SourceFilePath = filePath;
if (args.haveArg("d"))
settings.DestinationDirectoryPath = args.getArg("d").front();
if (settings.DestinationDirectoryPath.empty())
settings.DestinationDirectoryPath = filePath + "_export";
2016-01-14 22:46:19 +00:00
settings.DestinationDirectoryPath = NLMISC::CPath::standardizePath(settings.DestinationDirectoryPath);
if (args.haveLongArg("dependlog"))
settings.ToolDependLog = args.getLongArg("dependlog").front();
if (settings.ToolDependLog.empty())
settings.ToolDependLog = settings.DestinationDirectoryPath + "depend.log";
if (args.haveLongArg("errorlog"))
settings.ToolErrorLog = args.getLongArg("errorlog").front();
if (settings.ToolErrorLog.empty())
settings.ToolErrorLog = settings.DestinationDirectoryPath + "error.log";
res = exportScene(settings);
if (res != EXIT_SUCCESS) break;
}
return res;
2015-09-19 15:14:35 +00:00
}
/* end of file */