From 7eb372a02afdbbea593d1f02ddae3e2d12fae5cf Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 20 Dec 2022 16:32:20 -0800 Subject: GUI: "Finish" avatar generation workflow GUI now generates parameters & menu. Still need to handle write defaults. * Add capability to append to avatar parameters & menu * Install canned Unity assets, shaders, and fonts in avatar folder * Check in materials for ease of use * Bugfix: correctly label menu/parameters file pickers --- GUI/GUI/GUI/Frame.cpp | 4 +- GUI/GUI/GUI/PythonWrapper.cpp | 108 +++++++++++++++++++++++++++++++++++++++--- GUI/package.ps1 | 3 ++ 3 files changed, 107 insertions(+), 8 deletions(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp index 1645258..5029c9c 100644 --- a/GUI/GUI/GUI/Frame.cpp +++ b/GUI/GUI/GUI/Frame.cpp @@ -337,12 +337,12 @@ Frame::Frame() auto* unity_parameters_generated_name = new wxTextCtrl(unity_config_panel_pairs, ID_UNITY_PARAMETERS_GENERATED_NAME); - unity_parameters_generated_name->AppendText("TaSTT_Menu.asset"); + unity_parameters_generated_name->AppendText("TaSTT_Parameters.asset"); unity_parameters_generated_name_ = unity_parameters_generated_name; auto* unity_menu_generated_name = new wxTextCtrl(unity_config_panel_pairs, ID_UNITY_MENU_GENERATED_NAME); - unity_menu_generated_name->AppendText("TaSTT_Parameters.asset"); + unity_menu_generated_name->AppendText("TaSTT_Menu.asset"); unity_menu_generated_name_ = unity_menu_generated_name; auto* sizer = new wxFlexGridSizer(/*cols=*/2); diff --git a/GUI/GUI/GUI/PythonWrapper.cpp b/GUI/GUI/GUI/PythonWrapper.cpp index a2e1313..972982f 100644 --- a/GUI/GUI/GUI/PythonWrapper.cpp +++ b/GUI/GUI/GUI/PythonWrapper.cpp @@ -144,6 +144,8 @@ bool PythonWrapper::GenerateAnimator( // Python script locations std::string libunity_path = "Resources/Scripts/libunity.py"; std::string libtastt_path = "Resources/Scripts/libtastt.py"; + std::string generate_params_path = "Resources/Scripts/generate_params.py"; + std::string generate_menu_path = "Resources/Scripts/generate_menu.py"; // Generated directory locations std::filesystem::path tastt_generated_dir_path = @@ -152,21 +154,27 @@ bool PythonWrapper::GenerateAnimator( tastt_generated_dir_path / "guid.map"; std::filesystem::path tastt_animations_path = tastt_generated_dir_path / "Animations"; - std::filesystem::path tastt_animator_path = - tastt_generated_dir_path / unity_animator_generated_name; + std::filesystem::path tastt_assets_path = + tastt_generated_dir_path / "UnityAssets"; + std::filesystem::path tastt_shaders_path = + tastt_generated_dir_path / "Shaders"; + std::filesystem::path tastt_fonts_path = + tastt_generated_dir_path / "Fonts"; std::filesystem::path tastt_params_path = tastt_generated_dir_path / unity_parameters_generated_name; std::filesystem::path tastt_menu_path = tastt_generated_dir_path / unity_menu_generated_name; - // This is the initial, pre-merge FX controller. + // These are intermediate animators. We apply several transformations before + // arriving at the final animator. std::filesystem::path tastt_fx0_path = tastt_generated_dir_path / "FX0.controller"; std::filesystem::path tastt_fx1_path = tastt_generated_dir_path / "FX1.controller"; std::filesystem::path tastt_fx2_path = tastt_generated_dir_path / "FX2.controller"; - std::filesystem::path tastt_fx3_path = - tastt_generated_dir_path / "FX3.controller"; + // This is the final animator. + std::filesystem::path tastt_animator_path = + tastt_generated_dir_path / unity_animator_generated_name; { if (std::filesystem::exists(tastt_generated_dir_path)) { @@ -194,6 +202,48 @@ bool PythonWrapper::GenerateAnimator( } out->AppendText("success!\n"); } + { + out->AppendText("Copying canned assets... "); + auto opts = std::filesystem::copy_options(); + opts |= std::filesystem::copy_options::overwrite_existing; + opts |= std::filesystem::copy_options::recursive; + std::error_code error; + std::filesystem::copy("Resources/UnityAssets", tastt_assets_path, opts, error); + if (error.value()) { + wxLogError("Failed to copy animations: %s (%d)", error.message(), error.value()); + out->AppendText("failed!\n"); + return false; + } + out->AppendText("success!\n"); + } + { + out->AppendText("Copying canned shaders... "); + auto opts = std::filesystem::copy_options(); + opts |= std::filesystem::copy_options::overwrite_existing; + opts |= std::filesystem::copy_options::recursive; + std::error_code error; + std::filesystem::copy("Resources/Shaders", tastt_shaders_path, opts, error); + if (error.value()) { + wxLogError("Failed to copy animations: %s (%d)", error.message(), error.value()); + out->AppendText("failed!\n"); + return false; + } + out->AppendText("success!\n"); + } + { + out->AppendText("Copying canned fonts... "); + auto opts = std::filesystem::copy_options(); + opts |= std::filesystem::copy_options::overwrite_existing; + opts |= std::filesystem::copy_options::recursive; + std::error_code error; + std::filesystem::copy("Resources/Fonts", tastt_fonts_path, opts, error); + if (error.value()) { + wxLogError("Failed to copy animations: %s (%d)", error.message(), error.value()); + out->AppendText("failed!\n"); + return false; + } + out->AppendText("success!\n"); + } { out->AppendText("Generating guid.map... "); std::string py_stdout, py_stderr; @@ -318,7 +368,7 @@ bool PythonWrapper::GenerateAnimator( std::string py_stdout, py_stderr; if (InvokeWithArgs({ libunity_path, "set_noop_anim", "--fx0", tastt_fx2_path.string(), - "--fx_dest", tastt_fx3_path.string(), + "--fx_dest", tastt_animator_path.string(), "--gen_anim_dir", tastt_animations_path.string(), "--guid_map", guid_map_path.string() }, &py_stdout, &py_stderr)) { @@ -338,6 +388,52 @@ bool PythonWrapper::GenerateAnimator( return false; } } + { + out->AppendText("Generating avatar parameters... "); + std::string py_stdout, py_stderr; + if (InvokeWithArgs({ generate_params_path, + "--old_params", unity_parameters_path, + "--new_params", tastt_params_path.string()}, + &py_stdout, &py_stderr)) { + out->AppendText("success!\n"); + out->AppendText(py_stdout.c_str()); + if (!py_stdout.empty()) { + out->AppendText("\n"); + } + out->AppendText(py_stderr.c_str()); + if (!py_stderr.empty()) { + out->AppendText("\n"); + } + } + else { + wxLogError("Failed to generate avatar parameters: %s", py_stderr.c_str()); + out->AppendText("failed!\n"); + return false; + } + } + { + out->AppendText("Generating avatar menu... "); + std::string py_stdout, py_stderr; + if (InvokeWithArgs({ generate_menu_path, + "--old_menu", unity_menu_path, + "--new_menu", tastt_menu_path.string()}, + &py_stdout, &py_stderr)) { + out->AppendText("success!\n"); + out->AppendText(py_stdout.c_str()); + if (!py_stdout.empty()) { + out->AppendText("\n"); + } + out->AppendText(py_stderr.c_str()); + if (!py_stderr.empty()) { + out->AppendText("\n"); + } + } + else { + wxLogError("Failed to generate avatar menu: %s", py_stderr.c_str()); + out->AppendText("failed!\n"); + return false; + } + } return true; } diff --git a/GUI/package.ps1 b/GUI/package.ps1 index fc51b41..e4f8f3e 100644 --- a/GUI/package.ps1 +++ b/GUI/package.ps1 @@ -7,10 +7,13 @@ if (Test-Path $install_dir) { mkdir $install_dir > $null mkdir $install_dir/Resources > $null cp -Recurse ../Animations TaSTT/Resources/Animations +cp -Recurse ../Fonts TaSTT/Resources/Fonts cp -Recurse ../Images TaSTT/Resources/Images cp -Recurse ../Python TaSTT/Resources/Python cp -Recurse ../Scripts TaSTT/Resources/Scripts +cp -Recurse ../Shaders TaSTT/Resources/Shaders cp -Recurse ../Sounds TaSTT/Resources/Sounds +cp -Recurse ../UnityAssets TaSTT/Resources/UnityAssets cp GUI/x64/Release/GUI.exe TaSTT/TaSTT.exe Compress-Archive -Path "$install_dir" -DestinationPath "$install_dir.zip" -Force -- cgit v1.2.3