Dump IW4 xmodels as obj

This commit is contained in:
Jan
2021-08-01 00:30:12 +02:00
parent 2c96bc5ef8
commit 24145e15e2
11 changed files with 365 additions and 5 deletions

View File

@ -66,6 +66,13 @@ const CommandLineOption* const OPTION_IMAGE_FORMAT =
.WithParameter("imageFormatValue")
.Build();
const CommandLineOption* const OPTION_MODEL_FORMAT =
CommandLineOption::Builder::Create()
.WithLongName("model-format")
.WithDescription("Specifies the format of dumped model files. Valid values are: XMODEL_EXPORT, OBJ")
.WithParameter("modelFormatValue")
.Build();
const CommandLineOption* const OPTION_GDT =
CommandLineOption::Builder::Create()
.WithLongName("gdt")
@ -82,6 +89,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]
OPTION_OUTPUT_FOLDER,
OPTION_SEARCH_PATH,
OPTION_IMAGE_FORMAT,
OPTION_MODEL_FORMAT,
OPTION_GDT
};
@ -140,6 +148,29 @@ bool UnlinkerArgs::SetImageDumpingMode()
return false;
}
bool UnlinkerArgs::SetModelDumpingMode()
{
auto specifiedValue = m_argument_parser.GetValueForOption(OPTION_MODEL_FORMAT);
for (auto& c : specifiedValue)
c = static_cast<char>(tolower(c));
if (specifiedValue == "xmodel_export")
{
ObjWriting::Configuration.ModelOutputFormat = ObjWriting::Configuration_t::ModelOutputFormat_e::XMODEL_EXPORT;
return true;
}
if (specifiedValue == "obj")
{
ObjWriting::Configuration.ModelOutputFormat = ObjWriting::Configuration_t::ModelOutputFormat_e::XMODEL_EXPORT;
return true;
}
const std::string originalValue = m_argument_parser.GetValueForOption(OPTION_MODEL_FORMAT);
printf("Illegal value: \"%s\" is not a valid model output format. Use -? to see usage information.\n", originalValue.c_str());
return false;
}
bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
{
if (!m_argument_parser.ParseArguments(argc - 1, &argv[1]))
@ -203,6 +234,15 @@ bool UnlinkerArgs::ParseArgs(const int argc, const char** argv)
}
}
// --model-format
if (m_argument_parser.IsOptionSpecified(OPTION_MODEL_FORMAT))
{
if (!SetModelDumpingMode())
{
return false;
}
}
// --gdt
m_use_gdt = m_argument_parser.IsOptionSpecified(OPTION_GDT);