From 02cce6087a3568a00bc2d3a93ca79b3046d243a0 Mon Sep 17 00:00:00 2001 From: ergoxiv Date: Sun, 27 Oct 2024 17:58:59 +0100 Subject: [PATCH] Added a 'Weapons Only' pose import option --- Anamnesis/Actor/Pages/PosePage.xaml | 9 +++++++++ Anamnesis/Actor/Pages/PosePage.xaml.cs | 15 +++++++++++++++ .../Actor/Posing/Visuals/SkeletonVisual3d.cs | 14 ++++++++++++++ Anamnesis/Languages/en.json | 2 ++ 4 files changed, 40 insertions(+) diff --git a/Anamnesis/Actor/Pages/PosePage.xaml b/Anamnesis/Actor/Pages/PosePage.xaml index f667f5a8..093d30b8 100644 --- a/Anamnesis/Actor/Pages/PosePage.xaml +++ b/Anamnesis/Actor/Pages/PosePage.xaml @@ -271,6 +271,15 @@ + + + + + + + SettingsService.Instance; @@ -395,6 +396,11 @@ private async void OnImportSelectedBonesClicked(object sender, RoutedEventArgs e await this.HandleSecondaryOptionImport(PoseImportOptions.SelectedBones); } + private async void OnImportWeaponsClicked(object sender, RoutedEventArgs e) + { + await this.HandleSecondaryOptionImport(PoseImportOptions.WeaponsOnly); + } + private async Task ImportPose(PoseImportOptions importOption, PoseFile.Mode mode) { if (this.Actor == null || this.Skeleton == null) @@ -463,6 +469,15 @@ private async Task ImportPose(PoseImportOptions importOption, PoseFile.Mode mode return; } + if (importOption == PoseImportOptions.WeaponsOnly) + { + this.Skeleton.SelectWeapons(); + var selectedBoneNames = this.Skeleton.SelectedBones.Select(bone => bone.BoneName).ToHashSet(); + poseFile.Apply(this.Actor, this.Skeleton, selectedBoneNames, mode, false); + this.Skeleton.ClearSelection(); + return; + } + // Backup face bone positions before importing the body pose. // "Freeze Position" toggle resets them, so restore after import. Relevant only when pose service is enabled. this.Skeleton.SelectHead(); diff --git a/Anamnesis/Actor/Posing/Visuals/SkeletonVisual3d.cs b/Anamnesis/Actor/Posing/Visuals/SkeletonVisual3d.cs index 293f4ace..9e70183e 100644 --- a/Anamnesis/Actor/Posing/Visuals/SkeletonVisual3d.cs +++ b/Anamnesis/Actor/Posing/Visuals/SkeletonVisual3d.cs @@ -441,6 +441,20 @@ public void SelectHead() this.Select(headBones, SkeletonVisual3d.SelectMode.Add); } + public void SelectWeapons() + { + this.ClearSelection(); + var bonesToSelect = this.mainHandBones.Concat(this.offHandBones).ToList(); + + if (this.GetBone("n_buki_l") is BoneVisual3d boneLeft) + bonesToSelect.Add(boneLeft); + + if (this.GetBone("n_buki_r") is BoneVisual3d boneRight) + bonesToSelect.Add(boneRight); + + this.Select(bonesToSelect, SkeletonVisual3d.SelectMode.Add); + } + public void InvertSelection() { foreach ((string name, BoneVisual3d bone) in this.Bones) diff --git a/Anamnesis/Languages/en.json b/Anamnesis/Languages/en.json index f05f975d..566b44e5 100644 --- a/Anamnesis/Languages/en.json +++ b/Anamnesis/Languages/en.json @@ -327,6 +327,8 @@ "Pose_SelectedTooltip": "Loads a pose onto the actor's selected bones", "Pose_Expression": "Expression Only", "Pose_ExpressionTooltip": "Loads a pose onto the actor's face", + "Pose_WeaponsOnly": "Weapons Only", + "Pose_WeaponsOnlyTooltip": "Loads a pose onto the actor's main hand and off-hand", "Pose_ScalePack": "Body Scale", "Pose_Body": "Body Only", "Pose_BodyTooltip": "Loads a pose onto the entire actor, excluding the face",