-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
104 lines (93 loc) · 2.76 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <iostream>
#include <dirent.h>
#include <cstring>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#include <conio.h>
#endif
#include "src/export.hpp"
int main(int argc, char ** argv)
{
std::cout << "RenderWare Exporter (C) Amyr Ahmady (iAmir) https://github.com/AmyrAhmady \n\n";
if (argc < 4)
{
std::cout << "Usage: rwexporter [flag] path output_dir\n\n\n" <<
"|- flags:\n" <<
"\t-txd -> parse a texture dictionary and export all the textures\n" <<
"\t as png files into given output directory.\n\n" <<
"\t-dff -> parse a dff model and export data into a json file.\n" <<
"\t pass an extra flag -amf *after* file paths to convert data to amf instead of json\n\n" <<
"\t-dir -> enumerate over all files in the given directory path\n" <<
"\t and export them like what -txd and -dff does.\n" <<
"\t pass an extra flag -amf *after* folder paths to convert data to amf instead of json\n\n\n" <<
"|- path: path of the target file or directory.\n\n" <<
"|- output_dir: path of the directory that exported files will save into.\n\n\n\n";
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
std::cout << "Press any key to exit...";
_getch();
#endif
return 0;
}
if (!strcmp(argv[1], "-dff"))
{
if (argv[4])
{
if (!strcmp(argv[4], "-amf"))
{
Export::DffModel(argv[2], argv[3], true);
}
else
{
Export::DffModel(argv[2], argv[3], false);
}
}
else
{
Export::DffModel(argv[2], argv[3], false);
}
}
else if (!strcmp(argv[1], "-txd"))
{
Export::TexDic(argv[2], argv[3]);
}
else if (!strcmp(argv[1], "-dir"))
{
DIR * inputDir;
struct dirent * file;
inputDir = opendir(argv[2]);
if (inputDir != NULL)
{
std::cout << "Enumerating all files in " << argv[2] << std::endl;
while (file = readdir(inputDir))
{
std::size_t found = std::string(file->d_name).find(".dff");
if (found != std::string::npos)
{
std::cout << "Processing " << file->d_name << std::endl;
if (argv[4])
{
if (!strcmp(argv[4], "-amf"))
{
Export::DffModel(std::string(argv[2]) + "/" + file->d_name, argv[3], true);
}
else
{
Export::DffModel(std::string(argv[2]) + "/" + file->d_name, argv[3], false);
}
}
else
{
Export::DffModel(std::string(argv[2]) + "/" + file->d_name, argv[3], false);
}
}
found = std::string(file->d_name).find(".txd");
if (found != std::string::npos)
{
std::cout << "Processing " << file->d_name << std::endl;
Export::TexDic(std::string(argv[2]) + "/" + file->d_name, argv[3]);
}
}
std::cout << "Finished processing all files" << std::endl;
}
closedir(inputDir);
}
}