From 86c6082bc72a1511cbc0545eaa043851134769f2 Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Fri, 3 Jun 2022 02:43:14 +0100 Subject: [PATCH 1/2] 1.3.1 Arm Flexion Added. --- Editor/AnimRetargetGUI.cs | 93 +++++++++++++++++++++++++++++++++++- Editor/AnimRetargetWindow.cs | 2 +- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/Editor/AnimRetargetGUI.cs b/Editor/AnimRetargetGUI.cs index 1b0a868..66cc1ef 100644 --- a/Editor/AnimRetargetGUI.cs +++ b/Editor/AnimRetargetGUI.cs @@ -40,6 +40,7 @@ public class AnimRetargetGUI static bool closeMouth = false; static float shoulderOffset = 0f; static float armOffset = 0f; + static float armFBOffset = 0f; static float backgroundArmOffset = 0f; static float legOffset = 0f; static float heelOffset = 0f; @@ -60,6 +61,7 @@ public class AnimRetargetGUI static Dictionary shoulderBindings; static Dictionary armBindings; + static Dictionary armFBBindings; static Dictionary legBindings; static Dictionary heelBindings; static Dictionary heightBindings; @@ -155,6 +157,7 @@ static void Reset() closeMouth = false; shoulderOffset = 0f; armOffset = 0f; + armFBOffset = 0f; backgroundArmOffset = 0f; legOffset = 0f; heelOffset = 0f; @@ -197,6 +200,16 @@ static void Reset() } } + armFBBindings = new Dictionary(); + + for (int i = 0; i < curveBindings.Length; i++) + { + if (armFBCurveNames.Contains(curveBindings[i].propertyName)) + { + armFBBindings.Add(curveBindings[i].propertyName, curveBindings[i]); + } + } + legBindings = new Dictionary(); for (int i = 0; i < curveBindings.Length; i++) @@ -318,6 +331,19 @@ public static void DrawRetargeter() AnimPlayerGUI.SampleOnce(); } + EditorGUI.BeginChangeCheck(); + GUILayout.BeginHorizontal(GUILayout.Width(sliderWidth)); + GUILayout.Label(new GUIContent("(Flexion)", "Adjust the Upper Arm Front-Back rotation. Controls the 'Flexion' or 'Extension' of the arms."), GUILayout.Width(textWidth), GUILayout.Height(textHeight)); + armFBOffset = EditorGUILayout.Slider(armFBOffset, -aRange, aRange); + GUILayout.EndHorizontal(); + if (EditorGUI.EndChangeCheck()) + { + OffsetArmsFB(); + animator.gameObject.transform.position = animatorPosition; + animator.gameObject.transform.rotation = animatorRotation; + AnimPlayerGUI.SampleOnce(); + } + EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(GUILayout.Width(sliderWidth)); GUILayout.Label(new GUIContent("Leg", "Adjust the Upper Leg In-Out rotation. Controls the width of the character's stance."), GUILayout.Width(textWidth), GUILayout.Height(textHeight)); @@ -549,6 +575,7 @@ static void OffsetShoulders() } break; case lArm: + case lArmFB: { scale = arScale; eval = true; @@ -557,6 +584,7 @@ static void OffsetShoulders() } break; case rArm: + case rArmFB: { scale = arScale; eval = true; @@ -619,7 +647,7 @@ static void OffsetArms() switch (bind.Key) { - case lArm: + case lArm: { scale = arScale; eval = true; @@ -627,7 +655,7 @@ static void OffsetArms() includeBackgroundVal = true; } break; - case rArm: + case rArm: { scale = arScale; eval = true; @@ -671,6 +699,59 @@ static void OffsetArms() } } + static void OffsetArmsFB() + { + if (!(originalClip && workingClip)) return; + + foreach (KeyValuePair bind in armFBBindings) + { + float scale = 0f; + bool eval = false; + bool subtract = true; + bool includeBackgroundVal = false; + AnimationCurve curve = AnimationUtility.GetEditorCurve(originalClip, bind.Value); + Keyframe[] keys = curve.keys; + + switch (bind.Key) + { + case lArmFB: + { + scale = arScale; + eval = true; + subtract = false; + includeBackgroundVal = false; + } + break; + case rArmFB: + { + scale = arScale; + eval = true; + subtract = false; + includeBackgroundVal = false; + } + break; + } + + float diff = armFBOffset * scale; + if (includeBackgroundVal) + { + diff = (backgroundArmOffset + armFBOffset) * scale; + } + + for (int a = 0; a < keys.Length; a++) + { + + keys[a].value = eval ? EvaluateValue(keys[a].value, subtract ? -diff : diff) : keys[a].value + (subtract ? -diff : diff); + } + curve.keys = keys; + for (int b = 0; b < keys.Length; b++) + { + curve.SmoothTangents(b, 0.0f); + } + AnimationUtility.SetEditorCurve(workingClip, bind.Value, curve); + } + } + static void OffsetLegs() { if (!(originalClip && workingClip)) return; @@ -1073,10 +1154,12 @@ static string NameAnimation(string characterName) // Shoulder, Six curves to consider const string lShoulder = "Left Shoulder Down-Up"; const string lArm = "Left Arm Down-Up"; + const string lArmFB = "Left Arm Front-Back"; const string lArmTwist = "Left Arm Twist In-Out"; const string rShoulder = "Right Shoulder Down-Up"; const string rArm = "Right Arm Down-Up"; + const string rArmFB = "Right Arm Front-Back"; const string rArmTwist = "Right Arm Twist In-Out"; // Arm, Four Curves to consider @@ -1117,6 +1200,12 @@ static string NameAnimation(string characterName) rArmTwist }; + static string[] armFBCurveNames = new string[] + { + lArmFB, + rArmFB, + }; + static string[] legCurveNames = new string[] { lLeg, diff --git a/Editor/AnimRetargetWindow.cs b/Editor/AnimRetargetWindow.cs index 1b1a805..263a6a0 100644 --- a/Editor/AnimRetargetWindow.cs +++ b/Editor/AnimRetargetWindow.cs @@ -11,7 +11,7 @@ public static void OnSceneGUI(SceneView sceneView) { float ypadding = 1f; float width = 320f; - float height = 253f; + float height = 269f; float x = 3f; float y = sceneView.position.height - height - ypadding; From 7c7d1a575d8bb2ed862b6fcca4246e4363b29a53 Mon Sep 17 00:00:00 2001 From: soupday <79094830+soupday@users.noreply.github.com> Date: Fri, 3 Jun 2022 02:47:58 +0100 Subject: [PATCH 2/2] 1.3.1 - --- CHANGELOG.md | 3 +++ Editor/Pipeline.cs | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45863a7..11d35d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Changelog ========= +### v 1.3.1 +- Arm Flexion correction added. + ### v 1.3.0 - Animation correction and facial expression retargeting system added. - Correction sliders for shoulders, arms, legs, heels and height. diff --git a/Editor/Pipeline.cs b/Editor/Pipeline.cs index 07a07e0..be1e354 100644 --- a/Editor/Pipeline.cs +++ b/Editor/Pipeline.cs @@ -40,7 +40,7 @@ public enum MaterialQuality { None, Default, High, Baked } public static class Pipeline { - public const string VERSION = "1.3.0"; + public const string VERSION = "1.3.1"; #if HDRP_10_5_0_OR_NEWER // version diff --git a/package.json b/package.json index b5fbf14..8fb4547 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.soupday.cc3_unity_tools", - "version": "1.3.0", + "version": "1.3.1", "displayName": "CC/iC Unity Tools HDRP", "description": "Unity importer for Character Creator 3 & 4 and iClone 7 and 8.", "unity": "2020.3",