improve emotion control
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -2015,7 +2015,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
||||
{
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.ClearMorph();
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.ClearAllWeights();
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.ChangeMorph();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user