| 210 | } |
| 211 | |
| 212 | static void setupModelConvert(CLI::App& model) |
| 213 | { |
| 214 | auto* cmd = model.add_subcommand("convert", "Convert P3D model formats (MLOD/ODOL)"); |
| 215 | static std::string inputPath; |
| 216 | static std::string outputPath; |
| 217 | static bool verbose = false; |
| 218 | |
| 219 | cmd->add_option("input", inputPath, "Input P3D file path")->required()->check(CLI::ExistingFile); |
| 220 | cmd->add_option("output", outputPath, "Output P3D file path")->required(); |
| 221 | cmd->add_flag("-v,--verbose", verbose, "Verbose output"); |
| 222 | |
| 223 | cmd->callback( |
| 224 | [&]() |
| 225 | { |
| 226 | if (verbose) |
| 227 | std::cout << "Converting: " << inputPath << " -> " << outputPath << std::endl; |
| 228 | |
| 229 | auto* shape = new LODShapeWithShadow(); |
| 230 | if (!shape->LoadOptimized(inputPath.c_str())) |
| 231 | { |
| 232 | std::cerr << "Error: Failed to load " << inputPath << std::endl; |
| 233 | delete shape; |
| 234 | throw CLI::RuntimeError(1); |
| 235 | } |
| 236 | |
| 237 | if (verbose) |
| 238 | { |
| 239 | std::cout << "Loaded successfully" << std::endl; |
| 240 | std::cout << "LOD levels: " << static_cast<int>(shape->NLevels()) << std::endl; |
| 241 | for (int i = 0; i < shape->NLevels(); ++i) |
| 242 | { |
| 243 | Shape* lod = shape->Level(i); |
| 244 | if (lod) |
| 245 | { |
| 246 | std::cout << " LOD " << i << " (res=" << shape->Resolution(i) << "): " << lod->NPoints() |
| 247 | << " points, " << lod->NFaces() << " faces, " << lod->NTextures() << " textures, " |
| 248 | << lod->NNamedSel() << " selections" << std::endl; |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | shape->SaveOptimized(outputPath.c_str()); |
| 254 | |
| 255 | if (verbose) |
| 256 | std::cout << "Saved successfully as ODOL v7" << std::endl; |
| 257 | else |
| 258 | std::cout << "Converted: " << inputPath << " -> " << outputPath << std::endl; |
| 259 | |
| 260 | delete shape; |
| 261 | }); |
| 262 | } |
| 263 | |
| 264 | static void setupModelRender(CLI::App& model) |
| 265 | { |
no test coverage detected