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.
This commit is contained in:
parent
a6a712cd0c
commit
526f35d953
3 changed files with 50 additions and 0 deletions
BIN
example/content/models/cube.fbx
Normal file
BIN
example/content/models/cube.fbx
Normal file
Binary file not shown.
|
@ -6,6 +6,7 @@ endif()
|
||||||
|
|
||||||
if(BUILD_TOOLS)
|
if(BUILD_TOOLS)
|
||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
|
add_subdirectory(assetpipeline)
|
||||||
add_subdirectory(fontcompiler)
|
add_subdirectory(fontcompiler)
|
||||||
add_subdirectory(editor)
|
add_subdirectory(editor)
|
||||||
add_subdirectory(modelcompiler)
|
add_subdirectory(modelcompiler)
|
||||||
|
|
49
tools/assetpipeline/src/main.cpp
Normal file
49
tools/assetpipeline/src/main.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
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<std::string> 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;
|
||||||
|
}
|
Reference in a new issue