Add eye tracking
This commit is contained in:
@@ -7,7 +7,7 @@ AnimationClip:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: clip_2
|
m_Name: clip_2
|
||||||
serializedVersion: 7
|
serializedVersion: 6
|
||||||
m_Legacy: 0
|
m_Legacy: 0
|
||||||
m_Compressed: 0
|
m_Compressed: 0
|
||||||
m_UseHighQualityCurve: 1
|
m_UseHighQualityCurve: 1
|
||||||
|
|||||||
@@ -19980,8 +19980,8 @@ MonoBehaviour:
|
|||||||
m_TargetGraphic: {fileID: 1882365343}
|
m_TargetGraphic: {fileID: 1882365343}
|
||||||
m_HandleRect: {fileID: 1882365342}
|
m_HandleRect: {fileID: 1882365342}
|
||||||
m_Direction: 2
|
m_Direction: 2
|
||||||
m_Value: 0
|
m_Value: 0.999995
|
||||||
m_Size: 1
|
m_Size: 0.9765434
|
||||||
m_NumberOfSteps: 0
|
m_NumberOfSteps: 0
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ public class UmaContainer : MonoBehaviour
|
|||||||
[Header("Face")]
|
[Header("Face")]
|
||||||
public FaceDrivenKeyTarget FaceDrivenKeyTarget;
|
public FaceDrivenKeyTarget FaceDrivenKeyTarget;
|
||||||
public FaceEmotionKeyTarget FaceEmotionKeyTarget;
|
public FaceEmotionKeyTarget FaceEmotionKeyTarget;
|
||||||
|
public GameObject HeadBone;
|
||||||
|
public GameObject TrackTarget;
|
||||||
|
public float EyeHeight;
|
||||||
|
|
||||||
[Header("Generic")]
|
[Header("Generic")]
|
||||||
public bool IsGeneric = false;
|
public bool IsGeneric = false;
|
||||||
@@ -32,6 +35,13 @@ public class UmaContainer : MonoBehaviour
|
|||||||
public bool IsMini = false;
|
public bool IsMini = false;
|
||||||
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
|
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
HeadBone = (GameObject)Body.GetComponent<AssetHolder>()._assetTable.list.FindLast(a => a.Key == "head").Value;
|
||||||
|
EyeHeight = 0.1f;
|
||||||
|
TrackTarget = Camera.main.gameObject;
|
||||||
|
}
|
||||||
|
|
||||||
public void MergeModel()
|
public void MergeModel()
|
||||||
{
|
{
|
||||||
if (!Body) return;
|
if (!Body) return;
|
||||||
@@ -124,4 +134,15 @@ public class UmaContainer : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
if (TrackTarget)
|
||||||
|
{
|
||||||
|
var targetPosotion = TrackTarget.transform.position - new Vector3(0, EyeHeight, 0);
|
||||||
|
var deltaPos = HeadBone.transform.InverseTransformPoint(targetPosotion);
|
||||||
|
var deltaRotation = HeadBone.transform.InverseTransformDirection(deltaPos.normalized);
|
||||||
|
var finalRotation = new Vector2(Mathf.Clamp(deltaRotation.x / 0.86f,-1,1), Mathf.Clamp(deltaRotation.y / 0.86f, -1, 1));//Limited to the angle of view
|
||||||
|
FaceDrivenKeyTarget.SetEyeRange(finalRotation.x, finalRotation.y, finalRotation.x, -finalRotation.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,6 +278,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
FaceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
|
FaceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
|
||||||
|
|
||||||
var emotionDriven = ScriptableObject.CreateInstance<FaceEmotionKeyTarget>();
|
var emotionDriven = ScriptableObject.CreateInstance<FaceEmotionKeyTarget>();
|
||||||
|
emotionDriven.name = $"char{id}_{costumeId}_emotion_target";
|
||||||
CurrentUMAContainer.FaceEmotionKeyTarget = emotionDriven;
|
CurrentUMAContainer.FaceEmotionKeyTarget = emotionDriven;
|
||||||
emotionDriven.FaceDrivenKeyTarget = FaceDriven;
|
emotionDriven.FaceDrivenKeyTarget = FaceDriven;
|
||||||
emotionDriven.FaceEmotionKey = UmaDatabaseController.Instance.FaceTypeData.ToList();
|
emotionDriven.FaceEmotionKey = UmaDatabaseController.Instance.FaceTypeData.ToList();
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using Gallop.Live.Cutt;
|
using Gallop.Live.Cutt;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Gallop
|
namespace Gallop
|
||||||
{
|
{
|
||||||
@@ -17,6 +15,7 @@ namespace Gallop
|
|||||||
private FacialMorph BaseLEyeBrowMorph, BaseREyeBrowMorph;
|
private FacialMorph BaseLEyeBrowMorph, BaseREyeBrowMorph;
|
||||||
private FacialMorph BaseLEyeMorph, BaseREyeMorph;
|
private FacialMorph BaseLEyeMorph, BaseREyeMorph;
|
||||||
private FacialMorph BaseMouthMorph;
|
private FacialMorph BaseMouthMorph;
|
||||||
|
public FacialMorph LeftEyeXrange, LeftEyeYrange, RightEyeXrange, RightEyeYrange;
|
||||||
|
|
||||||
public List<FacialMorph> EyeBrowMorphs = new List<FacialMorph>();
|
public List<FacialMorph> EyeBrowMorphs = new List<FacialMorph>();
|
||||||
public List<FacialMorph> EyeMorphs = new List<FacialMorph>();
|
public List<FacialMorph> EyeMorphs = new List<FacialMorph>();
|
||||||
@@ -47,8 +46,8 @@ namespace Gallop
|
|||||||
}
|
}
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
if (morph.direction) BaseREyeBrowMorph = morph;
|
if (morph.direction) BaseLEyeBrowMorph = morph;
|
||||||
else BaseLEyeBrowMorph = morph;
|
else BaseREyeBrowMorph = morph;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -73,11 +72,22 @@ namespace Gallop
|
|||||||
}
|
}
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
if (morph.direction) BaseREyeMorph = morph;
|
if (morph.direction) BaseLEyeMorph = morph;
|
||||||
else BaseLEyeMorph = morph;
|
else BaseREyeMorph = morph;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (i == 20)
|
||||||
|
{
|
||||||
|
if (morph.direction) LeftEyeXrange = morph;
|
||||||
|
else RightEyeXrange = morph;
|
||||||
|
}
|
||||||
|
else if (i == 21)
|
||||||
|
{
|
||||||
|
if (morph.direction) LeftEyeYrange = morph;
|
||||||
|
else RightEyeYrange = morph;
|
||||||
|
}
|
||||||
|
|
||||||
EyeMorphs.Add(morph);
|
EyeMorphs.Add(morph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,6 +216,14 @@ namespace Gallop
|
|||||||
ChangeMorph();
|
ChangeMorph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetEyeRange(float lx, float ly,float rx, float ry)
|
||||||
|
{
|
||||||
|
LeftEyeXrange.weight = lx;
|
||||||
|
LeftEyeYrange.weight = ly;
|
||||||
|
RightEyeXrange.weight = rx;
|
||||||
|
RightEyeYrange.weight = ry;
|
||||||
|
ChangeMorph();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user