From 526f35d953e91f600b0b6d43b4f95b1ca2f7b121 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 21 May 2022 17:52:24 -0400 Subject: [PATCH] Add asset pipeline tool to aid in converting to compiled game formats This isn't invoked automatically (yet) but right now already compiles non-existent models from the "content" directory to the game directory. --- example/content/models/cube.fbx | Bin 0 -> 14828 bytes tools/CMakeLists.txt | 1 + tools/assetpipeline/src/main.cpp | 49 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 example/content/models/cube.fbx create mode 100644 tools/assetpipeline/src/main.cpp diff --git a/example/content/models/cube.fbx b/example/content/models/cube.fbx new file mode 100644 index 0000000000000000000000000000000000000000..52171d3747260580cb32e6465639547956c2a37e GIT binary patch literal 14828 zcmc&*dypK(d7tAX-9z$$1PGZ(a267Jq0^ltkU%)Pmrg9&y*uCDoe%|qx!t+DLAx{S z*;#Q1f<#X20zXjk2gSp7m0t;t3Biz_=(;w-&*`1m0@7Ld}zy7*=?~pm4H9fO)sQwO<@vT%+|xY+K`H%}xSB@O%keenW=cev@N#LA9ZLJ2?aZX9628NiAsX(OcAHyQhCSGPSNUs5D3CK4{BwB04vu7}LbHa2GvEY`RtYibV#)r|IA|!F4 z?+fu2P#o_o6moV(46aGI8}zJ8gqDWHS%tg6A%_SrNFGwiBd7&39lsv(u!&(?ANK+c zcY&k7p}_kj_@9J;tI;2VzYJ7zxC}xC)Iv(aadebxpGf;XLt8i;;*Z_yZasmt&GcfQHCC}b5?}>^e4?tz5^tPZEVB^g|^```6@U+aEL5iNeAxMc;1C3XgJa0UWFFlq!oP6|+LG69Ny)jcLfNq28x^(I?|_S$C%RwsVSKi>-wI{Jet)c} zdnDJKGlHBcnV#-%*g4ZwIF2Dv#yb7bkDy0l#Tg#z|DanIEf+d z#t!zUDZhM;8$)qa?`9IHY^)|5ddQ$PZI*KW046Wb42eGHp&hb?Y$=08Z4{|*0V#}q z%(`2_ZA3jpCQqDSQf}5tGrn6+DPNge5}XB|S0u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;j%o8c1{4kBpQ +#include +#include + +int main(int argc, char* argv[]) { + fmt::print("Asset compiler running....\n"); + + std::string dataDirectory = argv[1]; + fmt::print("Content directory to check: {}\n", dataDirectory); + + std::string gameDirectory = argv[2]; + fmt::print("Game directory to output compiled assets in: {}\n", gameDirectory); + + for(auto const& dir_entry : std::filesystem::recursive_directory_iterator{dataDirectory}) { + if(dir_entry.path().extension() == ".fbx") { + + fmt::print("Found fbx: {}\n", dir_entry.path().c_str()); + + auto rel_path = relative(dir_entry.path(), dataDirectory); + auto new_game_path = gameDirectory / rel_path; + new_game_path = new_game_path.replace_extension(".model"); + + fmt::print("Equivalent file in the game directory: {}\n", new_game_path.c_str()); + + if(!exists(new_game_path)) { + fmt::print("Compiled version does not exist!\n"); + + std::vector model_compiler_args; + model_compiler_args.emplace_back("./ModelCompiler"); // TODO: sorry win32 + model_compiler_args.emplace_back("--no_ui"); + model_compiler_args.emplace_back("--model-path"); + model_compiler_args.emplace_back(dir_entry.path().c_str()); + model_compiler_args.emplace_back("--compiled-model-path"); + model_compiler_args.emplace_back(new_game_path.c_str()); + + std::string compiled_command; + for(const auto& arg : model_compiler_args) { + compiled_command += arg + " "; + } + + fmt::print("Running {}...\n", compiled_command); + + system(compiled_command.c_str()); + } + } + } + + return 0; +} \ No newline at end of file