mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-16 07:34:05 -05:00
42 lines
1014 B
C#
42 lines
1014 B
C#
using UnityEngine;
|
|
|
|
namespace UniVRM10
|
|
{
|
|
struct TRS
|
|
{
|
|
public Vector3 Translation;
|
|
public Quaternion Rotation;
|
|
public Vector3 Scale;
|
|
|
|
public static TRS GetWorld(Transform t)
|
|
{
|
|
return new TRS
|
|
{
|
|
Translation = t.position,
|
|
Rotation = t.rotation,
|
|
Scale = t.lossyScale,
|
|
};
|
|
}
|
|
|
|
public static TRS GetLocal(Transform t)
|
|
{
|
|
return new TRS
|
|
{
|
|
Translation = t.localPosition,
|
|
Rotation = t.localRotation,
|
|
Scale = t.localScale,
|
|
};
|
|
}
|
|
|
|
public static TRS GetRelative(Transform t, Matrix4x4 toRelative)
|
|
{
|
|
return new TRS
|
|
{
|
|
Translation = toRelative.MultiplyPoint(t.position),
|
|
Rotation = toRelative.rotation * t.rotation,
|
|
Scale = toRelative.MultiplyVector(t.lossyScale),
|
|
};
|
|
}
|
|
}
|
|
}
|