Files
jak-project/goalc/build_actor/main.cpp
T
water111 f2e7606f1b [build_actor] Add skeleton and animation support (#3638)
This adds a feature to `build_actor` to support importing skeletons and
animations from .glb files.

Multiple animations are handled and will use the name in the GLB. The
default `viewer` process will end up playing back the first animation.

There are a few limitations:
- You can only have around 100 bones. It is technically possibly to have
slightly more, but certain animations may fail to compress when there
are more than ~100 bones.
- Currently, all animations have 60 keyframes per second. This is a
higher quality than what is normally used. If animation size becomes
problematic, we could make this customizable somehow.
- There is no support for the `align` bone.

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
2024-08-16 11:25:53 -04:00

66 lines
2.0 KiB
C++

#include "common/log/log.h"
#include "common/util/Assert.h"
#include "common/util/FileUtil.h"
#include "goalc/build_actor/jak1/build_actor.h"
#include "third-party/CLI11.hpp"
int main(int argc, char** argv) {
// logging
lg::set_stdout_level(lg::level::info);
lg::set_flush_level(lg::level::info);
lg::initialize();
// game version
std::string game, mdl_name, output_file;
bool gen_collide_mesh = false;
fs::path project_path_override;
// path
if (!file_util::setup_project_path(std::nullopt)) {
return 1;
}
lg::info("Build Actor Tool", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR);
CLI::App app{"OpenGOAL Compiler / REPL"};
app.add_option("input-model", mdl_name,
"Input model file (for example: custom_assets/jak1/models/test.glb)")
->required();
app.add_option("output-file", output_file,
"Output *-ag.go file (for example: out/jak1/obj/test-ag.go)")
->required();
app.add_option("-g,--game", game, "Game version (only jak1 for now)")->required();
app.add_option("--proj-path", project_path_override,
"Specify the location of the 'data/' folder");
app.add_flag("-m,--mesh", gen_collide_mesh, "Whether to generate a collide-mesh for this model");
app.validate_positionals();
CLI11_PARSE(app, argc, argv)
GameVersion game_version = game_name_to_version(game);
if (!project_path_override.empty()) {
if (!fs::exists(project_path_override)) {
lg::error("Error: project path override '{}' does not exist", project_path_override.string());
return 1;
}
if (!file_util::setup_project_path(project_path_override)) {
lg::error("Could not setup project path!");
return 1;
}
} else if (!file_util::setup_project_path(std::nullopt)) {
return 1;
}
switch (game_version) {
case GameVersion::Jak1:
jak1::run_build_actor(mdl_name, output_file, gen_collide_mesh);
break;
default:
ASSERT_NOT_REACHED_MSG("unsupported game version");
}
return 0;
}