From e72f40fd176fae6a6867ac2ee71d77518e076ef3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 19 Mar 2016 20:46:33 +0100 Subject: [PATCH] Unicode path support for mesh_export --HG-- branch : feature-material-editor --- code/nel/tools/3d/mesh_export/main.cpp | 18 ++++++++++++++++++ code/nel/tools/3d/mesh_utils/mesh_utils.cpp | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/mesh_export/main.cpp b/code/nel/tools/3d/mesh_export/main.cpp index f22e53f41..be1156a78 100644 --- a/code/nel/tools/3d/mesh_export/main.cpp +++ b/code/nel/tools/3d/mesh_export/main.cpp @@ -24,6 +24,24 @@ #include #include +#ifdef NL_OS_WINDOWS +#define main nlMain +int nlMain(int argc, char *argv[]); +static std::vector nlArgs; +static std::vector nlCArgs; +int wmain(int argc, wchar_t *argv[]) +{ + nlArgs.resize(argc); + nlCArgs.resize(argc); + for (int i = 0; i < argc; ++i) + { + nlArgs[i] = wideToUtf8(argv[i]); + nlCArgs[i] = nlArgs[i].c_str(); + } + nlMain(argc, const_cast(&nlCArgs[0])); +} +#endif + int main(int argc, char *argv[]) { NLMISC::CApplicationContext app; diff --git a/code/nel/tools/3d/mesh_utils/mesh_utils.cpp b/code/nel/tools/3d/mesh_utils/mesh_utils.cpp index 601340af1..6d9b4f264 100644 --- a/code/nel/tools/3d/mesh_utils/mesh_utils.cpp +++ b/code/nel/tools/3d/mesh_utils/mesh_utils.cpp @@ -312,12 +312,19 @@ int loadSceneMeta(CMeshUtilsContext &context) int importSceneAssimp(CMeshUtilsContext &context) { + std::vector memFile; + { + NLMISC::CIFile ifile(context.Settings.SourceFilePath); + memFile.resize(ifile.getFileSize()); + ifile.serialBuffer((uint8 *)&memFile[0], memFile.size()); + } + std::string fileExt = NLMISC::CFile::getExtension(context.Settings.SourceFilePath); Assimp::Importer importer; - const aiScene *scene = importer.ReadFile(context.Settings.SourceFilePath, 0 + const aiScene *scene = importer.ReadFileFromMemory(&memFile[0], memFile.size(), 0 | aiProcess_Triangulate | aiProcess_ValidateDataStructure | aiProcess_GenNormals // Or GenSmoothNormals? TODO: Validate smoothness between material boundaries! - ); // aiProcess_SplitLargeMeshes | aiProcess_LimitBoneWeights + , fileExt.c_str()); // aiProcess_SplitLargeMeshes | aiProcess_LimitBoneWeights if (!scene) { const char *errs = importer.GetErrorString();