mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-13 22:09:53 -05:00
fix no weight bone
This commit is contained in:
parent
cf4dfb0fdb
commit
2be66df5aa
|
|
@ -73,6 +73,12 @@ namespace UniGLTF.MeshUtility
|
|||
var r = _renderers[index];
|
||||
EditorGUI.ObjectField(rect, r, typeof(Renderer), true);
|
||||
};
|
||||
|
||||
// +ボタンが押された時のコールバック
|
||||
_rendererList.onAddCallback = list => Debug.Log("+ clicked.");
|
||||
|
||||
// -ボタンが押された時のコールバック
|
||||
_rendererList.onRemoveCallback = list => Debug.Log("- clicked : " + list.index + ".");
|
||||
}
|
||||
|
||||
public void UpdateMeshIntegrationList(GameObject root)
|
||||
|
|
|
|||
|
|
@ -85,6 +85,13 @@ namespace UniGLTF.MeshUtility
|
|||
src.ApplyMatrix(m);
|
||||
}
|
||||
|
||||
public static void ApplyTranslation(this Mesh src, Vector3 p)
|
||||
{
|
||||
var m = Matrix4x4.identity;
|
||||
m.SetColumn(3, new Vector4(p.x, p.y, p.z, 1));
|
||||
src.ApplyMatrix(m);
|
||||
}
|
||||
|
||||
public static void ApplyMatrix(this Mesh src, Matrix4x4 m)
|
||||
{
|
||||
src.vertices = src.vertices.Select(x => m.MultiplyPoint(x)).ToArray();
|
||||
|
|
|
|||
|
|
@ -149,10 +149,7 @@ namespace UniGLTF.MeshUtility
|
|||
// Before bake, bind no weight bones
|
||||
|
||||
srcMesh = srcMesh.Copy(true);
|
||||
var rootBone = src.rootBone ?? src.transform;
|
||||
srcMesh.ApplyRotationAndScale(rootBone.localToWorldMatrix, false);
|
||||
|
||||
Debug.LogFormat($"apply: {src.transform} {rootBone}");
|
||||
srcMesh.ApplyRotationAndScale(src.transform.localToWorldMatrix, false);
|
||||
|
||||
var bw = new BoneWeight
|
||||
{
|
||||
|
|
@ -166,8 +163,9 @@ namespace UniGLTF.MeshUtility
|
|||
weight3 = 0.0f,
|
||||
};
|
||||
srcMesh.boneWeights = Enumerable.Range(0, srcMesh.vertexCount).Select(x => bw).ToArray();
|
||||
src.rootBone = rootBone;
|
||||
src.bones = new[] { rootBone };
|
||||
src.bones = new[] { src.rootBone ?? src.transform };
|
||||
srcMesh.bindposes = src.bones.Select(x => x.worldToLocalMatrix).ToArray();
|
||||
|
||||
src.sharedMesh = srcMesh;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user