diff --git a/Assets/VRM10/Editor/Components/Constraint.meta b/Assets/VRM10/Editor/Components/Constraint.meta deleted file mode 100644 index 2a1fd51d0..000000000 --- a/Assets/VRM10/Editor/Components/Constraint.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7b369ee7eb21d1047bb03e139faa7eda -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/Editor/Components/Constraint/TRExtensions.cs b/Assets/VRM10/Editor/Components/Constraint/TRExtensions.cs deleted file mode 100644 index 1365ea074..000000000 --- a/Assets/VRM10/Editor/Components/Constraint/TRExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using UnityEditor; -using UnityEngine; - -namespace UniVRM10 -{ - public static class TRExtensions - { - public static void Draw(this TR tr, float size) - { - Handles.matrix = tr.TRS(size); - - // Handles.CubeHandleCap(0, Vector3.zero, Quaternion.identity, size, EventType.Repaint); - Handles.color = Color.red; - Handles.DrawLine(Vector3.zero, Vector3.right); - Handles.color = Color.green; - Handles.DrawLine(Vector3.zero, Vector3.up); - Handles.color = Color.blue; - Handles.DrawLine(Vector3.zero, Vector3.forward); - - Handles.color = Color.white; - // xy - Handles.DrawLine(Vector3.right + Vector3.up, Vector3.right); - Handles.DrawLine(Vector3.right + Vector3.up, Vector3.up); - // yz - Handles.DrawLine(Vector3.up + Vector3.forward, Vector3.forward); - Handles.DrawLine(Vector3.up + Vector3.forward, Vector3.up); - // zx - Handles.DrawLine(Vector3.forward + Vector3.right, Vector3.forward); - Handles.DrawLine(Vector3.forward + Vector3.right, Vector3.right); - } - } -} diff --git a/Assets/VRM10/Editor/Components/Constraint/TRExtensions.cs.meta b/Assets/VRM10/Editor/Components/Constraint/TRExtensions.cs.meta deleted file mode 100644 index d86fabc8d..000000000 --- a/Assets/VRM10/Editor/Components/Constraint/TRExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f2d422c6e760aca49841f8acf44c0434 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs deleted file mode 100644 index fcd5e8c6b..000000000 --- a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System.Text; -using UnityEditor; -using UnityEngine; - -namespace UniVRM10 -{ - public abstract class VRM10PositionRotationConstraintEditorBase : Editor - { - VRM10RotationPositionConstraintBase m_target; - - void OnEnable() - { - m_target = (VRM10RotationPositionConstraintBase)target; - } - - static GUIStyle s_style; - static GUIStyle Style - { - get - { - if (s_style == null) - { - s_style = new GUIStyle("box"); - } - return s_style; - } - } - - /// - /// Euler各を +- 180 にクランプする - /// - /// - /// - static Vector3 Clamp180(Vector3 v) - { - var x = v.x; - while (x < -180) x += 360; - while (x > 180) x -= 360; - var y = v.y; - while (y < -180) y += 360; - while (y > 180) y -= 360; - var z = v.z; - while (z < -180) z += 360; - while (z > 180) z -= 360; - return new Vector3(x, y, z); - } - - public void OnSceneGUI() - { - if (m_target.Source == null) - { - return; - } - - // source offset - if (!Application.isPlaying) - { - EditorGUI.BeginChangeCheck(); - Quaternion offset = Handles.RotationHandle(m_target.SourceOffset, m_target.Source.position); - if (EditorGUI.EndChangeCheck()) - { - Undo.RecordObject(m_target.GetComponent(), "source offset"); - m_target.SourceOffset = offset; - } - } - - // dest offset - if (!Application.isPlaying) - { - EditorGUI.BeginChangeCheck(); - Quaternion offset = Handles.RotationHandle(m_target.DestinationOffset, m_target.GetComponent().transform.position); - if (EditorGUI.EndChangeCheck()) - { - Undo.RecordObject(m_target.GetComponent(), "dest offset"); - m_target.DestinationOffset = offset; - } - } - - // this to target line - Handles.color = Color.yellow; - Handles.DrawLine(m_target.Source.position, m_target.GetComponent().transform.position); - - var delta = Clamp180(m_target.Delta); - - // show source - { - var sb = new StringBuilder(); - sb.AppendLine(); - sb.AppendLine(); - sb.AppendLine($"{delta.x:0.00}"); - sb.AppendLine($"{delta.y:0.00}"); - sb.Append($"{delta.z:0.00}"); - Handles.Label(m_target.Source.position, sb.ToString(), Style); - } - - // show dst - { - var sb = new StringBuilder(); - sb.AppendLine(m_target.Axes.HasFlag(AxisMask.X) ? $"{delta.x:0.00}" : "----"); - sb.AppendLine(m_target.Axes.HasFlag(AxisMask.Y) ? $"{delta.y:0.00}" : "----"); - sb.Append(m_target.Axes.HasFlag(AxisMask.Z) ? $"{delta.z:0.00}" : "----"); - Handles.Label(m_target.GetComponent().transform.position, sb.ToString(), Style); - } - - m_target.GetSourceCoords().Draw(0.2f); - if (Application.isPlaying) - { - Handles.matrix = m_target.GetSourceCurrent().TRS(0.05f); - Handles.color = Color.yellow; - Handles.DrawWireCube(Vector3.zero, Vector3.one); - } - - m_target.GetDstCoords().Draw(0.2f); - if (Application.isPlaying) - { - Handles.matrix = m_target.GetDstCurrent().TRS(0.05f); - Handles.color = Color.yellow; - Handles.DrawWireCube(Vector3.zero, Vector3.one); - } - } - } -} diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs deleted file mode 100644 index 0b8140aec..000000000 --- a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using UnityEditor; - -namespace UniVRM10 -{ - [CustomEditor(typeof(VRM10RotationConstraint))] - public class VRM10RotationConstraintEditor : VRM10PositionRotationConstraintEditorBase - { - } -} diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs.meta b/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs.meta deleted file mode 100644 index ada1c4062..000000000 --- a/Assets/VRM10/Editor/Components/Constraint/VRM10RotationConstraintEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cd4ca141215a42c45a0036791f2f8a4d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/Editor/Components/VRM10Window.cs b/Assets/VRM10/Editor/Components/VRM10Window.cs index 3612409eb..613ec0a7e 100644 --- a/Assets/VRM10/Editor/Components/VRM10Window.cs +++ b/Assets/VRM10/Editor/Components/VRM10Window.cs @@ -71,7 +71,7 @@ namespace UniVRM10 Transform m_head; - public VRM10Constraint[] m_constraints; + public Vrm10Constraint[] m_constraints; ScrollView m_scrollView = new ScrollView(); @@ -177,7 +177,7 @@ namespace UniVRM10 { if (m_constraints == null) { - m_constraints = Root.GetComponentsInChildren(); + m_constraints = Root.GetComponentsInChildren(); } } @@ -187,7 +187,7 @@ namespace UniVRM10 { foreach (var c in m_constraints) { - EditorGUILayout.ObjectField(c, typeof(VRM10Constraint), true); + EditorGUILayout.ObjectField(c, typeof(Vrm10Constraint), true); } } } diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs index 8b91193e9..fb04b9de9 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs @@ -1,92 +1,9 @@ -using System; -using UniGLTF.Extensions.VRMC_node_constraint; using UnityEngine; namespace UniVRM10 { - public abstract class VRM10Constraint : MonoBehaviour + public abstract class Vrm10Constraint : MonoBehaviour { - [SerializeField] - [Range(0, 10.0f)] - public float Weight = 1.0f; - - [SerializeField] - public Transform ModelRoot = default; - - protected virtual void Reset() - { - var current = transform; - while (true) - { - current = current.parent; - if (current.parent == null) - { - // root - break; - } - if (current.GetComponent() != null) - { - // model root - break; - } - } - ModelRoot = current; - } - - #region Source - public abstract Transform Source { get; set; } - - public ConstraintSource m_src; - - protected TR SourceInitialCoords() - { - if (m_src == null) - { - return TR.FromWorld(Source); - } - else - { - return TR.FromParent(Source) * m_src.LocalInitial; - } - } - #endregion - - #region Destination - protected ConstraintDestination m_dst; - - protected TR DestinationInitialCoords() - { - if (m_dst == null) - { - return TR.FromWorld(transform); - } - else - { - return TR.FromParent(transform) * m_dst.LocalInitial; - } - } - #endregion - - public void Process() - { - if (Source == null) - { - enabled = false; - return; - } - - if (m_src == null) - { - m_src = new ConstraintSource(Source, ModelRoot); - } - if (m_dst == null) - { - m_dst = new ConstraintDestination(transform, ModelRoot); - } - - OnProcess(); - } - - public abstract void OnProcess(); + public abstract void Process(); } } diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs index ba762d967..cdb0ada3f 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs @@ -1,40 +1,23 @@ -using System; -using UniGLTF.Extensions.VRMC_node_constraint; -using UnityEngine; +using UnityEngine; namespace UniVRM10 { /// - /// 対象の初期回転と現在回転の差分(delta)を、自身の初期回転と自身の初期回転にdeltaを乗算したものに対してWeightでSlerpする。 + /// https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.rotationConstraint.schema.json /// [DisallowMultipleComponent] - public class VRM10RotationConstraint : VRM10RotationPositionConstraintBase + public class Vrm10RotationConstraint : Vrm10Constraint { - public override Vector3 Delta => Axes.Mask(Quaternion.Slerp(Quaternion.identity, m_delta.Rotation, Weight).eulerAngles); + [SerializeField] + public Transform Source = default; - public override TR GetSourceCurrent() - { - var coords = GetSourceCoords(); - if (m_src == null) - { - return coords; - } - return coords * new TR(m_delta.Rotation); - } + [SerializeField] + [Range(0, 10.0f)] + public float Weight = 1.0f; - public override TR GetDstCurrent() + public override void Process() { - var coords = GetDstCoords(); - if (m_src == null) - { - return coords; - } - return coords * new TR(m_delta.Rotation); - } - - protected override void ApplyDelta() - { - m_dst.ApplyLocal(m_dst.LocalInitial * new TR(DestinationOffset) * new TR(Quaternion.Euler(Delta))); + throw new System.NotImplementedException(); } } } diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs deleted file mode 100644 index 7c4cf74e8..000000000 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using UniGLTF.Extensions.VRMC_node_constraint; -using UnityEngine; - -namespace UniVRM10 -{ - public abstract class VRM10RotationPositionConstraintBase : VRM10Constraint - { - [SerializeField] - [EnumFlags] - AxisMask m_axes = AxisMask.X | AxisMask.Y | AxisMask.Z; - public AxisMask Axes - { - get => m_axes; - set => m_axes = value; - } - - #region Source - [Header("Source")] - [SerializeField] - Transform m_source = default; - public override Transform Source - { - get => m_source; - set => m_source = value; - } - - - [SerializeField] - VRM10RotationOffset m_sourceOffset = VRM10RotationOffset.Identity; - - public Quaternion SourceOffset - { - get => m_sourceOffset.Rotation; - set => m_sourceOffset.Rotation = value; - } - #endregion - - - #region Destination - [Header("Destination")] - [SerializeField] - public VRM10RotationOffset m_destinationOffset = VRM10RotationOffset.Identity; - - public Quaternion DestinationOffset - { - get => m_destinationOffset.Rotation; - set => m_destinationOffset.Rotation = value; - } - #endregion - - public TR GetSourceCoords() - { - if (Source == null) - { - throw new ConstraintException(ConstraintException.ExceptionTypes.NoSource); - } - - var init = SourceInitialCoords(); - return new TR(init.Rotation * SourceOffset, init.Translation); - } - - public abstract TR GetSourceCurrent(); - - public TR GetDstCoords() - { - var init = DestinationInitialCoords(); - return new TR(init.Rotation * DestinationOffset, init.Translation); - } - - public abstract TR GetDstCurrent(); - - /// - /// Editorで設定値の変更を反映するために、クリアする - /// - void OnValidate() - { - // Debug.Log("Validate"); - if (m_src != null && m_src.ModelRoot != ModelRoot) - { - m_src = null; - } - if (m_dst != null && m_dst.ModelRoot != ModelRoot) - { - m_dst = null; - } - } - - public Component GetComponent() - { - return this; - } - - protected TR m_delta; - public abstract Vector3 Delta { get; } - - protected abstract void ApplyDelta(); - - public override void OnProcess() - { - m_delta = m_src.Delta(SourceOffset); - ApplyDelta(); - } - } -} diff --git a/Assets/VRM10/Runtime/Components/Constraint/Vrm10AimConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/Vrm10AimConstraint.cs new file mode 100644 index 000000000..87d7405f7 --- /dev/null +++ b/Assets/VRM10/Runtime/Components/Constraint/Vrm10AimConstraint.cs @@ -0,0 +1,26 @@ +using UnityEngine; + +namespace UniVRM10 +{ + /// + /// https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.aimConstraint.schema.json + /// + [DisallowMultipleComponent] + public class Vrm10AimConstraint : Vrm10Constraint + { + [SerializeField] + public Transform Source = default; + + [SerializeField] + [Range(0, 10.0f)] + public float Weight = 1.0f; + + [SerializeField] + public UniGLTF.Extensions.VRMC_node_constraint.AimAxis AimAxis; + + public override void Process() + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs.meta b/Assets/VRM10/Runtime/Components/Constraint/Vrm10AimConstraint.cs.meta similarity index 83% rename from Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs.meta rename to Assets/VRM10/Runtime/Components/Constraint/Vrm10AimConstraint.cs.meta index bac4e2e09..205e03dc4 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs.meta +++ b/Assets/VRM10/Runtime/Components/Constraint/Vrm10AimConstraint.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 07919df684c7a4c47a9492a2de417f66 +guid: 37b0507e4ae49724898ca17cc3db6f1a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM10/Runtime/Components/Constraint/Vrm10RollConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/Vrm10RollConstraint.cs new file mode 100644 index 000000000..199d14a7b --- /dev/null +++ b/Assets/VRM10/Runtime/Components/Constraint/Vrm10RollConstraint.cs @@ -0,0 +1,26 @@ +using UnityEngine; + +namespace UniVRM10 +{ + /// + /// https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.rollConstraint.schema.json + /// + [DisallowMultipleComponent] + public class Vrm10RollConstraint : Vrm10Constraint + { + [SerializeField] + public Transform Source = default; + + [SerializeField] + [Range(0, 10.0f)] + public float Weight = 1.0f; + + [SerializeField] + public UniGLTF.Extensions.VRMC_node_constraint.RollAxis RollAxis; + + public override void Process() + { + throw new System.NotImplementedException(); + } + } +} diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs.meta b/Assets/VRM10/Runtime/Components/Constraint/Vrm10RollConstraint.cs.meta similarity index 83% rename from Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs.meta rename to Assets/VRM10/Runtime/Components/Constraint/Vrm10RollConstraint.cs.meta index c162c586c..4c6dc5979 100644 --- a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs.meta +++ b/Assets/VRM10/Runtime/Components/Constraint/Vrm10RollConstraint.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 46c1f13688fee134aa37a39a72433217 +guid: 1e864293edac89b40b9f79c23e7aa547 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10Runtime.cs b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10Runtime.cs index 7bcad98b1..d446c917d 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10Runtime.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10Runtime.cs @@ -12,7 +12,7 @@ namespace UniVRM10 public class Vrm10Runtime : IDisposable { private readonly Vrm10Instance m_target; - private readonly VRM10Constraint[] m_constraints; + private readonly Vrm10Constraint[] m_constraints; private readonly Transform m_head; private readonly FastSpringBoneService m_fastSpringBoneService; @@ -39,7 +39,7 @@ namespace UniVRM10 if (m_constraints == null) { - m_constraints = target.GetComponentsInChildren(); + m_constraints = target.GetComponentsInChildren(); } if (!Application.isPlaying) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index 6e98d2308..fefa6ec2a 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -401,14 +401,43 @@ namespace UniVRM10 static void ExportConstraints(Vrm10Instance vrmController, Model model, ModelExporter converter, List nodes) { - var constraints = vrmController.GetComponentsInChildren(); + var constraints = vrmController.GetComponentsInChildren(); foreach (var constraint in constraints) { - UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint vrmConstraint = default; + var vrmConstraint = new UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint + { + SpecVersion = NODE_CONSTRAINT_SPEC_VERSION, + Constraint = new UniGLTF.Extensions.VRMC_node_constraint.Constraint + { + }, + }; + switch (constraint) { - case VRM10RotationConstraint rotationConstraint: - vrmConstraint = ExportRotationConstraint(rotationConstraint, model, converter); + case Vrm10AimConstraint aimConstraint: + vrmConstraint.Constraint.Aim = new UniGLTF.Extensions.VRMC_node_constraint.AimConstraint + { + Source = model.Nodes.IndexOf(converter.Nodes[aimConstraint.Source.gameObject]), + Weight = aimConstraint.Weight, + AimAxis = aimConstraint.AimAxis, + }; + break; + + case Vrm10RollConstraint rollConstraint: + vrmConstraint.Constraint.Roll = new UniGLTF.Extensions.VRMC_node_constraint.RollConstraint + { + Source = model.Nodes.IndexOf(converter.Nodes[rollConstraint.Source.gameObject]), + Weight = rollConstraint.Weight, + RollAxis = rollConstraint.RollAxis, + }; + break; + + case Vrm10RotationConstraint rotationConstraint: + vrmConstraint.Constraint.Rotation = new UniGLTF.Extensions.VRMC_node_constraint.RotationConstraint + { + Source = model.Nodes.IndexOf(converter.Nodes[rotationConstraint.Source.gameObject]), + Weight = rotationConstraint.Weight, + }; break; default: @@ -433,22 +462,6 @@ namespace UniVRM10 }; } - static UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint ExportRotationConstraint(VRM10RotationConstraint c, Model model, ModelExporter converter) - { - return new UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint - { - SpecVersion = NODE_CONSTRAINT_SPEC_VERSION, - Constraint = new UniGLTF.Extensions.VRMC_node_constraint.Constraint - { - Rotation = new UniGLTF.Extensions.VRMC_node_constraint.RotationConstraint - { - Source = model.Nodes.IndexOf(converter.Nodes[c.Source.gameObject]), - // Axes = ToArray(c.Axes), - Weight = c.Weight, - }, - }, - }; - } static UniGLTF.Extensions.VRMC_vrm.MeshAnnotation ExportMeshAnnotation(RendererFirstPersonFlags flags, Transform root, Func getIndex) { diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 50b510a91..355b1fc47 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -652,6 +652,17 @@ namespace UniVRM10 return v; } + /// + /// https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_node_constraint-1.0_draft + /// + /// * roll + /// * aim + /// * rotaton + /// + /// + /// + /// + /// async Task LoadConstraintAsync(IAwaitCaller awaitCaller, Vrm10Instance controller) { for (int i = 0; i < Data.GLTF.nodes.Count; ++i) @@ -661,14 +672,32 @@ namespace UniVRM10 { var constraint = ext.Constraint; var node = Nodes[i]; - if (constraint.Rotation != null) + if (constraint.Roll != null) { - var r = constraint.Rotation; - var rotationConstraint = node.gameObject.AddComponent(); - rotationConstraint.Source = Nodes[r.Source.Value]; - // rotationConstraint.Axes = ConstraintAxes(r.Axes); - rotationConstraint.Weight = r.Weight.Value; - rotationConstraint.ModelRoot = Root.transform; + var roll = constraint.Roll; + var component = node.gameObject.AddComponent(); + component.Source = Nodes[roll.Source.Value]; + component.Weight = roll.Weight.Value; + component.RollAxis = roll.RollAxis; + } + else if (constraint.Aim != null) + { + var aim = constraint.Aim; + var component = node.gameObject.AddComponent(); + component.Source = Nodes[aim.Source.Value]; + component.Weight = aim.Weight.Value; + component.AimAxis = aim.AimAxis; + } + else if (constraint.Rotation != null) + { + var rotation = constraint.Rotation; + var component = node.gameObject.AddComponent(); + component.Source = Nodes[rotation.Source.Value]; + component.Weight = rotation.Weight.Value; + } + else + { + throw new NotImplementedException(); } } }