diff --git a/Assets/UniGLTF/Editor/MeshUtility/MeshIntegrationTab.cs b/Assets/UniGLTF/Editor/MeshUtility/MeshIntegrationTab.cs index 52d753bf2..85ceb93a9 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/MeshIntegrationTab.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/MeshIntegrationTab.cs @@ -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) diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs index 22cc35a7b..736a63645 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs @@ -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(); diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs index f16c8bed2..3f903f7a7 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs @@ -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; }