From 56db0e2e54f4f627991770c55111c4ce1671408f Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 1 Jun 2021 18:09:41 +0900 Subject: [PATCH 1/2] rename namespace MeshUtility to UniGLTF.MeshUtility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * MeshUtility と UniGLTF に重複していたクラスを削除 --- .../UniGLTF/Editor/MeshUtility/AssetsPath.cs | 2 +- .../MeshUtility/BoneMeshEraserWizard.cs | 2 +- .../Editor/MeshUtility/HumanoidEditor.cs | 2 +- .../Editor/MeshUtility/MeshProcessDialog.cs | 2 +- .../UniGLTF/Editor/MeshUtility/MeshUtility.cs | 2 +- .../Editor/MeshUtility/TextureSaver.cs | 2 +- .../Editor/UniGLTF/ExportDialog/TabBar.cs | 2 +- .../Runtime/MeshUtility/BindposeGizmo.cs | 2 +- .../Runtime/MeshUtility/BoneMeshEraser.cs | 2 +- .../Runtime/MeshUtility/BoneNormalizer.cs | 2 +- .../UniGLTF/Runtime/MeshUtility/Humanoid.cs | 2 +- .../Runtime/MeshUtility/HumanoidLoader.cs | 2 +- .../Runtime/MeshUtility/MeshExtensions.cs | 2 +- .../MeshUtility/MeshIntegrationResult.cs | 2 +- .../Runtime/MeshUtility/MeshIntegrator.cs | 2 +- .../MeshUtility/MeshIntegratorUtility.cs | 2 +- .../MeshUtility/StaticMeshIntegrator.cs | 2 +- .../Runtime/MeshUtility/UnityExtensions.cs | 319 ------------- .../MeshUtility/UnityExtensions.cs.meta | 11 - .../UniGLTF/Runtime/MeshUtility/UnityPath.cs | 435 ------------------ .../Runtime/MeshUtility/UnityPath.cs.meta | 12 - .../Editor/Tests/VRMImportExportTests.cs | 2 +- Assets/VRM/Editor/Format/VRMEditorExporter.cs | 3 +- Assets/VRM/Editor/Format/VRMExporterWizard.cs | 3 +- Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs | 2 +- .../MeshIntegratorEditor.cs | 3 +- .../MeshIntegratorWizard.cs | 6 +- .../VRMSpringBoneColliderGroupEditor.cs | 1 - .../VRM/Runtime/FirstPerson/VRMFirstPerson.cs | 3 +- .../SkinnedMeshUtility/VRMBoneNormalizer.cs | 3 +- .../VRMMeshIntegratorUtility.cs | 11 +- Assets/VRM/Tests/MeshTests.cs | 3 +- Assets/VRM/Tests/NormalizeTests.cs | 5 +- .../Expression/ExpressionEditorBase.cs | 3 +- .../Expression/VRM10ExpressionEditor.cs | 2 +- Assets/VRM10/Editor/EditorUnityBuilder.cs | 139 ------ .../VRM10/Editor/EditorUnityBuilder.cs.meta | 11 - .../VrmScriptedImporterEditorGUI.cs | 3 +- Assets/VRM10/Editor/Vrm10ExportDialog.cs | 3 +- .../Components/Expression/VRM10Expression.cs | 3 +- .../Expression/VRM10ExpressionAvatar.cs | 2 +- .../Components/Meta/VRM10MetaObject.cs | 4 +- .../Components/VRM10ControllerFirstPerson.cs | 2 +- .../VRM10/Runtime/IO/Model/ModelExporter.cs | 5 +- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 2 +- 45 files changed, 56 insertions(+), 979 deletions(-) delete mode 100644 Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs delete mode 100644 Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs.meta delete mode 100644 Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs delete mode 100644 Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs.meta delete mode 100644 Assets/VRM10/Editor/EditorUnityBuilder.cs delete mode 100644 Assets/VRM10/Editor/EditorUnityBuilder.cs.meta diff --git a/Assets/UniGLTF/Editor/MeshUtility/AssetsPath.cs b/Assets/UniGLTF/Editor/MeshUtility/AssetsPath.cs index 96f575f20..f3bedd50e 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/AssetsPath.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/AssetsPath.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using UnityEditor; -namespace MeshUtility +namespace UniGLTF.MeshUtility { /// /// Application.dataPath を root とするファイルパスを扱う。 diff --git a/Assets/UniGLTF/Editor/MeshUtility/BoneMeshEraserWizard.cs b/Assets/UniGLTF/Editor/MeshUtility/BoneMeshEraserWizard.cs index cae2b87c1..3b08ccf69 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/BoneMeshEraserWizard.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/BoneMeshEraserWizard.cs @@ -6,7 +6,7 @@ using UnityEditor; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { [CustomPropertyDrawer(typeof(BoneMeshEraser.EraseBone))] public class EraseBoneDrawer : PropertyDrawer diff --git a/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs b/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs index f9a99cfc1..a7f9a72c5 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs @@ -6,7 +6,7 @@ using UnityEditor; using UnityEngine; using System; -namespace MeshUtility +namespace UniGLTF.MeshUtility { [CustomEditor(typeof(Humanoid))] public class HumanoidEditor : Editor diff --git a/Assets/UniGLTF/Editor/MeshUtility/MeshProcessDialog.cs b/Assets/UniGLTF/Editor/MeshUtility/MeshProcessDialog.cs index 9d4722de4..965872ed6 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/MeshProcessDialog.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/MeshProcessDialog.cs @@ -7,7 +7,7 @@ using UnityEditor; using UniGLTF; using UniGLTF.M17N; -namespace MeshUtility +namespace UniGLTF.MeshUtility { [CustomEditor(typeof(MeshProcessDialog), true)] public class BoneMeshEraserGUI : Editor diff --git a/Assets/UniGLTF/Editor/MeshUtility/MeshUtility.cs b/Assets/UniGLTF/Editor/MeshUtility/MeshUtility.cs index 017a8d56c..e1e8dc265 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/MeshUtility.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/MeshUtility.cs @@ -4,7 +4,7 @@ using System.Linq; using UnityEngine; using UnityEditor; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public class MeshUtility { diff --git a/Assets/UniGLTF/Editor/MeshUtility/TextureSaver.cs b/Assets/UniGLTF/Editor/MeshUtility/TextureSaver.cs index a4c050b56..593c7152f 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/TextureSaver.cs +++ b/Assets/UniGLTF/Editor/MeshUtility/TextureSaver.cs @@ -4,7 +4,7 @@ using UnityEngine; using VRMShaders; using ColorSpace = VRMShaders.ColorSpace; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class EditorChangeTextureType { diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/TabBar.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/TabBar.cs index f06237363..8bea7db02 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/TabBar.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/TabBar.cs @@ -3,7 +3,7 @@ using System.Linq; using UnityEditor; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class TabBar diff --git a/Assets/UniGLTF/Runtime/MeshUtility/BindposeGizmo.cs b/Assets/UniGLTF/Runtime/MeshUtility/BindposeGizmo.cs index 23e233e5e..886e7daf1 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/BindposeGizmo.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/BindposeGizmo.cs @@ -7,7 +7,7 @@ using UnityEditor; #endif -namespace MeshUtility +namespace UniGLTF.MeshUtility { [DisallowMultipleComponent] public class BindposeGizmo : MonoBehaviour diff --git a/Assets/UniGLTF/Runtime/MeshUtility/BoneMeshEraser.cs b/Assets/UniGLTF/Runtime/MeshUtility/BoneMeshEraser.cs index 64ee850d0..32952aead 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/BoneMeshEraser.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/BoneMeshEraser.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class BoneMeshEraser { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs b/Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs index 4747dbd2e..5ab40f94c 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs @@ -4,7 +4,7 @@ using System.Linq; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class BoneNormalizer { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs b/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs index c6d619483..abb9511a2 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { /// /// Bone割り当てを保持する。 diff --git a/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs b/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs index 2a5d52521..37b492d05 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class HumanoidLoader { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs index aa458d524..253906fc8 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshExtensions.cs @@ -2,7 +2,7 @@ using System.Linq; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class MeshExtensions { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrationResult.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrationResult.cs index 91742fc8b..56ffa4456 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrationResult.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrationResult.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { [System.Serializable] public class MeshIntegrationResult diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs index 34ba70052..76b4bffeb 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrator.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public class MeshIntegrator { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs index 8285af6e6..5ae99d60a 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshIntegratorUtility.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class MeshIntegratorUtility { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/StaticMeshIntegrator.cs b/Assets/UniGLTF/Runtime/MeshUtility/StaticMeshIntegrator.cs index e865b5a17..342dae79c 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/StaticMeshIntegrator.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/StaticMeshIntegrator.cs @@ -7,7 +7,7 @@ using UnityEditor; #endif -namespace MeshUtility +namespace UniGLTF.MeshUtility { public static class StaticMeshIntegrator { diff --git a/Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs b/Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs deleted file mode 100644 index a772980d3..000000000 --- a/Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs +++ /dev/null @@ -1,319 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -#if UNITY_EDITOR -using UnityEditor; -#endif - - -namespace MeshUtility -{ - public struct PosRot - { - public Vector3 Position; - public Quaternion Rotation; - - public static PosRot FromGlobalTransform(Transform t) - { - return new PosRot - { - Position = t.position, - Rotation = t.rotation, - }; - } - } - - public class BlendShape - { - public string Name; - - public BlendShape(string name) - { - Name = name; - } - - public List Positions = new List(); - public List Normals = new List(); - public List Tangents = new List(); - } - - public static class UnityExtensions - { - public static Vector4 ReverseZ(this Vector4 v) - { - return new Vector4(v.x, v.y, -v.z, v.w); - } - - public static Vector3 ReverseZ(this Vector3 v) - { - return new Vector3(v.x, v.y, -v.z); - } - - [Obsolete] - public static Vector2 ReverseY(this Vector2 v) - { - return new Vector2(v.x, -v.y); - } - - public static Vector2 ReverseUV(this Vector2 v) - { - return new Vector2(v.x, 1.0f - v.y); - } - - public static Quaternion ReverseZ(this Quaternion q) - { - float angle; - Vector3 axis; - q.ToAngleAxis(out angle, out axis); - return Quaternion.AngleAxis(-angle, ReverseZ(axis)); - } - - public static Matrix4x4 Matrix4x4FromColumns(Vector4 c0, Vector4 c1, Vector4 c2, Vector4 c3) - { -#if UNITY_2017_1_OR_NEWER - return new Matrix4x4(c0, c1, c2, c3); -#else - var m = default(Matrix4x4); - m.SetColumn(0, c0); - m.SetColumn(1, c1); - m.SetColumn(2, c2); - m.SetColumn(3, c3); - return m; -#endif - } - - public static Matrix4x4 Matrix4x4FromRotation(Quaternion q) - { -#if UNITY_2017_1_OR_NEWER - return Matrix4x4.Rotate(q); -#else - var m = default(Matrix4x4); - m.SetTRS(Vector3.zero, q, Vector3.one); - return m; -#endif - } - - public static Matrix4x4 ReverseZ(this Matrix4x4 m) - { - m.SetTRS(m.ExtractPosition().ReverseZ(), m.ExtractRotation().ReverseZ(), m.ExtractScale()); - return m; - } - - public static Matrix4x4 MatrixFromArray(float[] values) - { - var m = new Matrix4x4(); - m.m00 = values[0]; - m.m10 = values[1]; - m.m20 = values[2]; - m.m30 = values[3]; - m.m01 = values[4]; - m.m11 = values[5]; - m.m21 = values[6]; - m.m31 = values[7]; - m.m02 = values[8]; - m.m12 = values[9]; - m.m22 = values[10]; - m.m32 = values[11]; - m.m03 = values[12]; - m.m13 = values[13]; - m.m23 = values[14]; - m.m33 = values[15]; - return m; - } - - // https://forum.unity.com/threads/how-to-assign-matrix4x4-to-transform.121966/ - public static Quaternion ExtractRotation(this Matrix4x4 matrix) - { - Vector3 forward; - forward.x = matrix.m02; - forward.y = matrix.m12; - forward.z = matrix.m22; - - Vector3 upwards; - upwards.x = matrix.m01; - upwards.y = matrix.m11; - upwards.z = matrix.m21; - - return Quaternion.LookRotation(forward, upwards); - } - - public static Vector3 ExtractPosition(this Matrix4x4 matrix) - { - Vector3 position; - position.x = matrix.m03; - position.y = matrix.m13; - position.z = matrix.m23; - return position; - } - - public static Vector3 ExtractScale(this Matrix4x4 matrix) - { - Vector3 scale; - scale.x = new Vector4(matrix.m00, matrix.m10, matrix.m20, matrix.m30).magnitude; - scale.y = new Vector4(matrix.m01, matrix.m11, matrix.m21, matrix.m31).magnitude; - scale.z = new Vector4(matrix.m02, matrix.m12, matrix.m22, matrix.m32).magnitude; - return scale; - } - - public static string RelativePathFrom(this Transform self, Transform root) - { - var path = new List(); - for (var current = self; current != null; current = current.parent) - { - if (current == root) - { - return String.Join("/", path.ToArray()); - } - - path.Insert(0, current.name); - } - - throw new Exception("no RelativePath"); - } - - public static Transform GetChildByName(this Transform self, string childName) - { - foreach (Transform child in self) - { - if (child.name == childName) - { - return child; - } - } - - throw new KeyNotFoundException(); - } - - public static Transform GetFromPath(this Transform self, string path) - { - var current = self; - - var split = path.Split('/'); - - foreach (var childName in split) - { - current = current.GetChildByName(childName); - } - - return current; - } - - public static IEnumerable GetChildren(this Transform self) - { - foreach (Transform child in self) - { - yield return child; - } - } - - public static IEnumerable Traverse(this Transform t) - { - yield return t; - foreach (Transform x in t) - { - foreach (Transform y in x.Traverse()) - { - yield return y; - } - } - } - - [Obsolete("Use FindDescendant(name)")] - public static Transform FindDescenedant(this Transform t, string name) - { - return FindDescendant(t, name); - } - - public static Transform FindDescendant(this Transform t, string name) - { - return t.Traverse().First(x => x.name == name); - } - - public static IEnumerable Ancestors(this Transform t) - { - yield return t; - if (t.parent != null) - { - foreach (Transform x in t.parent.Ancestors()) - { - yield return x; - } - } - } - - public static float[] ToArray(this Quaternion q) - { - return new float[] { q.x, q.y, q.z, q.w }; - } - - public static float[] ToArray(this Vector3 v) - { - return new float[] { v.x, v.y, v.z }; - } - - public static float[] ToArray(this Vector4 v) - { - return new float[] { v.x, v.y, v.z, v.w }; - } - - public static float[] ToArray(this Color c) - { - return new float[] { c.r, c.g, c.b, c.a }; - } - - public static void ReverseZRecursive(this Transform root) - { - var globalMap = root.Traverse().ToDictionary(x => x, x => PosRot.FromGlobalTransform(x)); - - foreach (var x in root.Traverse()) - { - x.position = globalMap[x].Position.ReverseZ(); - x.rotation = globalMap[x].Rotation.ReverseZ(); - } - } - - public static Mesh GetSharedMesh(this Transform t) - { - var meshFilter = t.GetComponent(); - if (meshFilter != null) - { - return meshFilter.sharedMesh; - } - - var skinnedMeshRenderer = t.GetComponent(); - if (skinnedMeshRenderer != null) - { - return skinnedMeshRenderer.sharedMesh; - } - - return null; - } - - public static Material[] GetSharedMaterials(this Transform t) - { - var renderer = t.GetComponent(); - if (renderer != null) - { - return renderer.sharedMaterials; - } - - return new Material[] { }; - } - - public static bool Has(this Transform transform, T t) where T : Component - { - return transform.GetComponent() == t; - } - - public static T GetOrAddComponent(this GameObject go) where T : Component - { - var c = go.GetComponent(); - if (c != null) - { - return c; - } - return go.AddComponent(); - } - } -} diff --git a/Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs.meta b/Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs.meta deleted file mode 100644 index 07785c58f..000000000 --- a/Assets/UniGLTF/Runtime/MeshUtility/UnityExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5294813527b3278458026afc820dd63d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs b/Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs deleted file mode 100644 index 24404741b..000000000 --- a/Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs +++ /dev/null @@ -1,435 +0,0 @@ -using System; -using System.IO; -using UnityEngine; -using System.Collections.Generic; -#if UNITY_EDITOR -using UnityEditor; -#endif - - -namespace MeshUtility -{ - /// - /// relative path from Unity project root. - /// For AssetDatabase. - /// - public struct UnityPath - { - #region UnityPath - public string Value - { - get; - private set; - } - - public override string ToString() - { - return string.Format("unity://{0}", Value); - } - - public bool IsNull - { - get { return Value == null; } - } - - public bool IsUnderAssetsFolder - { - get - { - if (IsNull) - { - return false; - } - return Value == "Assets" || Value.StartsWith("Assets/"); - } - } - - public bool IsStreamingAsset - { - get - { - if (IsNull) - { - return false; - } - - return FullPath.StartsWith(Application.streamingAssetsPath + "/"); - } - } - - public string FileName - { - get { return Path.GetFileName(Value); } - } - - public string FileNameWithoutExtension - { - get { return Path.GetFileNameWithoutExtension(Value); } - } - - public string Extension - { - get { return Path.GetExtension(Value); } - } - - public UnityPath Parent - { - get - { - if (IsNull) - { - return default(UnityPath); - } - - return new UnityPath(Path.GetDirectoryName(Value)); - } - } - - public bool HasParent - { - get - { - return !string.IsNullOrEmpty(Value); - } - } - - static readonly char[] EscapeChars = new char[] - { - '\\', - '/', - ':', - '*', - '?', - '"', - '<', - '>', - '|', - }; - - static string EscapeFilePath(string path) - { - foreach (var x in EscapeChars) - { - path = path.Replace(x, '+'); - } - return path; - } - - public UnityPath Child(string name) - { - if (IsNull) - { - throw new NotImplementedException(); - } - else if (Value == "") - { - return new UnityPath(name); - } - else - { - return new UnityPath(Value + "/" + name); - } - } - - public override int GetHashCode() - { - if (IsNull) - { - return 0; - } - return Value.GetHashCode(); - } - - public override bool Equals(object obj) - { - if(obj is UnityPath) - { - var rhs = (UnityPath)obj; - if(Value==null && rhs.Value == null) - { - return true; - } - else if (Value == null) - { - return false; - } - else if (rhs.Value == null) - { - return false; - } - else - { - return Value == rhs.Value; - } - } - else - { - return false; - } - } - - /// - /// Remove extension and add suffix - /// - /// - /// - /// - public UnityPath GetAssetFolder(string suffix) - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - - return new UnityPath( - string.Format("{0}/{1}{2}", - Parent.Value, - FileNameWithoutExtension, - suffix - )); - } - - UnityPath(string value) : this() - { - Value = value.Replace("\\", "/"); - } - - /// - /// - /// - /// Relative from unity current path. GetParent(Application.dataPath) - /// - public static UnityPath FromUnityPath(string unityPath) - { - if (String.IsNullOrEmpty(unityPath)) - { - return new UnityPath - { - Value="" - }; - } - return FromFullpath(Path.GetFullPath(unityPath)); - } - #endregion - - #region FullPath - static string s_basePath; - static string BaseFullPath - { - get - { - if (string.IsNullOrEmpty(s_basePath)) - { - s_basePath = Path.GetFullPath(Application.dataPath + "/..").Replace("\\", "/"); - } - return s_basePath; - } - } - - static string AssetFullPath - { - get - { - return BaseFullPath + "/Assets"; - } - } - - public string FullPath - { - get - { - if (IsNull) - { - throw new NotImplementedException(); - } - return Path.Combine(BaseFullPath, Value).Replace("\\", "/"); - } - } - - public bool IsFileExists - { - get { return File.Exists(FullPath); } - } - - public bool IsDirectoryExists - { - get { return Directory.Exists(FullPath); } - } - - /// - /// - /// - /// C:/path/to/file - /// - public static UnityPath FromFullpath(string fullPath) - { - if(fullPath == null) - { - fullPath = ""; - } - fullPath = fullPath.Replace("\\", "/"); - - if (fullPath == BaseFullPath) { - return new UnityPath - { - Value="" - }; - } - else if(fullPath.StartsWith(BaseFullPath + "/")) - { - return new UnityPath(fullPath.Substring(BaseFullPath.Length + 1)); - } - else - { - return default(UnityPath); - } - } - - public static bool IsUnderAssetFolder(string fullPath) - { - return fullPath.Replace("\\", "/").StartsWith(AssetFullPath); - } - #endregion - - [Obsolete("Use TraverseDir()")] - public IEnumerable TravserseDir() - { - return TraverseDir(); - } - - public IEnumerable TraverseDir() - { - if (IsDirectoryExists) - { - yield return this; - - foreach(var child in ChildDirs) - { - foreach(var x in child.TraverseDir()) - { - yield return x; - } - } - } - } - - public IEnumerable ChildDirs - { - get - { - foreach(var x in Directory.GetDirectories(FullPath)) - { - yield return UnityPath.FromFullpath(x); - } - } - } - - public IEnumerable ChildFiles - { - get - { - foreach (var x in Directory.GetFiles(FullPath)) - { - yield return UnityPath.FromFullpath(x); - } - } - } - -#if UNITY_EDITOR - public T GetImporter() where T : AssetImporter - { - return AssetImporter.GetAtPath(Value) as T; - } - - public static UnityPath FromAsset(UnityEngine.Object asset) - { - return new UnityPath(AssetDatabase.GetAssetPath(asset)); - } - - public void ImportAsset() - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - AssetDatabase.ImportAsset(Value); - } - - public void EnsureFolder() - { - if (IsNull) - { - throw new NotImplementedException(); - } - - if (HasParent) - { - Parent.EnsureFolder(); - } - - if (!IsDirectoryExists) - { - var parent = Parent; - // ensure parent - parent.ImportAsset(); - // create - AssetDatabase.CreateFolder( - parent.Value, - Path.GetFileName(Value) - ); - ImportAsset(); - } - } - - public UnityEngine.Object[] GetSubAssets() - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - - return AssetDatabase.LoadAllAssetsAtPath(Value); - } - - public void CreateAsset(UnityEngine.Object o) - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - - AssetDatabase.CreateAsset(o, Value); - } - - public void AddObjectToAsset(UnityEngine.Object o) - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - - AssetDatabase.AddObjectToAsset(o, Value); - } - - public T LoadAsset() where T : UnityEngine.Object - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - - return AssetDatabase.LoadAssetAtPath(Value); - } - - public UnityPath GenerateUniqueAssetPath() - { - if (!IsUnderAssetsFolder) - { - throw new NotImplementedException(); - } - - return new UnityPath(AssetDatabase.GenerateUniqueAssetPath(Value)); - } - #endif - } -} diff --git a/Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs.meta b/Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs.meta deleted file mode 100644 index f64923d8b..000000000 --- a/Assets/UniGLTF/Runtime/MeshUtility/UnityPath.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 7b7af908694806c469d62ce0b5b2f06a -timeCreated: 1532326996 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs index 95ca70292..72aca7a9b 100644 --- a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs +++ b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs @@ -1,9 +1,9 @@ using NUnit.Framework; using System.IO; using UniGLTF; +using UniGLTF.MeshUtility; using UniJSON; using UnityEngine; -using MeshUtility; using System; using VRMShaders; diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index b8c3e27e6..a853981bd 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using UniGLTF; +using UniGLTF.MeshUtility; using UnityEngine; using VRMShaders; @@ -76,7 +77,7 @@ namespace VRM .Distinct() .ToArray(); - var copyMesh = MeshUtility.MeshExtensions.Copy(mesh, copyBlendShape: false); + var copyMesh = mesh.Copy(copyBlendShape: false); // 使われている BlendShape だけをコピーする foreach (var i in usedBlendshapeIndexArray) { diff --git a/Assets/VRM/Editor/Format/VRMExporterWizard.cs b/Assets/VRM/Editor/Format/VRMExporterWizard.cs index 768191a32..f90ca0173 100644 --- a/Assets/VRM/Editor/Format/VRMExporterWizard.cs +++ b/Assets/VRM/Editor/Format/VRMExporterWizard.cs @@ -5,6 +5,7 @@ using UnityEngine; using UniGLTF; using UniGLTF.M17N; using System.IO; +using UniGLTF.MeshUtility; namespace VRM { @@ -252,7 +253,7 @@ namespace VRM // // GUI // - _tab = MeshUtility.TabBar.OnGUI(_tab); + _tab = TabBar.OnGUI(_tab); foreach (var meshInfo in m_meshes.Meshes) { switch (meshInfo.VertexColor) diff --git a/Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs b/Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs index 249731c4c..6c8545af8 100644 --- a/Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs +++ b/Assets/VRM/Editor/Meta/VRMMetaObjectEditor.cs @@ -273,7 +273,7 @@ namespace VRM break; } - var assetPath = MeshUtility.UnityPath.FromFullpath(dst); + var assetPath = UnityPath.FromFullpath(dst); EditorApplication.delayCall += () => { assetPath.ImportAsset(); diff --git a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs index 6795a3a55..6c4f8e532 100644 --- a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs +++ b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorEditor.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using UniGLTF; +using UniGLTF.MeshUtility; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; @@ -44,7 +45,7 @@ namespace VRM //} - public static List Integrate(GameObject prefab) + public static List Integrate(GameObject prefab) { Undo.RecordObject(prefab, "Mesh Integration"); var instance = SkinnedMeshUtility.InstantiatePrefab(prefab); diff --git a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs index f931b281e..03f67b694 100644 --- a/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs +++ b/Assets/VRM/Editor/SkinnedMeshUtility/MeshIntegratorWizard.cs @@ -4,7 +4,7 @@ using UnityEngine; using System.Linq; using System; using System.Collections.Generic; - +using UniGLTF.MeshUtility; namespace VRM { @@ -58,7 +58,7 @@ namespace VRM MaterialList[] m_duplicateMaterials; [Header("Result")] - public MeshUtility.MeshIntegrationResult[] integrationResults; + public MeshIntegrationResult[] integrationResults; [MenuItem(MENU_KEY)] static void CreateWizard() @@ -124,7 +124,7 @@ namespace VRM return; } - m_uniqueMaterials = MeshUtility.MeshIntegratorUtility.EnumerateSkinnedMeshRenderer(m_root.transform, false) + m_uniqueMaterials = MeshIntegratorUtility.EnumerateSkinnedMeshRenderer(m_root.transform, false) .SelectMany(x => x.sharedMaterials) .Distinct() .ToArray(); diff --git a/Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs b/Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs index c4b9ecac8..9c2576196 100644 --- a/Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs +++ b/Assets/VRM/Editor/SpringBone/VRMSpringBoneColliderGroupEditor.cs @@ -1,5 +1,4 @@ using System.Linq; -using MeshUtility; using UniGLTF; using UnityEditor; using UnityEngine; diff --git a/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs index 78b2b10cd..d326b9959 100644 --- a/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs +++ b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using UniGLTF; +using UniGLTF.MeshUtility; using UnityEngine; @@ -215,7 +216,7 @@ namespace VRM setVisibility(renderer, false, true); // 削除対象のボーンに対するウェイトを保持する三角形を除外して、一人称用のモデルを複製する - var headlessMesh = MeshUtility.BoneMeshEraser.CreateErasedMesh(renderer.sharedMesh, eraseBones); + var headlessMesh = BoneMeshEraser.CreateErasedMesh(renderer.sharedMesh, eraseBones); if (headlessMesh.triangles.Length == 0) { // 一人称用のmeshには描画すべき部分が無い(全部削除された) diff --git a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs index 3b5891824..8d9154692 100644 --- a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs +++ b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMBoneNormalizer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using UniGLTF.MeshUtility; using UniHumanoid; using UnityEngine; @@ -66,7 +67,7 @@ namespace VRM // // 正規化されたヒエラルキーを作る // - var (normalized, bMap) = MeshUtility.BoneNormalizer.Execute(go, (_src, dst, boneMap) => + var (normalized, bMap) = BoneNormalizer.Execute(go, (_src, dst, boneMap) => { var src = _src.GetComponent(); diff --git a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs index 1dbbc7ea1..29a0fb5af 100644 --- a/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs +++ b/Assets/VRM/Runtime/SkinnedMeshUtility/VRMMeshIntegratorUtility.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using UniGLTF; +using UniGLTF.MeshUtility; using UnityEngine; namespace VRM @@ -38,17 +39,17 @@ namespace VRM return true; } - public static List Integrate(GameObject root, List blendshapeClips) + public static List Integrate(GameObject root, List blendshapeClips) { - var result = new List(); + var result = new List(); - var withoutBlendShape = MeshUtility.MeshIntegratorUtility.Integrate(root, onlyBlendShapeRenderers: false); + var withoutBlendShape = MeshIntegratorUtility.Integrate(root, onlyBlendShapeRenderers: false); if (withoutBlendShape.IntegratedRenderer != null) { result.Add(withoutBlendShape); } - var onlyBlendShape = MeshUtility.MeshIntegratorUtility.Integrate(root, onlyBlendShapeRenderers: true); + var onlyBlendShape = MeshIntegratorUtility.Integrate(root, onlyBlendShapeRenderers: true); if (onlyBlendShape.IntegratedRenderer != null) { result.Add(onlyBlendShape); @@ -58,7 +59,7 @@ namespace VRM return result; } - private static void FollowBlendshapeRendererChange(List clips, MeshUtility.MeshIntegrationResult result, GameObject root) + private static void FollowBlendshapeRendererChange(List clips, MeshIntegrationResult result, GameObject root) { if (clips == null || result == null || result.IntegratedRenderer == null || root == null) return; diff --git a/Assets/VRM/Tests/MeshTests.cs b/Assets/VRM/Tests/MeshTests.cs index 6be712b09..ff95e7972 100644 --- a/Assets/VRM/Tests/MeshTests.cs +++ b/Assets/VRM/Tests/MeshTests.cs @@ -1,5 +1,6 @@ using NUnit.Framework; using UnityEngine; +using UniGLTF.MeshUtility; using System.Linq; namespace VRM @@ -55,7 +56,7 @@ namespace VRM var src = new Mesh(); src.AddBlendShapeFrame("blendShape", 100.0f, null, null, null); - var dst = MeshUtility.MeshExtensions.Copy(src, true); + var dst = src.Copy(true); MeshEquals(src, dst); } diff --git a/Assets/VRM/Tests/NormalizeTests.cs b/Assets/VRM/Tests/NormalizeTests.cs index 1126b647a..ea8bd0e42 100644 --- a/Assets/VRM/Tests/NormalizeTests.cs +++ b/Assets/VRM/Tests/NormalizeTests.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using UniGLTF.MeshUtility; using UnityEngine; namespace VRM @@ -58,7 +59,7 @@ namespace VRM map.Add(null, new GameObject("null")); // map.Add(new GameObject("c"), null); // ありえないので Exception にしてある var boneWeights = map.CreateBoneWeight(64).ToArray(); - var newBoneWeight = MeshUtility.BoneNormalizer.MapBoneWeight(boneWeights, map.Map, + var newBoneWeight = BoneNormalizer.MapBoneWeight(boneWeights, map.Map, map.SrcBones.ToArray(), map.DstBones.ToArray()); // 正常系 @@ -74,7 +75,7 @@ namespace VRM map.Add(null, new GameObject("null")); // map.Add(new GameObject("c"), null); // ありえないので Exception にしてある var boneWeights = map.CreateBoneWeight(64).ToArray(); - var newBoneWeight = MeshUtility.BoneNormalizer.MapBoneWeight(boneWeights, map.Map, + var newBoneWeight = BoneNormalizer.MapBoneWeight(boneWeights, map.Map, map.SrcBones.ToArray(), map.DstBones.ToArray()); // 4 つめが 0 になる diff --git a/Assets/VRM10/Editor/Components/Expression/ExpressionEditorBase.cs b/Assets/VRM10/Editor/Components/Expression/ExpressionEditorBase.cs index 968c0bfdf..bd1f34bb9 100644 --- a/Assets/VRM10/Editor/Components/Expression/ExpressionEditorBase.cs +++ b/Assets/VRM10/Editor/Components/Expression/ExpressionEditorBase.cs @@ -1,5 +1,4 @@ -using MeshUtility; -using UnityEditor; +using UnityEditor; using UnityEngine; namespace UniVRM10 diff --git a/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs b/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs index 33a620467..1e2fad39a 100644 --- a/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs +++ b/Assets/VRM10/Editor/Components/Expression/VRM10ExpressionEditor.cs @@ -1,6 +1,6 @@ using System; using System.IO; -using MeshUtility; +using UniGLTF; using UnityEditor; using UnityEngine; diff --git a/Assets/VRM10/Editor/EditorUnityBuilder.cs b/Assets/VRM10/Editor/EditorUnityBuilder.cs deleted file mode 100644 index 8d7413577..000000000 --- a/Assets/VRM10/Editor/EditorUnityBuilder.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using UnityEngine; -using System.Linq; -using MeshUtility; -using VrmLib; - -namespace UniVRM10 -{ - public static class EditorUnityBuilder - { - // static public ModelAsset ToUnityAsset(VrmLib.Model model, string assetPath, IExternalUnityObject scriptedImporter) - // { - // var modelAsset = new ModelAsset(); - // CreateTextureAsset(model, modelAsset, scriptedImporter); - // CreateMaterialAsset(model, modelAsset, scriptedImporter); - // CreateMeshAsset(model, modelAsset); - - // // node - // RuntimeUnityBuilder.CreateNodes(model.Root, null, modelAsset.Map.Nodes); - // modelAsset.Root = modelAsset.Map.Nodes[model.Root]; - - // // renderer - // var map = modelAsset.Map; - // foreach (var (node, go) in map.Nodes) - // { - // if (node.MeshGroup is null) - // { - // continue; - // } - - // if (node.MeshGroup.Meshes.Count > 1) - // { - // throw new NotImplementedException("invalid isolated vertexbuffer"); - // } - - // var renderer = RuntimeUnityBuilder.CreateRenderer(node, go, map); - // map.Renderers.Add(node, renderer); - // modelAsset.Renderers.Add(renderer); - // } - - // if (model.Vrm != null) - // { - // // humanoid - // var humanoid = modelAsset.Root.AddComponent(); - // humanoid.AssignBones(modelAsset.Map.Nodes.Select(x => (x.Key.HumanoidBone.GetValueOrDefault().ToUnity(), x.Value.transform))); - // modelAsset.HumanoidAvatar = humanoid.CreateAvatar(); - // modelAsset.HumanoidAvatar.name = "VRM"; - - // var animator = modelAsset.Root.AddComponent(); - // animator.avatar = modelAsset.HumanoidAvatar; - // } - - // return modelAsset; - // } - - // static private void CreateTextureAsset(VrmLib.Model model, ModelAsset modelAsset, IExternalUnityObject scriptedImporter) - // { - // var externalObjects = scriptedImporter.GetExternalUnityObjects(); - - // // textures - // for (int i = 0; i < model.Textures.Count; ++i) - // { - // if (model.Textures[i] is VrmLib.ImageTexture imageTexture) - // { - // if (string.IsNullOrEmpty(model.Textures[i].Name)) - // { - // model.Textures[i].Name = string.Format("{0}_img{1}", model.Root.Name, i); - // } - // if (externalObjects.ContainsKey(model.Textures[i].Name)) - // { - // modelAsset.Map.Textures.Add(imageTexture, externalObjects[model.Textures[i].Name]); - // modelAsset.Textures.Add(externalObjects[model.Textures[i].Name]); - // } - // else - // { - // var name = !string.IsNullOrEmpty(imageTexture.Name) - // ? imageTexture.Name - // : string.Format("{0}_img{1}", model.Root.Name, i); - - // var texture = RuntimeUnityBuilder.CreateTexture(imageTexture); - // texture.name = name; - - // modelAsset.Map.Textures.Add(imageTexture, texture); - // modelAsset.Textures.Add(texture); - // } - // } - // else - // { - // Debug.LogWarning($"{i} not ImageTexture"); - // } - // } - // } - - - // static private void CreateMaterialAsset(VrmLib.Model model, ModelAsset modelAsset, IExternalUnityObject scriptedImporter) - // { - // var externalObjects = scriptedImporter.GetExternalUnityObjects(); - - // foreach (var src in model.Materials) - // { - // if (externalObjects.ContainsKey(src.Name)) - // { - // modelAsset.Map.Materials.Add(src, externalObjects[src.Name]); - // modelAsset.Materials.Add(externalObjects[src.Name]); - // } - // else - // { - // // TODO: material has VertexColor - // var material = RuntimeUnityMaterialBuilder.CreateMaterialAsset(src, hasVertexColor: false, modelAsset.Map.Textures); - // material.name = src.Name; - // modelAsset.Map.Materials.Add(src, material); - // modelAsset.Materials.Add(material); - // } - // } - // } - - // static private void CreateMeshAsset(VrmLib.Model model, ModelAsset modelAsset) - // { - // for (int i = 0; i < model.MeshGroups.Count; ++i) - // { - // var src = model.MeshGroups[i]; - // if (src.Meshes.Count == 1) - // { - // // submesh 方式 - // var mesh = new UnityEngine.Mesh(); - // mesh.name = src.Name; - // mesh.LoadMesh(src.Meshes[0], src.Skin); - // modelAsset.Map.Meshes.Add(src, mesh); - // modelAsset.Meshes.Add(mesh); - // } - // else - // { - // // 頂点バッファの連結が必用 - // throw new NotImplementedException(); - // } - // } - // } - } -} diff --git a/Assets/VRM10/Editor/EditorUnityBuilder.cs.meta b/Assets/VRM10/Editor/EditorUnityBuilder.cs.meta deleted file mode 100644 index 643e6fb40..000000000 --- a/Assets/VRM10/Editor/EditorUnityBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b3f83007d3c2144787097da4e3b92af -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterEditorGUI.cs b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterEditorGUI.cs index fe4473b61..49e7a2bd1 100644 --- a/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterEditorGUI.cs +++ b/Assets/VRM10/Editor/ScriptedImporter/VrmScriptedImporterEditorGUI.cs @@ -2,6 +2,7 @@ using UnityEngine; using UniGLTF; using System.IO; +using UniGLTF.MeshUtility; #if UNITY_2020_2_OR_NEWER using UnityEditor.AssetImporters; #else @@ -57,7 +58,7 @@ namespace UniVRM10 EditorGUILayout.HelpBox(m_message, MessageType.Error); } - s_currentTab = MeshUtility.TabBar.OnGUI(s_currentTab); + s_currentTab = TabBar.OnGUI(s_currentTab); GUILayout.Space(10); switch (s_currentTab) diff --git a/Assets/VRM10/Editor/Vrm10ExportDialog.cs b/Assets/VRM10/Editor/Vrm10ExportDialog.cs index c5af2a6e9..9818a4a86 100644 --- a/Assets/VRM10/Editor/Vrm10ExportDialog.cs +++ b/Assets/VRM10/Editor/Vrm10ExportDialog.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using UniGLTF; using UniGLTF.M17N; +using UniGLTF.MeshUtility; using UnityEditor; using UnityEngine; using VrmLib; @@ -235,7 +236,7 @@ namespace UniVRM10 } // tabbar - _tab = MeshUtility.TabBar.OnGUI(_tab); + _tab = TabBar.OnGUI(_tab); switch (_tab) { case Tabs.Meta: diff --git a/Assets/VRM10/Runtime/Components/Expression/VRM10Expression.cs b/Assets/VRM10/Runtime/Components/Expression/VRM10Expression.cs index a49eda8cd..135e7e945 100644 --- a/Assets/VRM10/Runtime/Components/Expression/VRM10Expression.cs +++ b/Assets/VRM10/Runtime/Components/Expression/VRM10Expression.cs @@ -1,7 +1,6 @@ -using MeshUtility; +using UniGLTF; using UnityEngine; - namespace UniVRM10 { [CreateAssetMenu(menuName = "VRM10/Expression")] diff --git a/Assets/VRM10/Runtime/Components/Expression/VRM10ExpressionAvatar.cs b/Assets/VRM10/Runtime/Components/Expression/VRM10ExpressionAvatar.cs index 58fbbd0fc..0a79a1c91 100644 --- a/Assets/VRM10/Runtime/Components/Expression/VRM10ExpressionAvatar.cs +++ b/Assets/VRM10/Runtime/Components/Expression/VRM10ExpressionAvatar.cs @@ -3,7 +3,7 @@ using System.Linq; using System; using System.Collections.Generic; using System.IO; -using MeshUtility; +using UniGLTF; #if UNITY_EDITOR using UnityEditor; #endif diff --git a/Assets/VRM10/Runtime/Components/Meta/VRM10MetaObject.cs b/Assets/VRM10/Runtime/Components/Meta/VRM10MetaObject.cs index e6b0f9037..d83987185 100644 --- a/Assets/VRM10/Runtime/Components/Meta/VRM10MetaObject.cs +++ b/Assets/VRM10/Runtime/Components/Meta/VRM10MetaObject.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using MeshUtility; using UniGLTF; using UnityEngine; using VRMShaders; diff --git a/Assets/VRM10/Runtime/Components/VRM10ControllerFirstPerson.cs b/Assets/VRM10/Runtime/Components/VRM10ControllerFirstPerson.cs index 780f049c4..c6f5e8c18 100644 --- a/Assets/VRM10/Runtime/Components/VRM10ControllerFirstPerson.cs +++ b/Assets/VRM10/Runtime/Components/VRM10ControllerFirstPerson.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using MeshUtility; +using UniGLTF.MeshUtility; using UnityEngine; namespace UniVRM10 diff --git a/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs b/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs index 4248354b6..7787a22c7 100644 --- a/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs +++ b/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using MeshUtility; using UnityEngine; using VrmLib; @@ -31,10 +30,10 @@ namespace UniVRM10 // humanoid { - var humanoid = root.GetComponent(); + var humanoid = root.GetComponent(); if (humanoid is null) { - humanoid = root.AddComponent(); + humanoid = root.AddComponent(); humanoid.AssignBonesFromAnimator(); } diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index d818d0779..3eabde8a2 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -215,7 +215,7 @@ namespace UniVRM10 Root.name = "VRM1"; // humanoid - var humanoid = Root.AddComponent(); + var humanoid = Root.AddComponent(); humanoid.AssignBones(m_map.Nodes.Select(x => (ToUnity(x.Key.HumanoidBone.GetValueOrDefault()), x.Value.transform))); m_humanoid = humanoid.CreateAvatar(); m_humanoid.name = "humanoid"; From 2d53b155599f76644f1b08a2c7cd50b8f1f054f8 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 1 Jun 2021 18:24:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?MeshUtility.Humanoid=20=E3=82=92=20UniHuman?= =?UTF-8?q?oid.Humanoid=20=E3=81=AB=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor}/HumanoidEditor.cs | 2 +- .../Editor}/HumanoidEditor.cs.meta | 2 +- .../MeshUtility => UniHumanoid/Scripts}/Humanoid.cs | 2 +- .../Scripts}/Humanoid.cs.meta | 2 +- .../Scripts}/HumanoidLoader.cs | 12 +----------- .../Scripts}/HumanoidLoader.cs.meta | 2 +- Assets/VRM10/Runtime/IO/Model/ModelExporter.cs | 4 ++-- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 2 +- Assets/VRM10/Runtime/VRM10.asmdef | 8 ++++---- 9 files changed, 13 insertions(+), 23 deletions(-) rename Assets/UniGLTF/{Editor/MeshUtility => UniHumanoid/Editor}/HumanoidEditor.cs (99%) rename Assets/UniGLTF/{Editor/MeshUtility => UniHumanoid/Editor}/HumanoidEditor.cs.meta (83%) rename Assets/UniGLTF/{Runtime/MeshUtility => UniHumanoid/Scripts}/Humanoid.cs (99%) rename Assets/UniGLTF/{Runtime/MeshUtility => UniHumanoid/Scripts}/Humanoid.cs.meta (83%) rename Assets/UniGLTF/{Runtime/MeshUtility => UniHumanoid/Scripts}/HumanoidLoader.cs (83%) rename Assets/UniGLTF/{Runtime/MeshUtility => UniHumanoid/Scripts}/HumanoidLoader.cs.meta (83%) diff --git a/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs b/Assets/UniGLTF/UniHumanoid/Editor/HumanoidEditor.cs similarity index 99% rename from Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs rename to Assets/UniGLTF/UniHumanoid/Editor/HumanoidEditor.cs index a7f9a72c5..2870a989c 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs +++ b/Assets/UniGLTF/UniHumanoid/Editor/HumanoidEditor.cs @@ -6,7 +6,7 @@ using UnityEditor; using UnityEngine; using System; -namespace UniGLTF.MeshUtility +namespace UniHumanoid { [CustomEditor(typeof(Humanoid))] public class HumanoidEditor : Editor diff --git a/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs.meta b/Assets/UniGLTF/UniHumanoid/Editor/HumanoidEditor.cs.meta similarity index 83% rename from Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs.meta rename to Assets/UniGLTF/UniHumanoid/Editor/HumanoidEditor.cs.meta index dffaaa186..4e871db08 100644 --- a/Assets/UniGLTF/Editor/MeshUtility/HumanoidEditor.cs.meta +++ b/Assets/UniGLTF/UniHumanoid/Editor/HumanoidEditor.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 57cc7b16eb4146c4ab5631f538e2489f +guid: ee7ea50401b78f64a950f59564838270 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs b/Assets/UniGLTF/UniHumanoid/Scripts/Humanoid.cs similarity index 99% rename from Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs rename to Assets/UniGLTF/UniHumanoid/Scripts/Humanoid.cs index abb9511a2..3e70358be 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs +++ b/Assets/UniGLTF/UniHumanoid/Scripts/Humanoid.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace UniGLTF.MeshUtility +namespace UniHumanoid { /// /// Bone割り当てを保持する。 diff --git a/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs.meta b/Assets/UniGLTF/UniHumanoid/Scripts/Humanoid.cs.meta similarity index 83% rename from Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs.meta rename to Assets/UniGLTF/UniHumanoid/Scripts/Humanoid.cs.meta index 53fc0f6d8..7ee846f25 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/Humanoid.cs.meta +++ b/Assets/UniGLTF/UniHumanoid/Scripts/Humanoid.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 889d98e41c0e8ff48bae50d1a729c2df +guid: 97a39af5b64ede64e86b92b5bf94a0e7 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs b/Assets/UniGLTF/UniHumanoid/Scripts/HumanoidLoader.cs similarity index 83% rename from Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs rename to Assets/UniGLTF/UniHumanoid/Scripts/HumanoidLoader.cs index 37b492d05..0254e9943 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs +++ b/Assets/UniGLTF/UniHumanoid/Scripts/HumanoidLoader.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -namespace UniGLTF.MeshUtility +namespace UniHumanoid { public static class HumanoidLoader { @@ -37,16 +37,6 @@ namespace UniGLTF.MeshUtility return AvatarBuilder.BuildHumanAvatar(root.gameObject, description); } - static SkeletonBone ToSkeletonBone(this Transform t) - { - var sb = new SkeletonBone(); - sb.name = t.name; - sb.position = t.localPosition; - sb.rotation = t.localRotation; - sb.scale = t.localScale; - return sb; - } - static HumanBodyBones TraitToHumanBone(string x) { return (HumanBodyBones)Enum.Parse(typeof(HumanBodyBones), x.Replace(" ", ""), true); diff --git a/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs.meta b/Assets/UniGLTF/UniHumanoid/Scripts/HumanoidLoader.cs.meta similarity index 83% rename from Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs.meta rename to Assets/UniGLTF/UniHumanoid/Scripts/HumanoidLoader.cs.meta index 029655567..9c7733565 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/HumanoidLoader.cs.meta +++ b/Assets/UniGLTF/UniHumanoid/Scripts/HumanoidLoader.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 12453a111483e4145852e3b057e065d9 +guid: 7b88d4c3436f9894ebc69f162d804cd4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs b/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs index 7787a22c7..603de0b15 100644 --- a/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs +++ b/Assets/VRM10/Runtime/IO/Model/ModelExporter.cs @@ -30,10 +30,10 @@ namespace UniVRM10 // humanoid { - var humanoid = root.GetComponent(); + var humanoid = root.GetComponent(); if (humanoid is null) { - humanoid = root.AddComponent(); + humanoid = root.AddComponent(); humanoid.AssignBonesFromAnimator(); } diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 3eabde8a2..2e860ddde 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -215,7 +215,7 @@ namespace UniVRM10 Root.name = "VRM1"; // humanoid - var humanoid = Root.AddComponent(); + var humanoid = Root.AddComponent(); humanoid.AssignBones(m_map.Nodes.Select(x => (ToUnity(x.Key.HumanoidBone.GetValueOrDefault()), x.Value.transform))); m_humanoid = humanoid.CreateAvatar(); m_humanoid.name = "humanoid"; diff --git a/Assets/VRM10/Runtime/VRM10.asmdef b/Assets/VRM10/Runtime/VRM10.asmdef index 05f8e8642..845518186 100644 --- a/Assets/VRM10/Runtime/VRM10.asmdef +++ b/Assets/VRM10/Runtime/VRM10.asmdef @@ -5,15 +5,15 @@ "MToon", "UniGLTF", "VRMShaders.GLTF.IO.Runtime", - "VRMShaders.VRM10.Format.Runtime" + "VRMShaders.VRM10.Format.Runtime", + "UniHumanoid" ], + "optionalUnityReferences": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false + "defineConstraints": [] } \ No newline at end of file