Coordinate conversion¶
UniVRM convert coordinate when import or export
right |
up |
forward |
chirality |
Origin of Texture coordinates |
||
---|---|---|---|---|---|---|
Unity |
+X |
+Y |
+Z |
Left handed |
left bottom |
|
VRM-0 |
+X |
+Y |
-Z |
Right handed |
left top |
|
VRM-1 |
-X |
+Y |
+Z |
Right handed |
left top |
|
glTF |
+Y |
Right handed |
left top |
The default is the VRM-0 method. Vrm-1 method can be selected as an option |
UV¶
The following conversions
\[V^{\prime} = 1 - V\]
Unity <-> VRM0¶
Invert Z-axis
Vector3: Position, Normal, etc.¶
public static Vector3 ReverseZ(this Vector3 v)
{
return new Vector3(v.x, v.y, -v.z);
}
Quaternion: Rotation¶
public static Quaternion ReverseZ(this Quaternion q)
{
float angle;
Vector3 axis;
q.ToAngleAxis(out angle, out axis);
return Quaternion.AngleAxis(-angle, ReverseZ(axis));
}
Matrix: BindMatrices¶
If the scale value is in it, it does not work.
public static Matrix4x4 ReverseZ(this Matrix4x4 m)
{
#if UNITY_2017_1_OR_NEWER
m.SetTRS(m.GetColumn(3).ReverseZ(), m.rotation.ReverseZ(), Vector3.one);
#else
m.SetTRS(m.ExtractPosition().ReverseZ(), m.ExtractRotation().ReverseZ(), Vector3.one);
#endif
return m;
}
Unity <-> VRM1¶
Invert X-axis