minor bug fix
This commit is contained in:
@@ -310,14 +310,10 @@ public class UmaContainer : MonoBehaviour
|
||||
PuppetMaster.mode = PuppetMaster.Mode.Active;
|
||||
}
|
||||
}
|
||||
var targetPosotion = TrackTarget.transform.position - HeadBone.transform.up * EyeHeight;
|
||||
var deltaPos = HeadBone.transform.InverseTransformPoint(targetPosotion);
|
||||
var deltaRotation = Quaternion.LookRotation(deltaPos.normalized, HeadBone.transform.up).eulerAngles;
|
||||
if (deltaRotation.x > 180) deltaRotation.x -= 360;
|
||||
if (deltaRotation.y > 180) deltaRotation.y -= 360;
|
||||
|
||||
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.y / 35, -1, 1), Mathf.Clamp(-deltaRotation.x / 25, -1, 1));//Limited to the angle of view
|
||||
FaceDrivenKeyTarget.SetEyeRange(finalRotation.x, finalRotation.y, finalRotation.x, -finalRotation.y);
|
||||
var finalRotation = FaceDrivenKeyTarget.GetEyeTrackRotation(TrackTarget.transform.position);
|
||||
FaceDrivenKeyTarget.SetEyeTrack(finalRotation);
|
||||
|
||||
var cam = Camera.main;
|
||||
var distance = Mathf.Clamp(cam.transform.InverseTransformPoint(HeadBone.transform.position).magnitude - 0.1f, 0, 2);
|
||||
var mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
|
||||
|
||||
@@ -100,6 +100,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.IsLive = true;
|
||||
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(characters[i].CharaEntry);
|
||||
CurrentUMAContainer.transform.parent = Gallop.Live.Director.instance.charaObjs[i];
|
||||
CurrentUMAContainer.transform.localPosition = new Vector3();
|
||||
LoadMobUma(characters[i].CharaEntry, characters[i].CostumeId);
|
||||
}
|
||||
else
|
||||
@@ -107,6 +108,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.IsLive = true;
|
||||
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(characters[i].CharaEntry);
|
||||
CurrentUMAContainer.transform.parent = Gallop.Live.Director.instance.charaObjs[i];
|
||||
CurrentUMAContainer.transform.localPosition = new Vector3();
|
||||
LoadNormalUma(characters[i].CharaEntry, characters[i].CostumeId);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ using UnityEngine;
|
||||
using static DynamicBone;
|
||||
using static Gallop.DrivenKeyComponent;
|
||||
using static Gallop.FaceDrivenKeyTarget;
|
||||
using static Gallop.Live.Cutt.LiveTimelineDefine;
|
||||
using static RootMotion.FinalIK.FBBIKHeadEffector;
|
||||
|
||||
namespace Gallop
|
||||
{
|
||||
@@ -1050,9 +1052,79 @@ namespace Gallop
|
||||
ChangeMorphEar();
|
||||
|
||||
}
|
||||
|
||||
if (updateInfo_.eyeTrackCur != null)
|
||||
{
|
||||
float weightRatio = CalcMorphWeight(liveTime_, updateInfo_.eyeTrackCur.speed, updateInfo_.eyeTrackCur.time, updateInfo_.eyeTrackCur.interpolateType, updateInfo_.eyeTrackCur, updateInfo_.eyeTrackNext);
|
||||
|
||||
Vector2 finalRotation = new Vector2();
|
||||
|
||||
if (updateInfo_.eyeTrackPrev != null)
|
||||
{
|
||||
finalRotation = Vector2.Lerp(GetTimelineEyeTrackRotation(updateInfo_.eyeTrackPrev), GetTimelineEyeTrackRotation(updateInfo_.eyeTrackCur), weightRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
finalRotation = GetTimelineEyeTrackRotation(updateInfo_.eyeTrackCur);
|
||||
}
|
||||
|
||||
SetEyeTrack(finalRotation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public float CalcMorphWeight(float time, int speed, int interFrame, InterpolateType interType, LiveTimelineKey curKey, LiveTimelineKey nextKey)
|
||||
public Vector2 GetTimelineEyeTrackRotation(LiveTimelineKeyFacialEyeTrackData key)
|
||||
{
|
||||
Vector3 target = new Vector3();
|
||||
if(CalcTargetPosition(key, ref target))
|
||||
{
|
||||
return GetEyeTrackRotation(target) + new Vector2((float)key.horizontalRatePer / 100, (float)key.verticalRatePer / 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Vector2(0, 0) + new Vector2((float)key.horizontalRatePer / 100, (float)key.verticalRatePer / 100);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CalcTargetPosition(LiveTimelineKeyFacialEyeTrackData key, ref Vector3 target)
|
||||
{
|
||||
|
||||
switch (key.targetType)
|
||||
{
|
||||
case FacialEyeTrackTargetType.Arena:
|
||||
target = Container.HeadBone.transform.position + new Vector3(0, 1, 10);
|
||||
return true;
|
||||
case FacialEyeTrackTargetType.DirectPosition:
|
||||
target = key.DirectPosition;
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Vector2 GetEyeTrackRotation(Vector3 target)
|
||||
{
|
||||
var targetPosotion = target - Container.HeadBone.transform.up * Container.EyeHeight;
|
||||
var deltaPos = Container.HeadBone.transform.InverseTransformPoint(targetPosotion);
|
||||
var deltaRotation = Quaternion.LookRotation(deltaPos.normalized, Container.HeadBone.transform.up).eulerAngles;
|
||||
if (deltaRotation.x > 180) deltaRotation.x -= 360;
|
||||
if (deltaRotation.y > 180) deltaRotation.y -= 360;
|
||||
|
||||
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.y / 35, -1, 1), Mathf.Clamp(-deltaRotation.x / 25, -1, 1));//Limited to the angle of view
|
||||
|
||||
return finalRotation;
|
||||
|
||||
}
|
||||
|
||||
public void SetEyeTrack(Vector2 rotation)
|
||||
{
|
||||
SetEyeRange(rotation.x, rotation.y, rotation.x, -rotation.y);
|
||||
}
|
||||
|
||||
public static float CalcMorphWeight(float time, int speed, int interFrame, InterpolateType interType, LiveTimelineKey curKey, LiveTimelineKey nextKey)
|
||||
{
|
||||
|
||||
float keyTime = (float)curKey.frame / 60;
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace Gallop.Live.Cutt
|
||||
public LiveTimelineKeyFacialEyebrowData eyebrowPrev; // 0x28
|
||||
public LiveTimelineKeyFacialEyebrowData eyebrowCur; // 0x28
|
||||
public LiveTimelineKeyFacialEyebrowData eyebrowNext; // 0x28
|
||||
public LiveTimelineKeyFacialEyeTrackData eyeTrack; // 0x30
|
||||
public LiveTimelineKeyFacialEyeTrackData eyeTrackPrev; // 0x30
|
||||
public LiveTimelineKeyFacialEyeTrackData eyeTrackCur; // 0x30
|
||||
public LiveTimelineKeyFacialEyeTrackData eyeTrackNext; // 0x30
|
||||
public LiveTimelineKeyFacialEarData earPrev; // 0x38
|
||||
public LiveTimelineKeyFacialEarData earCur; // 0x38
|
||||
public LiveTimelineKeyFacialEarData earNext; // 0x38
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Gallop.Live.Cutt
|
||||
|
||||
public Quaternion liveCharaPositionLocalRotation { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public Vector3 liveCharaHeadPosition => UmaContainer.HeadBone.transform.position + new Vector3(0, UmaContainer.EyeHeight, 0);
|
||||
public Vector3 liveCharaHeadPosition => UmaContainer.HeadBone.transform.position + new Vector3(0, 0.1f, 0);
|
||||
|
||||
public Vector3 liveCharaWaistPosition => Bones["Waist"].position;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using static RootMotion.FinalIK.IKSolverVR;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using static UnityEngine.Rendering.VirtualTexturing.Debugging;
|
||||
using static Gallop.Live.Cutt.LiveTimelineDefine;
|
||||
|
||||
namespace Gallop.Live.Cutt
|
||||
{
|
||||
@@ -363,6 +364,7 @@ namespace Gallop.Live.Cutt
|
||||
SetupFacialUpdateInfo_Eye(ref updateInfo, facialDataList.eyeKeys, liveTime);
|
||||
SetupFacialUpdateInfo_Eyebrow(ref updateInfo, facialDataList.eyebrowKeys, liveTime);
|
||||
SetupFacialUpdateInfo_Ear(ref updateInfo, facialDataList.earKeys, liveTime);
|
||||
SetupFacialUpdateInfo_EyeTrack(ref updateInfo, facialDataList.eyeTrackKeys, liveTime);
|
||||
this.OnUpdateFacial(updateInfo, liveTime, 0);
|
||||
}
|
||||
|
||||
@@ -373,6 +375,7 @@ namespace Gallop.Live.Cutt
|
||||
SetupFacialUpdateInfo_Eye(ref updateInfo, otherFacialDataList[i].eyeKeys, liveTime);
|
||||
SetupFacialUpdateInfo_Eyebrow(ref updateInfo, otherFacialDataList[i].eyebrowKeys, liveTime);
|
||||
SetupFacialUpdateInfo_Ear(ref updateInfo, otherFacialDataList[i].earKeys, liveTime);
|
||||
SetupFacialUpdateInfo_EyeTrack(ref updateInfo, otherFacialDataList[i].eyeTrackKeys, liveTime);
|
||||
this.OnUpdateFacial(updateInfo, liveTime, i+1);
|
||||
}
|
||||
}
|
||||
@@ -457,6 +460,26 @@ namespace Gallop.Live.Cutt
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupFacialUpdateInfo_EyeTrack(ref FacialDataUpdateInfo updateInfo, LiveTimelineKeyFacialEyeTrackDataList keys, float time)
|
||||
{
|
||||
LiveTimelineKey liveTimelineKey = null;
|
||||
LiveTimelineKey liveTimelineKey2 = null;
|
||||
LiveTimelineKey liveTimelineKey3 = null;
|
||||
|
||||
LiveTimelineKeyIndex curKey = AlterUpdate_Key(keys, time);
|
||||
if (curKey != null)
|
||||
{
|
||||
liveTimelineKey = curKey.prevKey;
|
||||
liveTimelineKey2 = curKey.key;
|
||||
liveTimelineKey3 = curKey.nextKey;
|
||||
|
||||
updateInfo.eyeTrackPrev = liveTimelineKey as LiveTimelineKeyFacialEyeTrackData;
|
||||
updateInfo.eyeTrackCur = liveTimelineKey2 as LiveTimelineKeyFacialEyeTrackData;
|
||||
updateInfo.eyeTrackNext = liveTimelineKey3 as LiveTimelineKeyFacialEyeTrackData;
|
||||
updateInfo.eyeTrackKeyIndex = curKey.index;
|
||||
}
|
||||
}
|
||||
|
||||
public void AlterUpdate_LipSync(float liveTime)
|
||||
{
|
||||
var lipDataList = data.worksheetList[0].ripSyncKeys;
|
||||
@@ -578,14 +601,14 @@ namespace Gallop.Live.Cutt
|
||||
if(nextKey != null && nextKey.interpolateType != LiveCameraInterpolateType.None)
|
||||
{
|
||||
float ratio = CalculateInterpolationValue(curKey, nextKey, time * 60);
|
||||
chara.transform.position = Vector3.Lerp(curKey.Position, nextKey.Position, ratio);
|
||||
chara.transform.localPosition = Vector3.Lerp(curKey.Position, nextKey.Position, ratio);
|
||||
var x = chara.Position.localEulerAngles.x;
|
||||
var z = chara.Position.localEulerAngles.z;
|
||||
chara.Position.localEulerAngles = new Vector3(x, Mathf.Lerp(curKey.LocalRotationY, nextKey.LocalRotationY, ratio), z);
|
||||
}
|
||||
else
|
||||
{
|
||||
chara.transform.position = curKey.Position;
|
||||
chara.transform.localPosition = curKey.Position;
|
||||
var x = chara.Position.localEulerAngles.x;
|
||||
var z = chara.Position.localEulerAngles.z;
|
||||
chara.Position.localEulerAngles = new Vector3(x, curKey.LocalRotationY, z);
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace Gallop.Live
|
||||
{
|
||||
_liveCurrentTime += Time.deltaTime;
|
||||
|
||||
//Debug.Log(_liveCurrentTime * 60);
|
||||
Debug.Log(_liveCurrentTime * 60);
|
||||
|
||||
UI.ProgressBar.SetValueWithoutNotify(_liveCurrentTime / totalTime);
|
||||
OnTimelineUpdate(_liveCurrentTime);
|
||||
|
||||
Reference in New Issue
Block a user