[930] | 1 | /*->if (numargs < 2)
|
---|
| 2 | {
|
---|
| 3 | exit(-1);
|
---|
| 4 | }*/
|
---|
| 5 |
|
---|
| 6 | /*->FILE *file = NULL;
|
---|
| 7 |
|
---|
| 8 | file = fopen("L:\\Ogre3D\\ogrenew\\Tools\\GPUObscurancesOgre3D1\\bin\\debug\\tmp.txt", "w");
|
---|
| 9 |
|
---|
| 10 | fprintf(file, "%s", argv);
|
---|
| 11 |
|
---|
| 12 | fclose(file);*/
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | XmlOptions opts;
|
---|
| 16 |
|
---|
| 17 | //
|
---|
| 18 | opts.interactiveMode = false;
|
---|
| 19 | opts.lodDist = 500;
|
---|
| 20 | opts.lodFixed = 0;
|
---|
| 21 | opts.lodPercent = 20;
|
---|
| 22 | opts.numLods = 0;
|
---|
| 23 | opts.usePercent = true;
|
---|
| 24 | opts.generateEdgeLists = true;
|
---|
| 25 | opts.generateTangents = false;
|
---|
| 26 | opts.reorganiseBuffers = true;
|
---|
| 27 | opts.optimiseAnimations = true;
|
---|
| 28 | opts.quietMode = false;
|
---|
| 29 | opts.endian = Serializer::ENDIAN_NATIVE;
|
---|
| 30 |
|
---|
| 31 | // ignore program name
|
---|
| 32 | /*->char* source = "objMesh.mesh";
|
---|
| 33 | char* dest = "objMesh.xml";*/
|
---|
| 34 | char* source = "L:\\Ogre3D\\ogrenew\\Tools\\GPUObscurancesOgre3D1\\bin\\Debug\\objMesh.mesh";
|
---|
| 35 | char* dest = "L:\\Ogre3D\\ogrenew\\Tools\\GPUObscurancesOgre3D1\\bin\\Debug\\objMesh.xml";
|
---|
| 36 |
|
---|
| 37 | FILE *file = NULL;
|
---|
| 38 |
|
---|
| 39 | file = fopen("L:\\Ogre3D\\ogrenew\\Tools\\GPUObscurancesOgre3D1\\bin\\Debug\\tmp.txt", "w");
|
---|
| 40 |
|
---|
| 41 | fprintf(file, "\nFitxer origen: %s\nFitxer desti: %s\n", source, dest);
|
---|
| 42 |
|
---|
| 43 | fclose(file);
|
---|
| 44 |
|
---|
| 45 | // Set up options
|
---|
| 46 | UnaryOptionList unOpt;
|
---|
| 47 | BinaryOptionList binOpt;
|
---|
| 48 |
|
---|
| 49 | unOpt["-i"] = false;
|
---|
| 50 | unOpt["-e"] = false;
|
---|
| 51 | unOpt["-r"] = false;
|
---|
| 52 | unOpt["-t"] = false;
|
---|
| 53 | unOpt["-o"] = false;
|
---|
| 54 | unOpt["-q"] = false;
|
---|
| 55 | unOpt["-d3d"] = false;
|
---|
| 56 | unOpt["-gl"] = true;
|
---|
| 57 | binOpt["-l"] = "";
|
---|
| 58 | binOpt["-d"] = "";
|
---|
| 59 | binOpt["-p"] = "";
|
---|
| 60 | binOpt["-f"] = "";
|
---|
| 61 | binOpt["-E"] = "";
|
---|
| 62 | binOpt["-log"] = "OgreXMLConverter.log";
|
---|
| 63 |
|
---|
| 64 | //->int startIndex = findCommandLineOpts(numArgs, args, unOpt, binOpt);
|
---|
| 65 | UnaryOptionList::iterator ui;
|
---|
| 66 | BinaryOptionList::iterator bi;
|
---|
| 67 |
|
---|
| 68 | ui = unOpt.find("-q");
|
---|
| 69 | if (ui->second)
|
---|
| 70 | {
|
---|
| 71 | opts.quietMode = true;
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | ui = unOpt.find("-i");
|
---|
| 75 | if (ui->second)
|
---|
| 76 | {
|
---|
| 77 | opts.interactiveMode = true;
|
---|
| 78 | }
|
---|
| 79 | else
|
---|
| 80 | {
|
---|
| 81 | ui = unOpt.find("-e");
|
---|
| 82 | if (ui->second)
|
---|
| 83 | {
|
---|
| 84 | opts.generateEdgeLists = false;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | ui = unOpt.find("-r");
|
---|
| 88 | if (ui->second)
|
---|
| 89 | {
|
---|
| 90 | opts.reorganiseBuffers = false;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | ui = unOpt.find("-t");
|
---|
| 94 | if (ui->second)
|
---|
| 95 | {
|
---|
| 96 | opts.generateTangents = true;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | ui = unOpt.find("-o");
|
---|
| 100 | if (ui->second)
|
---|
| 101 | {
|
---|
| 102 | opts.optimiseAnimations = false;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | bi = binOpt.find("-l");
|
---|
| 106 | if (!bi->second.empty())
|
---|
| 107 | {
|
---|
| 108 | opts.numLods = StringConverter::parseInt(bi->second);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | bi = binOpt.find("-d");
|
---|
| 112 | if (!bi->second.empty())
|
---|
| 113 | {
|
---|
| 114 | opts.lodDist = StringConverter::parseReal(bi->second);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | bi = binOpt.find("-p");
|
---|
| 118 | if (!bi->second.empty())
|
---|
| 119 | {
|
---|
| 120 | opts.lodPercent = StringConverter::parseReal(bi->second);
|
---|
| 121 | opts.usePercent = true;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | bi = binOpt.find("-f");
|
---|
| 126 | if (!bi->second.empty())
|
---|
| 127 | {
|
---|
| 128 | opts.lodFixed = StringConverter::parseInt(bi->second);
|
---|
| 129 | opts.usePercent = false;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | bi = binOpt.find("-log");
|
---|
| 133 | if (!bi->second.empty())
|
---|
| 134 | {
|
---|
| 135 | opts.logFile = bi->second;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | bi = binOpt.find("-E");
|
---|
| 139 | if (!bi->second.empty())
|
---|
| 140 | {
|
---|
| 141 | if (bi->second == "big")
|
---|
| 142 | opts.endian = Serializer::ENDIAN_BIG;
|
---|
| 143 | else if (bi->second == "little")
|
---|
| 144 | opts.endian = Serializer::ENDIAN_LITTLE;
|
---|
| 145 | else
|
---|
| 146 | opts.endian = Serializer::ENDIAN_NATIVE;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | ui = unOpt.find("-d3d");
|
---|
| 150 | if (ui->second)
|
---|
| 151 | {
|
---|
| 152 | opts.d3d = true;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | ui = unOpt.find("-gl");
|
---|
| 156 | if (ui->second)
|
---|
| 157 | {
|
---|
| 158 | opts.gl = true;
|
---|
| 159 | opts.d3d = false;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | }
|
---|
| 163 | // Source / dest
|
---|
| 164 | /*->source = argv;
|
---|
| 165 | source = "objMesh.mesh";
|
---|
| 166 | dest = "objMesh.xml";
|
---|
| 167 | /*->dest = source;
|
---|
| 168 | strcat(dest, ".xml");*/
|
---|
| 169 |
|
---|
| 170 | /*->if (numArgs > startIndex)
|
---|
| 171 | source = args[startIndex];
|
---|
| 172 | if (numArgs > startIndex+1)
|
---|
| 173 | dest = args[startIndex+1];*/
|
---|
| 174 |
|
---|
| 175 | if (!source)
|
---|
| 176 | {
|
---|
| 177 | cout << "Missing source file - abort. " << endl;
|
---|
| 178 | //->help();
|
---|
| 179 | exit(1);
|
---|
| 180 | }
|
---|
| 181 | // Work out what kind of conversion this is
|
---|
| 182 | opts.source = source;
|
---|
| 183 | std::vector<String> srcparts = StringUtil::split(opts.source, ".");
|
---|
| 184 | String& ext = srcparts.back();
|
---|
| 185 | StringUtil::toLowerCase(ext);
|
---|
| 186 | opts.sourceExt = ext;
|
---|
| 187 |
|
---|
| 188 | if (!dest)
|
---|
| 189 | {
|
---|
| 190 | if (opts.sourceExt == "xml")
|
---|
| 191 | {
|
---|
| 192 | // dest is source minus .xml
|
---|
| 193 | opts.dest = opts.source.substr(0, opts.source.size() - 4);
|
---|
| 194 | }
|
---|
| 195 | else
|
---|
| 196 | {
|
---|
| 197 | // dest is source + .xml
|
---|
| 198 | opts.dest = opts.source;
|
---|
| 199 | opts.dest.append(".xml");
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | }
|
---|
| 203 | else
|
---|
| 204 | {
|
---|
| 205 | opts.dest = dest;
|
---|
| 206 | }
|
---|
| 207 | std::vector<String> dstparts = StringUtil::split(opts.dest, ".");
|
---|
| 208 | ext = dstparts.back();
|
---|
| 209 | StringUtil::toLowerCase(ext);
|
---|
| 210 | opts.destExt = ext;
|
---|
| 211 |
|
---|
| 212 | if (!opts.quietMode)
|
---|
| 213 | {
|
---|
| 214 | cout << endl;
|
---|
| 215 | cout << "-- OPTIONS --" << endl;
|
---|
| 216 | cout << "source file = " << opts.source << endl;
|
---|
| 217 | cout << "destination file = " << opts.dest << endl;
|
---|
| 218 | cout << "log file = " << opts.logFile << endl;
|
---|
| 219 | cout << "interactive mode = " << StringConverter::toString(opts.interactiveMode) << endl;
|
---|
| 220 | if (opts.numLods == 0)
|
---|
| 221 | {
|
---|
| 222 | cout << "lod levels = none (or use existing)" << endl;
|
---|
| 223 | }
|
---|
| 224 | else
|
---|
| 225 | {
|
---|
| 226 | cout << "lod levels = " << opts.numLods << endl;
|
---|
| 227 | cout << "lod distance = " << opts.lodDist << endl;
|
---|
| 228 | if (opts.usePercent)
|
---|
| 229 | {
|
---|
| 230 | cout << "lod reduction = " << opts.lodPercent << "%" << endl;
|
---|
| 231 | }
|
---|
| 232 | else
|
---|
| 233 | {
|
---|
| 234 | cout << "lod reduction = " << opts.lodFixed << " verts" << endl;
|
---|
| 235 | }
|
---|
| 236 | }
|
---|
| 237 | cout << "Generate edge lists = " << opts.generateEdgeLists << endl;
|
---|
| 238 | cout << "Generate tangents = " << opts.generateTangents << endl;
|
---|
| 239 | cout << "Reorganise vertex buffers = " << opts.reorganiseBuffers << endl;
|
---|
| 240 | cout << "Optimise animations = " << opts.optimiseAnimations << endl;
|
---|
| 241 |
|
---|
| 242 | cout << "-- END OPTIONS --" << endl;
|
---|
| 243 | cout << endl;
|
---|
| 244 | }
|
---|
| 245 | //
|
---|
| 246 |
|
---|
| 247 | //->parseArgs(argv, opts); |
---|