+1551
-45
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ using UnityEngine;
|
||||
|
||||
public class UmaContainer : MonoBehaviour
|
||||
{
|
||||
UmaViewerUI UI => UmaViewerUI.Instance;
|
||||
|
||||
public JObject CharaData;
|
||||
public GameObject Body;
|
||||
public GameObject Tail;
|
||||
@@ -18,9 +20,8 @@ public class UmaContainer : MonoBehaviour
|
||||
public AnimatorOverrideController OverrideController;
|
||||
|
||||
[Header("Face")]
|
||||
public List<AnimationClip> FacialClips = new List<AnimationClip>();
|
||||
public FaceDrivenKeyTarget FaceDrivenKeyTargets;
|
||||
|
||||
public FaceDrivenKeyTarget FaceDrivenKeyTarget;
|
||||
public FaceEmotionKeyTarget FaceEmotionKeyTarget;
|
||||
|
||||
[Header("Generic")]
|
||||
public bool IsGeneric = false;
|
||||
@@ -31,16 +32,6 @@ public class UmaContainer : MonoBehaviour
|
||||
public bool IsMini = false;
|
||||
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (TryGetComponent<PuppetMaster>(out PuppetMaster t))
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
else { Destroy(gameObject); }
|
||||
|
||||
}
|
||||
|
||||
public void MergeModel()
|
||||
{
|
||||
if (!Body) return;
|
||||
@@ -92,7 +83,7 @@ public class UmaContainer : MonoBehaviour
|
||||
UmaAnimator = gameObject.AddComponent<Animator>();
|
||||
UmaAnimator.avatar = AvatarBuilder.BuildGenericAvatar(gameObject, gameObject.name);
|
||||
UmaAnimator.runtimeAnimatorController = OverrideController = Instantiate(UmaViewerBuilder.Instance.OverrideController);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Transform[] MergeBone(SkinnedMeshRenderer from, List<Transform> targetBones)
|
||||
@@ -121,15 +112,16 @@ public class UmaContainer : MonoBehaviour
|
||||
}
|
||||
}
|
||||
from.bones = tmpBone;
|
||||
return emptyBones.ToArray() ;
|
||||
return emptyBones.ToArray();
|
||||
}
|
||||
|
||||
public void LoadPhysics()
|
||||
{
|
||||
var springs = PhysicsController.GetComponentsInChildren<CySpringDataContainer>();
|
||||
var springs = PhysicsController.GetComponentsInChildren<CySpringDataContainer>();
|
||||
foreach (CySpringDataContainer spring in springs)
|
||||
{
|
||||
spring.InitializePhysics();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections;
|
||||
using RootMotion.Dynamics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Gallop;
|
||||
|
||||
public class UmaDatabaseEntry
|
||||
{
|
||||
@@ -30,11 +32,36 @@ public class UmaLyricsData
|
||||
public string text;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class EmotionKey
|
||||
{
|
||||
public FacialMorph morph;
|
||||
public float weight;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
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 enum UmaFileType
|
||||
|
||||
@@ -177,7 +177,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
int head_id;
|
||||
string head_costumeId;
|
||||
int tailId = (int)charaData["tailModelId"];
|
||||
|
||||
|
||||
//The tailId of 9006 is 1, but the character has no tail
|
||||
if (id == 9006) tailId = -1;
|
||||
|
||||
@@ -192,10 +192,12 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
head_id = id;
|
||||
head_costumeId = costumeId;
|
||||
|
||||
CurrentHead = new UmaHeadData();
|
||||
CurrentHead.id = id;
|
||||
CurrentHead.costumeId = costumeId;
|
||||
CurrentHead.tailId = tailId;
|
||||
CurrentHead = new UmaHeadData
|
||||
{
|
||||
id = id,
|
||||
costumeId = costumeId,
|
||||
tailId = tailId
|
||||
};
|
||||
}
|
||||
|
||||
string head = UmaDatabaseController.HeadPath + $"chr{head_id}_{head_costumeId}/pfb_chr{head_id}_{head_costumeId}";
|
||||
@@ -237,7 +239,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (tailId != 0)
|
||||
{
|
||||
string tailName = $"tail{tailId.ToString().PadLeft(4, '0')}_00";
|
||||
@@ -271,8 +273,16 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
var firsehead = CurrentUMAContainer.Head;
|
||||
var FaceDriven = firsehead.GetComponent<AssetHolder>()._assetTable.list.Find(a => { return a.Key == "facial_target"; }).Value as FaceDrivenKeyTarget;
|
||||
CurrentUMAContainer.FaceDrivenKeyTargets = FaceDriven;
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget = FaceDriven;
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.Container = CurrentUMAContainer;
|
||||
FaceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
|
||||
|
||||
CurrentUMAContainer.FaceEmotionKeyTarget = new FaceEmotionKeyTarget()
|
||||
{
|
||||
FaceDrivenKeyTarget = FaceDriven,
|
||||
FaceEmotionKey = UmaDatabaseController.Instance.FaceTypeData.ToList()
|
||||
};
|
||||
CurrentUMAContainer.FaceEmotionKeyTarget.Initialize();
|
||||
}
|
||||
|
||||
CurrentUMAContainer.MergeModel();
|
||||
@@ -387,7 +397,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
var asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith("cutt_son" + live.MusicId));
|
||||
var BGasset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name.EndsWith($"pfb_env_live{live.BackGroundId}_controller000"));
|
||||
if (asset == null|| BGasset == null) return;
|
||||
if (asset == null || BGasset == null) return;
|
||||
|
||||
UnloadLive();
|
||||
UnloadAllBundle();
|
||||
@@ -507,7 +517,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
int sampleRate = stream.WaveFormat.SampleRate;
|
||||
|
||||
AudioClip clip = AudioClip.Create(
|
||||
Path.GetFileNameWithoutExtension(awb.Name)+"_"+wave.WaveId.ToString(),
|
||||
Path.GetFileNameWithoutExtension(awb.Name) + "_" + wave.WaveId.ToString(),
|
||||
(int)(stream.Length / channels / bytesPerSample),
|
||||
channels,
|
||||
sampleRate,
|
||||
@@ -543,11 +553,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
bundle = AssetBundle.LoadFromFile(filePath);
|
||||
Main.LoadedBundles.Add(lyricsAsset.Name, bundle);
|
||||
}
|
||||
|
||||
|
||||
TextAsset asset = bundle.LoadAsset<TextAsset>(Path.GetFileNameWithoutExtension(lyricsVar));
|
||||
string[] lines = asset.text.Split("\n"[0]);
|
||||
|
||||
for (int i = 1; i < lines.Length; i++)
|
||||
for (int i = 1; i < lines.Length; i++)
|
||||
{
|
||||
string[] words = lines[i].Split(',');
|
||||
if (words.Length > 0)
|
||||
@@ -561,13 +571,13 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
};
|
||||
CurrentLyrics.Add(lyricsData);
|
||||
}
|
||||
catch{}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void RecursiveLoadAsset(UmaDatabaseEntry entry, bool IsSubAsset = false)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(entry.Prerequisites))
|
||||
@@ -804,7 +814,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
private void LoadHead(GameObject go)
|
||||
{
|
||||
GameObject head = Instantiate(go, CurrentUMAContainer.transform);
|
||||
CurrentUMAContainer.Head=head;
|
||||
CurrentUMAContainer.Head = head;
|
||||
|
||||
foreach (Renderer r in head.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
@@ -933,11 +943,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
RecursiveLoadAsset(motion_e);
|
||||
RecursiveLoadAsset(motion_s);
|
||||
}
|
||||
|
||||
|
||||
var lastTime = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime;
|
||||
CurrentUMAContainer.OverrideController["clip_1"] = CurrentUMAContainer.OverrideController["clip_2"];
|
||||
CurrentUMAContainer.OverrideController["clip_2"] = clip;
|
||||
|
||||
|
||||
CurrentUMAContainer.UmaAnimator.Play("motion_1", -1);
|
||||
CurrentUMAContainer.UmaAnimator.SetTrigger(needTransit ? "next_s" : "next");
|
||||
}
|
||||
@@ -1009,7 +1019,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
|
||||
public void UnloadProp()
|
||||
{
|
||||
if(CurrentOtherContainer != null)
|
||||
if (CurrentOtherContainer != null)
|
||||
{
|
||||
Destroy(CurrentOtherContainer.gameObject);
|
||||
}
|
||||
@@ -1027,8 +1037,29 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
if (CurrentUMAContainer != null)
|
||||
{
|
||||
//It seems that OnDestroy will executed after new model loaded, which cause new FacialPanels empty...
|
||||
UmaViewerUI.Instance.currentFaceDrivenKeyTarget = null;
|
||||
UmaViewerUI.Instance.LoadEmotionPanels(null);
|
||||
UmaViewerUI.Instance.LoadFacialPanels(null);
|
||||
Destroy(CurrentUMAContainer.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearMorphs()
|
||||
{
|
||||
if (CurrentUMAContainer != null && CurrentUMAContainer.FaceDrivenKeyTarget != null)
|
||||
{
|
||||
foreach (var container in UI.EmotionList.GetComponentsInChildren<UmaUIContainer>())
|
||||
{
|
||||
if (container.Slider != null)
|
||||
container.Slider.value = 0;
|
||||
}
|
||||
foreach (var container in UI.FacialList.GetComponentsInChildren<UmaUIContainer>())
|
||||
{
|
||||
if (container.Slider != null)
|
||||
container.Slider.SetValueWithoutNotify(0);
|
||||
}
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.ClearMorph();
|
||||
CurrentUMAContainer.FaceDrivenKeyTarget.ChangeMorph();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -31,6 +32,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
public ScrollRect PropList;
|
||||
public ScrollRect SceneList;
|
||||
|
||||
public ScrollRect EmotionList;
|
||||
public ScrollRect FacialList;
|
||||
public ScrollRect LiveList;
|
||||
public ScrollRect LiveSoundList;
|
||||
@@ -77,6 +79,8 @@ public class UmaViewerUI : MonoBehaviour
|
||||
public bool isCriware = false;
|
||||
public bool isHeadFix = false;
|
||||
|
||||
public FaceDrivenKeyTarget currentFaceDrivenKeyTarget;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
@@ -89,6 +93,40 @@ public class UmaViewerUI : MonoBehaviour
|
||||
canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Shrink;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Builder.CurrentAudioSources.Count > 0)
|
||||
{
|
||||
AudioSource MianSource = Builder.CurrentAudioSources[0];
|
||||
if (MianSource.clip)
|
||||
{
|
||||
TitleText.text = MianSource.clip.name;
|
||||
ProgressText.text = string.Format("{0} / {1}", ToTimeFormat(MianSource.time), ToTimeFormat(MianSource.clip.length));
|
||||
AudioSlider.SetValueWithoutNotify(MianSource.time / MianSource.clip.length);
|
||||
LyricsText.text = GetCurrentLyrics(MianSource.time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.OverrideController != null)
|
||||
{
|
||||
if (Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2")
|
||||
{
|
||||
bool isLoop = Builder.CurrentUMAContainer.OverrideController["clip_2"].name.EndsWith("_loop");
|
||||
var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0);
|
||||
var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"];
|
||||
if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0)
|
||||
{
|
||||
var normalizedTime = (isLoop) ? Mathf.Repeat(AnimeState.normalizedTime, 1) : Mathf.Min(AnimeState.normalizedTime, 1);
|
||||
|
||||
AnimationTitleText.text = AnimeClip.name;
|
||||
AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate));
|
||||
AnimationSlider.SetValueWithoutNotify(normalizedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HighlightChildImage(Transform mainObject, Image child)
|
||||
{
|
||||
foreach(var t in mainObject.GetComponentsInChildren<Image>())
|
||||
@@ -164,10 +202,13 @@ public class UmaViewerUI : MonoBehaviour
|
||||
|
||||
public void LoadFacialPanels(FaceDrivenKeyTarget target)
|
||||
{
|
||||
currentFaceDrivenKeyTarget = target;
|
||||
|
||||
foreach (UmaUIContainer ui in FacialList.content.GetComponentsInChildren<UmaUIContainer>())
|
||||
{
|
||||
Destroy(ui.gameObject);
|
||||
}
|
||||
|
||||
if (target == null) return;
|
||||
List<FacialMorph> tempMorph = new List<FacialMorph>();
|
||||
tempMorph.AddRange(target.EyeBrowMorphs);
|
||||
@@ -176,11 +217,40 @@ public class UmaViewerUI : MonoBehaviour
|
||||
foreach (FacialMorph morph in tempMorph)
|
||||
{
|
||||
var container = Instantiate(UmaContainerSliderPrefab, FacialList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = morph.name;
|
||||
container.Slider.value = morph.Weight;
|
||||
container.Name.text = morph.name + " (" + morph.tag + ")";
|
||||
container.Slider.value = morph.weight;
|
||||
container.Slider.maxValue = 1;
|
||||
container.Slider.minValue = 0;
|
||||
container.Slider.onValueChanged.AddListener((a) => { morph.Weight = a;});
|
||||
container.Slider.onValueChanged.AddListener((a) => { target.ChangeMorphWeight(morph, a); });
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFacialPanels()
|
||||
{
|
||||
LoadFacialPanels(currentFaceDrivenKeyTarget);
|
||||
}
|
||||
|
||||
public void LoadEmotionPanels(FaceEmotionKeyTarget target)
|
||||
{
|
||||
foreach (UmaUIContainer ui in EmotionList.content.GetComponentsInChildren<UmaUIContainer>())
|
||||
{
|
||||
Destroy(ui.gameObject);
|
||||
}
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
foreach(var emotion in target.FaceEmotionKey)
|
||||
{
|
||||
if (emotion.label == "Base")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var container = Instantiate(UmaContainerSliderPrefab, EmotionList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = emotion.label;
|
||||
container.Slider.value = emotion.Weight;
|
||||
container.Slider.maxValue = 1;
|
||||
container.Slider.minValue = 0;
|
||||
container.Slider.onValueChanged.AddListener((a) => { emotion.Weight = a; });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,40 +681,6 @@ public class UmaViewerUI : MonoBehaviour
|
||||
Builder.CurrentUMAContainer.UmaAnimator.speed = val;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Builder.CurrentAudioSources.Count > 0)
|
||||
{
|
||||
AudioSource MianSource = Builder.CurrentAudioSources[0];
|
||||
if (MianSource.clip)
|
||||
{
|
||||
TitleText.text = MianSource.clip.name;
|
||||
ProgressText.text = string.Format("{0} / {1}", ToTimeFormat(MianSource.time), ToTimeFormat(MianSource.clip.length));
|
||||
AudioSlider.SetValueWithoutNotify(MianSource.time/ MianSource.clip.length);
|
||||
LyricsText.text = GetCurrentLyrics(MianSource.time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Builder.CurrentUMAContainer != null && Builder.CurrentUMAContainer.OverrideController != null)
|
||||
{
|
||||
if(Builder.CurrentUMAContainer.OverrideController["clip_2"].name != "clip_2")
|
||||
{
|
||||
bool isLoop = Builder.CurrentUMAContainer.OverrideController["clip_2"].name.EndsWith("_loop");
|
||||
var AnimeState = Builder.CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0);
|
||||
var AnimeClip = Builder.CurrentUMAContainer.OverrideController["clip_2"];
|
||||
if (AnimeClip && Builder.CurrentUMAContainer.UmaAnimator.speed != 0)
|
||||
{
|
||||
var normalizedTime = (isLoop) ? Mathf.Repeat(AnimeState.normalizedTime, 1) : Mathf.Min(AnimeState.normalizedTime, 1);
|
||||
|
||||
AnimationTitleText.text = AnimeClip.name;
|
||||
AnimationProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate));
|
||||
AnimationSlider.SetValueWithoutNotify(normalizedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAudioPlayer()
|
||||
{
|
||||
TitleText.text = "No Audio";
|
||||
|
||||
@@ -2,6 +2,8 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Gallop.Live.Cutt;
|
||||
using System;
|
||||
|
||||
namespace Gallop
|
||||
{
|
||||
@@ -20,6 +22,10 @@ namespace Gallop
|
||||
public List<FacialMorph> EyeMorphs = new List<FacialMorph>();
|
||||
public List<FacialMorph> MouthMorphs = new List<FacialMorph>();
|
||||
|
||||
public bool needUpdate = false;
|
||||
public bool needAllUpdate = false;
|
||||
public UmaContainer Container;
|
||||
|
||||
Dictionary<Transform, Vector3> RotationRecorder = new Dictionary<Transform, Vector3>();
|
||||
public void Initialize(List<Transform> objs)
|
||||
{
|
||||
@@ -33,6 +39,7 @@ namespace Gallop
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "EyeBrow_" + i + "_" + (morph.direction ? "L" : "R");
|
||||
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialEyebrowId), i);
|
||||
morph.trsArray = _eyebrowTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
@@ -58,6 +65,7 @@ namespace Gallop
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "Eye_" + i + "_" + (morph.direction ? "L" : "R");
|
||||
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialEyeId), i);
|
||||
morph.trsArray = _eyeTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
@@ -83,6 +91,7 @@ namespace Gallop
|
||||
morph.target = this;
|
||||
morph.direction = j > 0;
|
||||
morph.name = "Mouth_" + i + "_" + j;
|
||||
morph.tag = Enum.GetName(typeof(LiveTimelineDefine.FacialMouthId), i);
|
||||
morph.trsArray = _mouthTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
@@ -98,23 +107,27 @@ namespace Gallop
|
||||
}
|
||||
}
|
||||
}
|
||||
FacialReset();
|
||||
MouthMorphs[3].Weight = 1;
|
||||
if (UmaViewerUI.Instance) { UmaViewerUI.Instance.LoadFacialPanels(this); }
|
||||
FacialResetAll();
|
||||
ChangeMorphWeight(MouthMorphs[3], 1);
|
||||
|
||||
if (UmaViewerUI.Instance)
|
||||
{
|
||||
UmaViewerUI.Instance.LoadFacialPanels(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ChangeMorph()
|
||||
{
|
||||
FacialReset();
|
||||
FacialResetAll();
|
||||
|
||||
foreach (FacialMorph morph in EyeBrowMorphs)
|
||||
{
|
||||
ProcessMorph(morph);
|
||||
ProcessMorph(morph);
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in EyeMorphs)
|
||||
{
|
||||
ProcessMorph(morph);
|
||||
ProcessMorph(morph);
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in MouthMorphs)
|
||||
@@ -124,89 +137,76 @@ namespace Gallop
|
||||
|
||||
ApplyRotation();
|
||||
}
|
||||
|
||||
public void ClearMorph()
|
||||
{
|
||||
foreach (FacialMorph morph in EyeBrowMorphs)
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in EyeMorphs)
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
|
||||
foreach (FacialMorph morph in MouthMorphs)
|
||||
{
|
||||
morph.weight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMorph(FacialMorph morph)
|
||||
{
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localScale += trs._scale * morph.Weight;
|
||||
trs.transform.localPosition += trs._position * morph.Weight;
|
||||
RotationRecorder[trs.transform] += trs._rotation * morph.Weight;
|
||||
trs.transform.localScale += trs._scale * morph.weight;
|
||||
trs.transform.localPosition += trs._position * morph.weight;
|
||||
RotationRecorder[trs.transform] += trs._rotation * morph.weight;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void FacialReset()
|
||||
public void FacialResetAll()
|
||||
{
|
||||
foreach (TrsArray trs in BaseLEyeBrowMorph.trsArray)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
RotationRecorder[trs.transform] = trs._rotation;
|
||||
};
|
||||
}
|
||||
|
||||
foreach (TrsArray trs in BaseREyeBrowMorph.trsArray)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
RotationRecorder[trs.transform] = trs._rotation;
|
||||
};
|
||||
}
|
||||
|
||||
foreach (TrsArray trs in BaseLEyeMorph.trsArray)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
RotationRecorder[trs.transform] = trs._rotation;
|
||||
};
|
||||
}
|
||||
|
||||
foreach (TrsArray trs in BaseREyeMorph.trsArray)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
RotationRecorder[trs.transform] = trs._rotation;
|
||||
};
|
||||
}
|
||||
|
||||
foreach (TrsArray trs in BaseMouthMorph.trsArray)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
RotationRecorder[trs.transform] = trs._rotation;
|
||||
};
|
||||
}
|
||||
|
||||
FacialReset(BaseLEyeBrowMorph.trsArray);
|
||||
FacialReset(BaseREyeBrowMorph.trsArray);
|
||||
FacialReset(BaseLEyeMorph.trsArray);
|
||||
FacialReset(BaseREyeMorph.trsArray);
|
||||
FacialReset(BaseMouthMorph.trsArray);
|
||||
ApplyRotation();
|
||||
}
|
||||
|
||||
public void ApplyRotation(){
|
||||
public void FacialReset(List<TrsArray> trsArrays)
|
||||
{
|
||||
foreach (TrsArray trs in trsArrays)
|
||||
{
|
||||
if (trs.transform)
|
||||
{
|
||||
trs.transform.localPosition = trs._position;
|
||||
trs.transform.localScale = trs._scale;
|
||||
RotationRecorder[trs.transform] = trs._rotation;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyRotation()
|
||||
{
|
||||
foreach (var trs in RotationRecorder)
|
||||
{
|
||||
trs.Key.localRotation = RotationConvert.fromMaya(trs.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ChangeMorphWeight(FacialMorph morph,float val)
|
||||
{
|
||||
morph.weight = val;
|
||||
ChangeMorph();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
using Gallop;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
public class FaceEmotionKeyTarget : ScriptableObject
|
||||
{
|
||||
public List<FaceTypeData> FaceEmotionKey;
|
||||
public FaceDrivenKeyTarget FaceDrivenKeyTarget;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
foreach (var emotion in FaceEmotionKey)
|
||||
{
|
||||
if (emotion.label == "Base") continue;
|
||||
emotion.target = this;
|
||||
emotion.emotionKeys = new List<EmotionKey>();
|
||||
InitializeEmotionTarget(emotion,FaceDrivenKeyTarget.MouthMorphs, emotion.mouth, false);
|
||||
InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeMorphs, emotion.eye_l, true);
|
||||
InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeMorphs, emotion.eye_r, false);
|
||||
InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeBrowMorphs, emotion.eyebrow_l, true);
|
||||
InitializeEmotionTarget(emotion, FaceDrivenKeyTarget.EyeBrowMorphs, emotion.eyebrow_r, false);
|
||||
}
|
||||
|
||||
if (UmaViewerUI.Instance)
|
||||
{
|
||||
UmaViewerUI.Instance.LoadEmotionPanels(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeEmotionTarget(FaceTypeData faceTypeData, List<FacialMorph> morphs,string tags,bool direction)
|
||||
{
|
||||
foreach (var morphName in tags.Split('|'))
|
||||
{
|
||||
EmotionKey newValue = new EmotionKey();
|
||||
if (morphName.Contains("__"))
|
||||
{
|
||||
var splitArray = Regex.Split(morphName, "__", RegexOptions.IgnoreCase);
|
||||
if (splitArray[0] == "Base")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue.morph = morphs.Where(a => a.tag == splitArray[0] && a.direction == direction).First();
|
||||
}
|
||||
newValue.weight = Convert.ToInt32(splitArray[1]);
|
||||
faceTypeData.emotionKeys.Add(newValue);
|
||||
//Debug.Log(newValue.weight);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (morphName == "Base")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
newValue.morph = morphs.Where(a => a.tag == morphName && a.direction == direction).First();
|
||||
}
|
||||
newValue.weight = 100;
|
||||
faceTypeData.emotionKeys.Add(newValue);
|
||||
//Debug.Log(morphName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAllFacialKeyTargets()
|
||||
{
|
||||
if (FaceDrivenKeyTarget == null) return;
|
||||
FaceDrivenKeyTarget.ClearMorph();
|
||||
|
||||
foreach (var emotion in FaceEmotionKey)
|
||||
{
|
||||
if (emotion.emotionKeys != null)
|
||||
{
|
||||
foreach (var key in emotion.emotionKeys)
|
||||
{
|
||||
key.morph.weight += key.weight / 100 * emotion.Weight;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FaceDrivenKeyTarget.ChangeMorph();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43ba40a9c767e6e43a635ce59cb7942e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,21 +11,10 @@ namespace Gallop
|
||||
public class FacialMorph
|
||||
{
|
||||
public string name;
|
||||
public string tag = "";
|
||||
public bool direction;
|
||||
public FaceDrivenKeyTarget target;
|
||||
private float _weight;
|
||||
public float Weight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _weight;
|
||||
}
|
||||
set
|
||||
{
|
||||
_weight = value;
|
||||
target.ChangeMorph();
|
||||
}
|
||||
}
|
||||
public float weight;
|
||||
public List<TrsArray> trsArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ PlayerSettings:
|
||||
16:10: 1
|
||||
16:9: 1
|
||||
Others: 1
|
||||
bundleVersion: 3.0
|
||||
bundleVersion: 2.1.1
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
|
||||
Reference in New Issue
Block a user