When invoking the model compiler in "no ui" mode, specify absolute path
This is going to be used in the future "asset pipeline" tool. The auto export animations and materials flags are also turned off in "no ui" mode.
This commit is contained in:
parent
cbf1246e2f
commit
a6a712cd0c
2 changed files with 20 additions and 8 deletions
|
@ -17,5 +17,5 @@ public:
|
|||
|
||||
std::string data_path, model_path;
|
||||
|
||||
void compile_model();
|
||||
void compile_model(std::string compiled_model_path);
|
||||
};
|
||||
|
|
|
@ -31,18 +31,23 @@ void app_main(prism::engine* engine) {
|
|||
{editor->getDefaultX(), editor->getDefaultY(), 300, 300},
|
||||
WindowFlags::None);
|
||||
} else {
|
||||
std::string compiled_model_path;
|
||||
|
||||
for(auto [i, argument] : utility::enumerate(engine->command_line_arguments)) {
|
||||
if(argument == "--model-path")
|
||||
editor->model_path = engine->command_line_arguments[i + 1];
|
||||
|
||||
if(argument == "--data-path")
|
||||
editor->data_path = engine->command_line_arguments[i + 1];
|
||||
if(argument == "--compiled-model-path")
|
||||
compiled_model_path = engine->command_line_arguments[i + 1];
|
||||
|
||||
if(argument == "--compile-static")
|
||||
editor->flags.compile_static = true;
|
||||
}
|
||||
|
||||
editor->compile_model();
|
||||
editor->flags.export_animations = false;
|
||||
editor->flags.export_materials = false;
|
||||
|
||||
editor->compile_model(compiled_model_path);
|
||||
|
||||
platform::force_quit();
|
||||
}
|
||||
|
@ -159,7 +164,7 @@ void write_string(FILE* file, const std::string& str) {
|
|||
}
|
||||
}
|
||||
|
||||
void ModelEditor::compile_model() {
|
||||
void ModelEditor::compile_model(std::string compiled_model_path) {
|
||||
struct BoneWeight {
|
||||
unsigned int vertex_index = 0, bone_index = 0;
|
||||
float weight = 0.0f;
|
||||
|
@ -209,7 +214,9 @@ void ModelEditor::compile_model() {
|
|||
auto name = model_path.substr(model_path.find_last_of("/") + 1, model_path.length());
|
||||
name = name.substr(0, name.find_last_of("."));
|
||||
|
||||
FILE* file = fopen((data_path + "/models/" + name + ".model").c_str(), "wb");
|
||||
FILE* file = fopen(compiled_model_path.c_str(), "wb");
|
||||
|
||||
fmt::print("Exporting to {}...\n", compiled_model_path);
|
||||
|
||||
int version = 7;
|
||||
fwrite(&version, sizeof(int), 1, file);
|
||||
|
@ -418,6 +425,8 @@ void ModelEditor::compile_model() {
|
|||
|
||||
fclose(file);
|
||||
|
||||
fmt::print("Finished writing model!\n");
|
||||
|
||||
if(flags.export_materials) {
|
||||
for(int i = 0; i < sc->mNumMaterials; i++) {
|
||||
auto path = data_path + "/materials/" + sc->mMaterials[i]->GetName().C_Str() + ".material";
|
||||
|
@ -538,8 +547,11 @@ void ModelEditor::drawUI() {
|
|||
if(!model_path.empty() && !data_path.empty()) {
|
||||
ImGui::Text("%s will be compiled for data path %s", model_path.c_str(), data_path.c_str());
|
||||
|
||||
if(ImGui::Button("Compile"))
|
||||
compile_model();
|
||||
if(ImGui::Button("Compile")) {
|
||||
auto name = model_path.substr(model_path.find_last_of("/") + 1, model_path.length());
|
||||
name = name.substr(0, name.find_last_of("."));
|
||||
compile_model(data_path + "/models/" + name + ".model");
|
||||
}
|
||||
} else {
|
||||
ImGui::TextColored(ImVec4(1.0, 0.0, 0.0, 1.0), "Please select a path first before compiling!");
|
||||
}
|
||||
|
|
Reference in a new issue