mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-09 04:19:42 -05:00
IVRM10SourceDestination
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
public static class IVRM10ConstraintSourceDestinationExtensions
|
||||
{
|
||||
public static void DrawSourceCoords(this IVRM10ConstraintSourceDestination self)
|
||||
{
|
||||
try
|
||||
{
|
||||
self.GetSourceCoords().Draw(0.2f);
|
||||
}
|
||||
catch (ConstraintException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
public static void DrawSourceCurrent(this IVRM10ConstraintSourceDestination self)
|
||||
{
|
||||
try
|
||||
{
|
||||
Handles.matrix = self.GetSourceCurrent().TRS(0.05f);
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawWireCube(Vector3.zero, Vector3.one);
|
||||
}
|
||||
catch (ConstraintException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawDstCoords(this IVRM10ConstraintSourceDestination self)
|
||||
{
|
||||
try
|
||||
{
|
||||
self.GetDstCoords().Draw(0.2f);
|
||||
}
|
||||
catch (ConstraintException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawDstCurrent(this IVRM10ConstraintSourceDestination self)
|
||||
{
|
||||
try
|
||||
{
|
||||
Handles.matrix = self.GetDstCurrent().TRS(0.05f);
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawWireCube(Vector3.zero, Vector3.one);
|
||||
}
|
||||
catch (ConstraintException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59e1ae1f9d4fb9a459cd2c97a4351b1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -15,39 +14,18 @@ namespace UniVRM10
|
||||
m_target = (VRM10RotationConstraint)target;
|
||||
}
|
||||
|
||||
#region SRC
|
||||
void DrawSourceCurrent()
|
||||
{
|
||||
var s = m_target.transform.lossyScale.x;
|
||||
Handles.matrix = m_target.GetSourceCurrent().TRS(0.05f * s);
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawWireCube(Vector3.zero, Vector3.one);
|
||||
}
|
||||
|
||||
void DrawSourceCoords()
|
||||
{
|
||||
var s = m_target.transform.lossyScale.x;
|
||||
m_target.GetSourceCoords().Draw(0.2f / s);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dst
|
||||
void DrawDstCurrent()
|
||||
{
|
||||
var s = m_target.transform.lossyScale.x;
|
||||
Handles.matrix = m_target.GetDstCurrent().TRS(0.05f * s);
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawWireCube(Vector3.zero, Vector3.one);
|
||||
}
|
||||
|
||||
void DrawDstCoords()
|
||||
{
|
||||
var s = m_target.transform.lossyScale.x;
|
||||
m_target.GetDstCoords().Draw(0.2f / s);
|
||||
}
|
||||
#endregion
|
||||
|
||||
static GUIStyle s_style;
|
||||
static GUIStyle Style
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_style == null)
|
||||
{
|
||||
s_style = new GUIStyle("box");
|
||||
}
|
||||
return s_style;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Euler各を +- 180 にクランプする
|
||||
@@ -74,16 +52,12 @@ namespace UniVRM10
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (s_style == null)
|
||||
{
|
||||
s_style = new GUIStyle("box");
|
||||
}
|
||||
|
||||
// this to target line
|
||||
Handles.color = Color.yellow;
|
||||
Handles.DrawLine(m_target.Source.position, m_target.transform.position);
|
||||
|
||||
var euler = Clamp180(m_target.Delta.eulerAngles);
|
||||
var delta = Clamp180(m_target.Delta.eulerAngles);
|
||||
|
||||
// show source
|
||||
{
|
||||
@@ -91,26 +65,26 @@ namespace UniVRM10
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"source: {m_target.SourceCoordinate}");
|
||||
sb.AppendLine($"{euler.x:0.}");
|
||||
sb.AppendLine($"{euler.y:0.}");
|
||||
sb.Append($"{euler.z:0.}");
|
||||
Handles.Label(m_target.Source.position, sb.ToString(), s_style);
|
||||
sb.AppendLine($"{delta.x:0.}");
|
||||
sb.AppendLine($"{delta.y:0.}");
|
||||
sb.Append($"{delta.z:0.}");
|
||||
Handles.Label(m_target.Source.position, sb.ToString(), Style);
|
||||
}
|
||||
|
||||
// show dst
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"constraint: {m_target.DestinationCoordinate}");
|
||||
sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.X) ? $"freeze" : $"{euler.x:0.}");
|
||||
sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.Y) ? $"freeze" : $"{euler.y:0.}");
|
||||
sb.Append(m_target.FreezeAxes.HasFlag(AxisMask.Z) ? $"freeze" : $"{euler.z:0.}");
|
||||
Handles.Label(m_target.transform.position, sb.ToString(), s_style);
|
||||
sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.X) ? $"freeze" : $"{delta.x:0.}");
|
||||
sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.Y) ? $"freeze" : $"{delta.y:0.}");
|
||||
sb.Append(m_target.FreezeAxes.HasFlag(AxisMask.Z) ? $"freeze" : $"{delta.z:0.}");
|
||||
Handles.Label(m_target.transform.position, sb.ToString(), Style);
|
||||
}
|
||||
|
||||
DrawSourceCoords();
|
||||
DrawSourceCurrent();
|
||||
DrawDstCoords();
|
||||
DrawDstCurrent();
|
||||
m_target.DrawSourceCoords();
|
||||
m_target.DrawSourceCurrent();
|
||||
m_target.DrawDstCoords();
|
||||
m_target.DrawDstCurrent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace UniVRM10
|
||||
{
|
||||
public interface IVRM10ConstraintSourceDestination
|
||||
{
|
||||
TR GetSourceCoords();
|
||||
TR GetSourceCurrent();
|
||||
|
||||
TR GetDstCoords();
|
||||
TR GetDstCurrent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d1ea0f0f4d95a2499f9aa5a1d7a2235
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,7 +9,7 @@ namespace UniVRM10
|
||||
/// 対象の初期回転と現在回転の差分(delta)を、自身の初期回転と自身の初期回転にdeltaを乗算したものに対してWeightでSlerpする。
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
public class VRM10RotationConstraint : VRM10Constraint
|
||||
public class VRM10RotationConstraint : VRM10Constraint, IVRM10ConstraintSourceDestination
|
||||
{
|
||||
[SerializeField]
|
||||
public Transform Source = default;
|
||||
@@ -36,10 +36,6 @@ namespace UniVRM10
|
||||
|
||||
ConstraintSource m_src;
|
||||
|
||||
/// <summary>
|
||||
/// Source の座標系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TR GetSourceCoords()
|
||||
{
|
||||
switch (SourceCoordinate)
|
||||
|
||||
Reference in New Issue
Block a user