From 7028cbe09c688437910a25623098762bf0fa592d Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 28 Mar 2016 22:28:34 +1000 Subject: Move Irrlicht to src/others. --- .../irrlicht-1.8.1/tools/MeshConverter/main.cpp | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 src/others/irrlicht-1.8.1/tools/MeshConverter/main.cpp (limited to 'src/others/irrlicht-1.8.1/tools/MeshConverter/main.cpp') diff --git a/src/others/irrlicht-1.8.1/tools/MeshConverter/main.cpp b/src/others/irrlicht-1.8.1/tools/MeshConverter/main.cpp new file mode 100644 index 0000000..d6b878f --- /dev/null +++ b/src/others/irrlicht-1.8.1/tools/MeshConverter/main.cpp @@ -0,0 +1,108 @@ +#include +#include + +using namespace irr; + +using namespace core; +using namespace scene; +using namespace video; +using namespace io; +using namespace gui; + +#ifdef _IRR_WINDOWS_ +#pragma comment(lib, "Irrlicht.lib") +#endif + +void usage(const char* name) +{ + std::cerr << "Usage: " << name << " [options] " << std::endl; + std::cerr << " where options are" << std::endl; + std::cerr << " --createTangents: convert to tangents mesh is possible." << std::endl; + std::cerr << " --format=[irrmesh|collada|stl|obj|ply]: Choose target format" << std::endl; +} + +int main(int argc, char* argv[]) +{ + if ((argc < 3) || + ((argc==3) && (argv[1][0]=='-'))) + { + usage(argv[0]); + return 1; + } + + IrrlichtDevice *device = createDevice( video::EDT_NULL, + dimension2d(800, 600), 32, false, false, false, 0); + + device->setWindowCaption(L"Mesh Converter"); + + scene::EMESH_WRITER_TYPE type = EMWT_IRR_MESH; + u32 i=1; + bool createTangents=false; + while (argv[i][0]=='-') + { + core::stringc format = argv[i]; + if (format.size() > 3) + { + if (format.equalsn("--format=",9)) + { + format = format.subString(9,format.size()); + if (format=="collada") + type = EMWT_COLLADA; + else if (format=="stl") + type = EMWT_STL; + else if (format=="obj") + type = EMWT_OBJ; + else if (format=="ply") + type = EMWT_PLY; + else + type = EMWT_IRR_MESH; + } + else + if (format =="--createTangents") + createTangents=true; + } + else + if (format=="--") + { + ++i; + break; + } + ++i; + } + + const s32 srcmesh = i; + const s32 destmesh = i+1; + + --argc; + if ((argcgetSceneManager()->getMesh(argv[srcmesh])->getMesh(0); + if (!mesh) + { + std::cerr << "Could not load " << argv[srcmesh] << std::endl; + return 1; + } + if (createTangents) + { + IMesh* tmp = device->getSceneManager()->getMeshManipulator()->createMeshWithTangents(mesh); + mesh->drop(); + mesh=tmp; + } + IMeshWriter* mw = device->getSceneManager()->createMeshWriter(type); + IWriteFile* file = device->getFileSystem()->createAndWriteFile(argv[destmesh]); + mw->writeMesh(file, mesh); + + file->drop(); + mw->drop(); + device->drop(); + + return 0; +} + -- cgit v1.1