| 70 | } |
| 71 | |
| 72 | static void setupModelInspect(CLI::App& model) |
| 73 | { |
| 74 | auto* cmd = model.add_subcommand("inspect", "Inspect P3D model details"); |
| 75 | static std::string inputPath; |
| 76 | static bool showTextures = false; |
| 77 | static bool showSelections = false; |
| 78 | static bool showSections = false; |
| 79 | static bool showAll = false; |
| 80 | static bool classify = false; |
| 81 | static std::string texRoot; |
| 82 | |
| 83 | cmd->add_option("input", inputPath, "Input P3D file path")->required()->check(CLI::ExistingFile); |
| 84 | cmd->add_flag("-t,--textures", showTextures, "Show texture details"); |
| 85 | cmd->add_flag("-s,--selections", showSelections, "Show named selections"); |
| 86 | cmd->add_flag("--sections", showSections, "Show section details with render hints"); |
| 87 | cmd->add_flag("-a,--all", showAll, "Show all details"); |
| 88 | cmd->add_flag("--classify", classify, "Classify each texture's alpha (opaque/cutout/blend) + render route"); |
| 89 | cmd->add_option("--texroot", texRoot, |
| 90 | "Directory to resolve texture paths from (recursive basename match; defaults to model dir)"); |
| 91 | |
| 92 | cmd->callback( |
| 93 | [&]() |
| 94 | { |
| 95 | auto info = Poseidon::InspectModel(inputPath); |
| 96 | |
| 97 | std::cout << "File: " << inputPath << std::endl; |
| 98 | std::cout << "Format: " << info.format << std::endl; |
| 99 | std::cout << "Version: " << info.version << std::endl; |
| 100 | |
| 101 | if (!info.isSupported) |
| 102 | { |
| 103 | std::cerr << "Warning: Format is not fully supported" << std::endl; |
| 104 | if (!info.errorMessage.empty()) |
| 105 | std::cerr << " " << info.errorMessage << std::endl; |
| 106 | } |
| 107 | |
| 108 | if (!info.valid) |
| 109 | { |
| 110 | std::cerr << "Error: Failed to load " << inputPath << std::endl; |
| 111 | throw CLI::RuntimeError(1); |
| 112 | } |
| 113 | std::cout << std::endl; |
| 114 | |
| 115 | std::cout << "LOD Levels: " << info.lodCount << std::endl; |
| 116 | std::cout << std::endl; |
| 117 | |
| 118 | for (const auto& lod : info.lods) |
| 119 | { |
| 120 | std::cout << "LOD " << lod.index << " (Resolution: " << lod.resolution << ")" << std::endl; |
| 121 | std::cout << " Points: " << std::setw(6) << lod.points << std::endl; |
| 122 | std::cout << " Faces: " << std::setw(6) << lod.faces << std::endl; |
| 123 | std::cout << " Textures: " << std::setw(6) << lod.textures << std::endl; |
| 124 | std::cout << " Selections: " << std::setw(6) << lod.selections << std::endl; |
| 125 | |
| 126 | if (showAll || showTextures) |
| 127 | { |
| 128 | std::cout << " Texture List:" << std::endl; |
| 129 | for (size_t t = 0; t < lod.textureNames.size(); ++t) |
no test coverage detected