GetSourceCurrent

This commit is contained in:
ousttrue
2021-05-10 20:18:32 +09:00
parent 22b3613df9
commit c806dc6186
3 changed files with 58 additions and 7 deletions

View File

@@ -20,12 +20,9 @@ namespace UniVRM10
void DrawSourceCurrent()
{
var s = m_target.transform.lossyScale.x;
// current
Handles.matrix = m_target.Source.localToWorldMatrix;
Handles.matrix = m_target.GetSourceCurrent().TRS(0.05f * s);
Handles.color = Color.yellow;
var size = 0.05f / s;
Handles.DrawWireCube(Vector3.zero, new Vector3(size, size, size));
Handles.DrawWireCube(Vector3.zero, Vector3.one);
}
void DrawSourceCoords()

View File

@@ -34,10 +34,9 @@ namespace UniVRM10
{
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);
case ObjectSpace.model: return m_transform.rotation * Quaternion.Inverse(ModelRoot.rotation) * Quaternion.Inverse(ModelInitial.Rotation);
case ObjectSpace.model: return m_transform.rotation * Quaternion.Inverse(ModelInitial.Rotation) * Quaternion.Inverse(ModelRoot.rotation);
default: throw new NotImplementedException();
}
}

View File

@@ -92,6 +92,61 @@ namespace UniVRM10
throw new NotImplementedException();
}
public TR GetSourceCurrent()
{
switch (SourceCoordinate)
{
case ObjectSpace.model:
{
var r = Quaternion.identity;
if (Source != null)
{
if (ModelRoot != null)
{
r = ModelRoot.rotation;
if (m_src != null)
{
r *= m_src.RotationDelta(ObjectSpace.model);
}
}
}
var t = Vector3.zero;
if (Source != null)
{
t = Source.position;
}
return new TR(r, t);
}
case ObjectSpace.local:
{
if (Source != null)
{
if (m_src != null)
{
// runtime
var parent = TR.Identity;
if (Source.parent != null)
{
parent = TR.FromWorld(Source.parent);
}
return parent * m_src.LocalInitial;
}
else
{
return TR.FromWorld(Source);
}
}
return TR.Identity;
}
}
throw new NotImplementedException();
}
public Quaternion Delta
{
get;