mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-20 22:17:41 -05:00
Delta
This commit is contained in:
parent
da4ae3f0e5
commit
c2641b2fb4
|
|
@ -19,6 +19,17 @@ namespace UniVRM10
|
|||
/// </summary>
|
||||
public readonly TR LocalInitial;
|
||||
|
||||
public TR Delta(ObjectSpace coords, Quaternion sourceRotationOffset)
|
||||
{
|
||||
switch (coords)
|
||||
{
|
||||
// case SourceCoordinates.World: return m_transform.rotation * Quaternion.Inverse(m_initial.Rotation);
|
||||
case ObjectSpace.local: return TR.FromLocal(m_transform) * (LocalInitial * new TR(sourceRotationOffset)).Inverse();
|
||||
case ObjectSpace.model: return TR.FromWorld(m_transform) * (TR.FromWorld(ModelRoot) * ModelInitial * new TR(sourceRotationOffset)).Inverse();
|
||||
default: throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 TranslationDelta(ObjectSpace coords)
|
||||
{
|
||||
switch (coords)
|
||||
|
|
@ -30,30 +41,30 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
public Quaternion RotationDelta(ObjectSpace coords, Quaternion sourceRotationOffset)
|
||||
{
|
||||
switch (coords)
|
||||
{
|
||||
// case SourceCoordinates.World: return m_transform.rotation * Quaternion.Inverse(m_initial.Rotation);
|
||||
case ObjectSpace.local: return m_transform.localRotation * Quaternion.Inverse(LocalInitial.Rotation * sourceRotationOffset);
|
||||
case ObjectSpace.model: return m_transform.rotation * Quaternion.Inverse(ModelInitial.Rotation * sourceRotationOffset) * Quaternion.Inverse(ModelRoot.rotation);
|
||||
default: throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
// public Quaternion RotationDelta(ObjectSpace coords, Quaternion sourceRotationOffset)
|
||||
// {
|
||||
// return Delta(coords, sourceRotationOffset).Rotation;
|
||||
|
||||
// switch (coords)
|
||||
// {
|
||||
// // case SourceCoordinates.World: return m_transform.rotation * Quaternion.Inverse(m_initial.Rotation);
|
||||
// case ObjectSpace.local: return m_transform.localRotation * Quaternion.Inverse(LocalInitial.Rotation * sourceRotationOffset);
|
||||
// case ObjectSpace.model: return m_transform.rotation * Quaternion.Inverse(ModelInitial.Rotation * sourceRotationOffset) * Quaternion.Inverse(ModelRoot.rotation);
|
||||
// default: throw new NotImplementedException();
|
||||
// }
|
||||
// }
|
||||
|
||||
public ConstraintSource(Transform t, Transform modelRoot = null)
|
||||
{
|
||||
m_transform = t;
|
||||
|
||||
{
|
||||
m_transform = t;
|
||||
LocalInitial = TR.FromLocal(t);
|
||||
}
|
||||
|
||||
if (modelRoot != null)
|
||||
{
|
||||
var world = TR.FromWorld(t);
|
||||
ModelRoot = modelRoot;
|
||||
ModelInitial = new TR(world.Rotation * Quaternion.Inverse(ModelRoot.rotation), modelRoot.worldToLocalMatrix.MultiplyPoint(world.Translation));
|
||||
ModelInitial = TR.FromWorld(t) * TR.FromWorld(ModelRoot).Inverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace UniVRM10
|
|||
|
||||
protected override void UpdateDelta()
|
||||
{
|
||||
m_delta = m_src.RotationDelta(SourceCoordinate, SourceOffset);
|
||||
m_delta = m_src.Delta(SourceCoordinate, SourceOffset).Rotation;
|
||||
|
||||
// 軸制限
|
||||
var fleezed = FreezeAxes.Freeze(Delta);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user