implement BlendShape LookAt

This commit is contained in:
ousttrue
2018-04-05 18:01:46 +09:00
parent 2bc3a48d6b
commit 87a7212a4c
6 changed files with 68 additions and 30 deletions

View File

@@ -18,7 +18,7 @@ namespace VRM
void OnSceneGUI()
{
if (!Application.isPlaying) return;
//if (!Application.isPlaying) return;
if (!m_target.DrawGizmo) return;
if (m_target.Target == null) return;
if (m_target.Head.Transform == null) return;

View File

@@ -8,16 +8,14 @@ namespace VRM
{
public bool DrawGizmo = true;
[SerializeField, Header("Degree Mapping")]
public CurveMapper Horizontal = new CurveMapper();
[SerializeField]
float Range = 20.0f;
public CurveMapper VerticalDown = new CurveMapper();
private void Reset()
{
}
private void OnValidate()
{
}
[SerializeField]
public CurveMapper VerticalUp = new CurveMapper();
VRMLookAtHead m_head;
VRMBlendShapeProxy m_propxy;
@@ -48,26 +46,27 @@ namespace VRM
if (yaw < 0)
{
// Left
m_propxy.SetValue(BlendShapePreset.LookLeft, -yaw / Range);
m_propxy.SetValue(BlendShapePreset.LookLeft, Horizontal.Map(-yaw));
m_propxy.SetValue(BlendShapePreset.LookRight, 0);
}
else{
else
{
// Right
m_propxy.SetValue(BlendShapePreset.LookLeft, 0);
m_propxy.SetValue(BlendShapePreset.LookRight, yaw / Range);
m_propxy.SetValue(BlendShapePreset.LookRight, Horizontal.Map(yaw));
}
if (pitch < 0)
{
// Up
m_propxy.SetValue(BlendShapePreset.LookUp, -pitch / Range);
m_propxy.SetValue(BlendShapePreset.LookDown, 0);
// Down
m_propxy.SetValue(BlendShapePreset.LookUp, 0);
m_propxy.SetValue(BlendShapePreset.LookDown, VerticalDown.Map(-pitch));
}
else
{
// Down
m_propxy.SetValue(BlendShapePreset.LookUp, 0);
m_propxy.SetValue(BlendShapePreset.LookDown, pitch / Range);
// Up
m_propxy.SetValue(BlendShapePreset.LookUp, VerticalUp.Map(pitch));
m_propxy.SetValue(BlendShapePreset.LookDown, 0);
}
}
}