improve emotion control

This commit is contained in:
CroakFang
2023-07-06 21:26:58 +08:00
parent e9c0a7a428
commit f5573496ee
13 changed files with 76 additions and 55 deletions
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b3e58808cb15120468eafdef64280407
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 59d63bcae2fecff42be7b4fc8b1df10f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7d1083877b3838042b9e91b249731b89
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0512c18ad5403428db876010796c1cda
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 57ddc43ace113674392034825a54600a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d00cc5f8e672c264d856aa10ed20df7e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -87,7 +87,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0
inSlope: 0
outSlope: 0
@@ -115,7 +115,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -143,7 +143,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -171,7 +171,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -199,7 +199,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0
inSlope: 0
outSlope: 0
@@ -228,7 +228,7 @@ AnimationClip:
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.5833333
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
@@ -314,7 +314,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0
inSlope: 0
outSlope: 0
@@ -342,7 +342,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -370,7 +370,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -398,7 +398,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -426,7 +426,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0
inSlope: 0
outSlope: 0
@@ -87,7 +87,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 1
inSlope: 0
outSlope: 0
@@ -115,7 +115,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -143,7 +143,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -171,7 +171,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -199,7 +199,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 1
inSlope: 0
outSlope: 0
@@ -228,7 +228,7 @@ AnimationClip:
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.5833333
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
@@ -314,7 +314,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 1
inSlope: 0
outSlope: 0
@@ -342,7 +342,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -370,7 +370,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -398,7 +398,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 0.3018868
inSlope: 0
outSlope: 0
@@ -426,7 +426,7 @@ AnimationClip:
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5833333
time: 1
value: 1
inSlope: 0
outSlope: 0
+2 -20
View File
@@ -1,11 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using Gallop;
using System.IO;
using static UmaViewerUI;
using System.Xml.Linq;
using System.Windows.Markup;
using System;
public class UmaDatabaseEntry
@@ -72,24 +69,9 @@ public class FaceTypeData
{
public string label, eyebrow_l, eyebrow_r, eye_l, eye_r, mouth, inverce_face_type;
public int mouth_shape_type, set_face_group;
public FaceEmotionKeyTarget target;
public List<EmotionKey> emotionKeys;
private float _weight;
public float Weight
{
get
{
return _weight;
}
set
{
_weight = value;
target.UpdateAllFacialKeyTargets();
}
}
public float weight;
}
[System.Serializable]
+1 -1
View File
@@ -2015,7 +2015,7 @@ public class UmaViewerBuilder : MonoBehaviour
}
if (CurrentUMAContainer.FaceDrivenKeyTarget)
{
CurrentUMAContainer.FaceDrivenKeyTarget.ClearMorph();
CurrentUMAContainer.FaceDrivenKeyTarget.ClearAllWeights();
CurrentUMAContainer.FaceDrivenKeyTarget.ChangeMorph();
}
}
+1 -1
View File
@@ -495,7 +495,7 @@ public class UmaViewerUI : MonoBehaviour
}
var container = Instantiate(UmaContainerSliderPrefab, EmotionList.content).GetComponent<UmaUIContainer>();
container.Name = emotion.label;
container.Slider.value = emotion.Weight;
container.Slider.value = emotion.weight;
container.Slider.maxValue = 1;
container.Slider.minValue = 0;
container.Slider.onValueChanged.AddListener((a) => { target.ChangeEmotionWeight(emotion, a); });
@@ -402,7 +402,7 @@ namespace Gallop
ApplyRotationEar();
}
public void ClearMorph()
public void ClearAllWeights()
{
EarMorphs.ForEach(morph => morph.weight = 0);
EyeBrowMorphs.ForEach(morph => morph.weight = 0);
@@ -520,7 +520,6 @@ namespace Gallop
}
FacialReset(BaseLEyeMorph.trsArray);
FacialReset(BaseREyeMorph.trsArray);
//ApplyRotationEye();
}
public void FacialResetMouth()
@@ -530,7 +529,6 @@ namespace Gallop
OverrideFace(Container.FaceOverrideData);
}
FacialReset(BaseMouthMorph.trsArray);
//ApplyRotationMouth();
}
public void FacialResetEyebrow()
@@ -541,7 +539,6 @@ namespace Gallop
}
FacialReset(BaseLEyeBrowMorph.trsArray);
FacialReset(BaseREyeBrowMorph.trsArray);
//ApplyRotationEyebrow();
}
public void FacialResetEar()
@@ -552,7 +549,6 @@ namespace Gallop
}
FacialReset(BaseLEarMorph.trsArray);
FacialReset(BaseREarMorph.trsArray);
//ApplyRotationEyebrow();
}
public void FacialReset(List<TrsArray> trsArrays)
@@ -44,7 +44,7 @@ public class FaceEmotionKeyTarget : ScriptableObject
}
else
{
newValue.morph = morphs.Where(a => a.tag == splitArray[0] && a.direction == direction).First();
newValue.morph = morphs.FirstOrDefault(a => a.tag == splitArray[0] && a.direction == direction);
}
newValue.weight = Convert.ToInt32(splitArray[1]);
faceTypeData.emotionKeys.Add(newValue);
@@ -58,7 +58,7 @@ public class FaceEmotionKeyTarget : ScriptableObject
}
else
{
newValue.morph = morphs.Where(a => a.tag == morphName && a.direction == direction).First();
newValue.morph = morphs.FirstOrDefault(a => a.tag == morphName && a.direction == direction);
}
newValue.weight = 100;
faceTypeData.emotionKeys.Add(newValue);
@@ -70,14 +70,15 @@ public class FaceEmotionKeyTarget : ScriptableObject
public void ChangeEmotionWeight(FaceTypeData emotion, float val)
{
FaceDrivenKeyTarget.Container.isAnimatorControl = false;
emotion.Weight = val;
emotion.weight = val;
FaceDrivenKeyTarget.ClearAllWeights();
UpdateAllTargetWeight();
FaceDrivenKeyTarget.ChangeMorph();
}
public void UpdateAllFacialKeyTargets()
public void UpdateAllTargetWeight()
{
if (FaceDrivenKeyTarget == null) return;
FaceDrivenKeyTarget.ClearMorph();
foreach (var emotion in FaceEmotionKey)
{
@@ -85,7 +86,7 @@ public class FaceEmotionKeyTarget : ScriptableObject
{
foreach (var key in emotion.emotionKeys)
{
key.morph.weight += key.weight / 100 * emotion.Weight;
key.morph.weight += key.weight / 100 * emotion.weight;
}
}
}