MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / setupModelConvert

Function setupModelConvert

apps/tools/Tools/commands/ModelCommand.cpp:212–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212static 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
264static void setupModelRender(CLI::App& model)
265{

Callers 1

SetupMethod · 0.85

Calls 9

NLevelsMethod · 0.80
LevelMethod · 0.80
ResolutionMethod · 0.80
NNamedSelMethod · 0.80
LoadOptimizedMethod · 0.45
NPointsMethod · 0.45
NFacesMethod · 0.45
NTexturesMethod · 0.45
SaveOptimizedMethod · 0.45

Tested by

no test coverage detected