aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/tools/MeshConverter/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/tools/MeshConverter/main.cpp216
1 files changed, 108 insertions, 108 deletions
diff --git a/libraries/irrlicht-1.8/tools/MeshConverter/main.cpp b/libraries/irrlicht-1.8/tools/MeshConverter/main.cpp
index d6b878f..f05d6fa 100644
--- a/libraries/irrlicht-1.8/tools/MeshConverter/main.cpp
+++ b/libraries/irrlicht-1.8/tools/MeshConverter/main.cpp
@@ -1,108 +1,108 @@
1#include <irrlicht.h> 1#include <irrlicht.h>
2#include <iostream> 2#include <iostream>
3 3
4using namespace irr; 4using namespace irr;
5 5
6using namespace core; 6using namespace core;
7using namespace scene; 7using namespace scene;
8using namespace video; 8using namespace video;
9using namespace io; 9using namespace io;
10using namespace gui; 10using namespace gui;
11 11
12#ifdef _IRR_WINDOWS_ 12#ifdef _IRR_WINDOWS_
13#pragma comment(lib, "Irrlicht.lib") 13#pragma comment(lib, "Irrlicht.lib")
14#endif 14#endif
15 15
16void usage(const char* name) 16void usage(const char* name)
17{ 17{
18 std::cerr << "Usage: " << name << " [options] <srcFile> <destFile>" << std::endl; 18 std::cerr << "Usage: " << name << " [options] <srcFile> <destFile>" << std::endl;
19 std::cerr << " where options are" << std::endl; 19 std::cerr << " where options are" << std::endl;
20 std::cerr << " --createTangents: convert to tangents mesh is possible." << std::endl; 20 std::cerr << " --createTangents: convert to tangents mesh is possible." << std::endl;
21 std::cerr << " --format=[irrmesh|collada|stl|obj|ply]: Choose target format" << std::endl; 21 std::cerr << " --format=[irrmesh|collada|stl|obj|ply]: Choose target format" << std::endl;
22} 22}
23 23
24int main(int argc, char* argv[]) 24int main(int argc, char* argv[])
25{ 25{
26 if ((argc < 3) || 26 if ((argc < 3) ||
27 ((argc==3) && (argv[1][0]=='-'))) 27 ((argc==3) && (argv[1][0]=='-')))
28 { 28 {
29 usage(argv[0]); 29 usage(argv[0]);
30 return 1; 30 return 1;
31 } 31 }
32 32
33 IrrlichtDevice *device = createDevice( video::EDT_NULL, 33 IrrlichtDevice *device = createDevice( video::EDT_NULL,
34 dimension2d<u32>(800, 600), 32, false, false, false, 0); 34 dimension2d<u32>(800, 600), 32, false, false, false, 0);
35 35
36 device->setWindowCaption(L"Mesh Converter"); 36 device->setWindowCaption(L"Mesh Converter");
37 37
38 scene::EMESH_WRITER_TYPE type = EMWT_IRR_MESH; 38 scene::EMESH_WRITER_TYPE type = EMWT_IRR_MESH;
39 u32 i=1; 39 u32 i=1;
40 bool createTangents=false; 40 bool createTangents=false;
41 while (argv[i][0]=='-') 41 while (argv[i][0]=='-')
42 { 42 {
43 core::stringc format = argv[i]; 43 core::stringc format = argv[i];
44 if (format.size() > 3) 44 if (format.size() > 3)
45 { 45 {
46 if (format.equalsn("--format=",9)) 46 if (format.equalsn("--format=",9))
47 { 47 {
48 format = format.subString(9,format.size()); 48 format = format.subString(9,format.size());
49 if (format=="collada") 49 if (format=="collada")
50 type = EMWT_COLLADA; 50 type = EMWT_COLLADA;
51 else if (format=="stl") 51 else if (format=="stl")
52 type = EMWT_STL; 52 type = EMWT_STL;
53 else if (format=="obj") 53 else if (format=="obj")
54 type = EMWT_OBJ; 54 type = EMWT_OBJ;
55 else if (format=="ply") 55 else if (format=="ply")
56 type = EMWT_PLY; 56 type = EMWT_PLY;
57 else 57 else
58 type = EMWT_IRR_MESH; 58 type = EMWT_IRR_MESH;
59 } 59 }
60 else 60 else
61 if (format =="--createTangents") 61 if (format =="--createTangents")
62 createTangents=true; 62 createTangents=true;
63 } 63 }
64 else 64 else
65 if (format=="--") 65 if (format=="--")
66 { 66 {
67 ++i; 67 ++i;
68 break; 68 break;
69 } 69 }
70 ++i; 70 ++i;
71 } 71 }
72 72
73 const s32 srcmesh = i; 73 const s32 srcmesh = i;
74 const s32 destmesh = i+1; 74 const s32 destmesh = i+1;
75 75
76 --argc; 76 --argc;
77 if ((argc<srcmesh) || (argc<destmesh)) 77 if ((argc<srcmesh) || (argc<destmesh))
78 { 78 {
79 std::cerr << "Not enough files given." << std::endl; 79 std::cerr << "Not enough files given." << std::endl;
80 usage(argv[0]); 80 usage(argv[0]);
81 return 1; 81 return 1;
82 } 82 }
83 83
84 createTangents = createTangents && (type==EMWT_IRR_MESH); 84 createTangents = createTangents && (type==EMWT_IRR_MESH);
85 std::cout << "Converting " << argv[srcmesh] << " to " << argv[destmesh] << std::endl; 85 std::cout << "Converting " << argv[srcmesh] << " to " << argv[destmesh] << std::endl;
86 IMesh* mesh = device->getSceneManager()->getMesh(argv[srcmesh])->getMesh(0); 86 IMesh* mesh = device->getSceneManager()->getMesh(argv[srcmesh])->getMesh(0);
87 if (!mesh) 87 if (!mesh)
88 { 88 {
89 std::cerr << "Could not load " << argv[srcmesh] << std::endl; 89 std::cerr << "Could not load " << argv[srcmesh] << std::endl;
90 return 1; 90 return 1;
91 } 91 }
92 if (createTangents) 92 if (createTangents)
93 { 93 {
94 IMesh* tmp = device->getSceneManager()->getMeshManipulator()->createMeshWithTangents(mesh); 94 IMesh* tmp = device->getSceneManager()->getMeshManipulator()->createMeshWithTangents(mesh);
95 mesh->drop(); 95 mesh->drop();
96 mesh=tmp; 96 mesh=tmp;
97 } 97 }
98 IMeshWriter* mw = device->getSceneManager()->createMeshWriter(type); 98 IMeshWriter* mw = device->getSceneManager()->createMeshWriter(type);
99 IWriteFile* file = device->getFileSystem()->createAndWriteFile(argv[destmesh]); 99 IWriteFile* file = device->getFileSystem()->createAndWriteFile(argv[destmesh]);
100 mw->writeMesh(file, mesh); 100 mw->writeMesh(file, mesh);
101 101
102 file->drop(); 102 file->drop();
103 mw->drop(); 103 mw->drop();
104 device->drop(); 104 device->drop();
105 105
106 return 0; 106 return 0;
107} 107}
108 108