Bind bone before normalization

This commit is contained in:
ousttrue
2018-07-30 16:40:14 +09:00
parent 92501ae8ab
commit 2cd29895ab
2 changed files with 56 additions and 42 deletions

View File

@@ -17,12 +17,13 @@ namespace VRM
dst.vertices = src.vertices;
dst.normals = src.normals;
dst.tangents = src.tangents;
if (src.colors != null && src.colors.Length > 0) dst.colors = src.colors;
if (src.uv != null && src.uv.Length > 0) dst.uv = src.uv;
if (src.uv2 != null && src.uv2.Length > 0) dst.uv2 = src.uv2;
if (src.uv3 != null && src.uv3.Length > 0) dst.uv3 = src.uv3;
if (src.uv4 != null && src.uv4.Length > 0) dst.uv4 = src.uv4;
dst.colors = src.colors;
dst.uv = src.uv;
dst.uv2 = src.uv2;
dst.uv3 = src.uv3;
dst.uv4 = src.uv4;
dst.boneWeights = src.boneWeights;
dst.bindposes = src.bindposes;
dst.subMeshCount = src.subMeshCount;
for (int i = 0; i < dst.subMeshCount; ++i)
@@ -30,19 +31,19 @@ namespace VRM
dst.SetIndices(src.GetIndices(i), src.GetTopology(i), i);
}
dst.RecalculateBounds();
return dst;
}
public static void ApplyRotationAndScale(this Mesh src, Matrix4x4 m)
{
m.SetColumn(3, new Vector4(0, 0, 0, 1));
m.SetColumn(3, new Vector4(0, 0, 0, 1)); // remove translation
src.ApplyMatrix(m);
}
public static void ApplyMatrix(this Mesh src, Matrix4x4 m)
{
m.SetColumn(3, new Vector4(0, 0, 0, 1));
src.vertices = src.vertices.Select(x => m.MultiplyPoint(x)).ToArray();
if (src.normals != null && src.normals.Length > 0)
{