diff --git a/Assets/Main.unity b/Assets/Main.unity index f03312e..63dbe8f 100644 --- a/Assets/Main.unity +++ b/Assets/Main.unity @@ -171,6 +171,10 @@ PrefabInstance: propertyPath: m_Name value: New Metamesh objectReference: {fileID: 0} + - target: {fileID: 8980549144392899874, guid: f5e4c28eb4672d24ca584d5456a268e7, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -1029,15 +1033,15 @@ PrefabInstance: m_Modifications: - target: {fileID: -364223573239433514, guid: 666014e54879dc1479f1c29bea163dd4, type: 3} propertyPath: m_LocalPosition.x - value: 0.5482712 + value: 0 objectReference: {fileID: 0} - target: {fileID: -364223573239433514, guid: 666014e54879dc1479f1c29bea163dd4, type: 3} propertyPath: m_LocalPosition.y - value: 2.7895133 + value: 2.5 objectReference: {fileID: 0} - target: {fileID: -364223573239433514, guid: 666014e54879dc1479f1c29bea163dd4, type: 3} propertyPath: m_LocalPosition.z - value: 0.8493496 + value: 0 objectReference: {fileID: 0} - target: {fileID: -364223573239433514, guid: 666014e54879dc1479f1c29bea163dd4, type: 3} propertyPath: m_LocalRotation.w @@ -2112,7 +2116,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 2147483647 - m_IsActive: 1 + m_IsActive: 0 --- !u!23 &7499497021674395898 MeshRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/New GoldbergPolyhedron.gph.meta b/Assets/Resources/New GoldbergPolyhedron.gph.meta index df6b419..55e6167 100644 --- a/Assets/Resources/New GoldbergPolyhedron.gph.meta +++ b/Assets/Resources/New GoldbergPolyhedron.gph.meta @@ -9,8 +9,7 @@ ScriptedImporter: assetBundleVariant: script: {fileID: 11500000, guid: 80f1e0e8eacc4a945b07bba9e3065c99, type: 3} radius: 1 - subdivision: 4 - m: 1 - n: 0 + m: 16 + n: 1 generateLightmapUVs: 0 readWriteMeshes: 0 diff --git a/Assets/Resources/New Material.mat b/Assets/Resources/New Material.mat index f56f79c..efb4299 100644 --- a/Assets/Resources/New Material.mat +++ b/Assets/Resources/New Material.mat @@ -114,12 +114,12 @@ Material: - _GlossMapScale: 0 - _Glossiness: 0 - _GlossyReflections: 0 - - _Metallic: 0 + - _Metallic: 0.923 - _OcclusionStrength: 1 - _Parallax: 0.005 - _QueueOffset: 0 - _ReceiveShadows: 1 - - _Smoothness: 0.5 + - _Smoothness: 0.862 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 diff --git a/Assets/Scripts/.keep b/Assets/Scripts/.keep new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/Assets/Scripts/.keep @@ -0,0 +1 @@ + diff --git a/Assets/Scripts/Editor/IsoVector.cs b/Assets/Scripts/Editor/IsoVector.cs deleted file mode 100644 index 2ac0256..0000000 --- a/Assets/Scripts/Editor/IsoVector.cs +++ /dev/null @@ -1,67 +0,0 @@ -using UnityEngine; - -namespace Metamesh -{ - public class IsoVector - { - public int x; - public int y; - - public IsoVector(int x, int y) - { - this.x = x; - this.y = y; - } - - public IsoVector Clone() - { - return new IsoVector(x, y); - } - - public IsoVector Rotate60About(IsoVector other) - { - var x = this.x; - this.x = other.x + other.y - this.y; - this.y = x + this.y - other.x; - return this; - } - - public IsoVector RotateNeg60About(IsoVector other) - { - var x = this.x; - this.x = x + this.y - other.y; - this.y = other.x + other.y - x; - return this; - } - - public IsoVector Rotate120(int m, int n) - { - var x = this.x; - this.x = m - x - this.y; - this.y = n + x; - return this; - } - - public IsoVector RotateNeg120(int m, int n) - { - var x = this.x; - this.x = this.y - n; - this.y = m + n - x - this.y; - return this; - } - - public Vector3 ToCartesianOrigin(IsoVector origin, float isoGridSize) - { - var point = Vector3.zero; - point.x = origin.x + 2 * this.x * isoGridSize + this.y * isoGridSize; - point.y = origin.y + Mathf.Sqrt(3) * this.y * isoGridSize; - return point; - } - - public static IsoVector Zero() - { - return new IsoVector(0, 0); - } - } -} - diff --git a/Assets/Scripts/Editor/IsoVector.cs.meta b/Assets/Scripts/Editor/IsoVector.cs.meta deleted file mode 100644 index a110e22..0000000 --- a/Assets/Scripts/Editor/IsoVector.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 1b57a079742a0234e892f0128b45703f \ No newline at end of file diff --git a/Assets/UltraCombos.Metamesh.meta b/Assets/UltraCombos.Metamesh.meta new file mode 100644 index 0000000..221a772 --- /dev/null +++ b/Assets/UltraCombos.Metamesh.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2f059aeacfc85304fbbf6dc410c48f4e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor.meta b/Assets/UltraCombos.Metamesh/Editor.meta similarity index 77% rename from Assets/Scripts/Editor.meta rename to Assets/UltraCombos.Metamesh/Editor.meta index 83b0e45..0a9c0b5 100644 --- a/Assets/Scripts/Editor.meta +++ b/Assets/UltraCombos.Metamesh/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 97b79f4815ec35242a5fcedb042271b8 +guid: 188d2369623379f41a59c1c727bbd035 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/Editor/GeodesicMesh.cs b/Assets/UltraCombos.Metamesh/Editor/GeodesicMesh.cs similarity index 92% rename from Assets/Scripts/Editor/GeodesicMesh.cs rename to Assets/UltraCombos.Metamesh/Editor/GeodesicMesh.cs index d71a160..5f4026a 100644 --- a/Assets/Scripts/Editor/GeodesicMesh.cs +++ b/Assets/UltraCombos.Metamesh/Editor/GeodesicMesh.cs @@ -34,20 +34,20 @@ namespace Metamesh public PolyhedronData IDATA = new PolyhedronData( "icosahedron", "Regular", - new List - { - new Vector3(0, PHI, -1), - new Vector3(-PHI, 1, 0), - new Vector3(-1, 0, -PHI), - new Vector3(1, 0, -PHI), - new Vector3(PHI, 1, 0), - new Vector3(0, PHI, 1), - new Vector3(-1, 0, PHI), - new Vector3(-PHI, -1, 0), - new Vector3(0, -PHI, -1), - new Vector3(PHI, -1, 0), - new Vector3(1, 0, PHI), - new Vector3(0, -PHI, 1), + new Dictionary + { + {0,new Vector3(0, PHI, -1)}, + {1,new Vector3(-PHI, 1, 0)}, + {2,new Vector3(-1, 0, -PHI)}, + {3,new Vector3(1, 0, -PHI)}, + {4,new Vector3(PHI, 1, 0)}, + {5,new Vector3(0, PHI, 1)}, + {6,new Vector3(-1, 0, PHI)}, + {7,new Vector3(-PHI, -1, 0)}, + {8,new Vector3(0, -PHI, -1)}, + {9,new Vector3(PHI, -1, 0)}, + {10,new Vector3(1, 0, PHI)}, + {11,new Vector3(0, -PHI, 1)}, }, new List> { @@ -464,12 +464,10 @@ namespace Metamesh var tempVec = x * this.cartesian[i].x + y * this.cartesian[i].y + O; //mapped[i] = tempVec; idx = faceNb + "|" + this.vertices[i].x + "|" + this.vertices[i].y; - while (this.vecToidx[idx] >= geodesicData.vertex.Count) - geodesicData.vertex.Add(Vector3.zero); geodesicData.vertex[this.vecToidx[idx]] = tempVec; } } - + public PrimaryIsoTriangle Build(int m, int n) { var vertices = new List(); @@ -641,14 +639,14 @@ namespace Metamesh { public string name; public string category; - public List vertex; + public Dictionary vertex; public List> face; public List<(int, string, int, string)> edgematch; public PolyhedronData( string name, string category, - List vertex, + Dictionary vertex, List> face ) { @@ -669,7 +667,7 @@ namespace Metamesh private GeodesicData( string name, string category, - List vertex, + Dictionary vertex, List> face ) : base(name, category, vertex, face) { @@ -705,7 +703,7 @@ namespace Metamesh { primTri.vecToidx[temp[0]], primTri.vecToidx[temp[1]], primTri.vecToidx[temp[2]] }); } } - + private void MapOBOAtoDATA(int faceNb, PrimaryIsoTriangle primTri) { var fr = primTri.IDATA.edgematch[faceNb].Item1; @@ -728,7 +726,7 @@ namespace Metamesh { primTri.vecToidx[temp[0]], primTri.vecToidx[temp[1]], primTri.vecToidx[temp[2]] }); } } - + private void MapBAOAtoDATA(int faceNb, PrimaryIsoTriangle primTri) { var fr = primTri.IDATA.edgematch[faceNb].Item3; @@ -751,7 +749,7 @@ namespace Metamesh { primTri.vecToidx[temp[0]], primTri.vecToidx[temp[1]], primTri.vecToidx[temp[2]] }); } } - + private void OrderData(PrimaryIsoTriangle primTri) { var nearTo = new Dictionary>>(); @@ -775,30 +773,42 @@ namespace Metamesh nearTo[12].Add(new List { i, close[i][0] }); } } - + //var near = Enumerable.Range(0, 12).ToList(); var near = Enumerable.Range(0, 12).ToDictionary(i => i); var nearIndex = 12; for (var i = 0; i < 12; i++) { nearTo[i].Sort((a, b) => { return a[1].CompareTo(b[1]); }); - + foreach (var item in nearTo[i]) { near[item[0]] = nearIndex++; } } - + foreach (var item in nearTo[12]) { near[item[0]] = nearIndex++; } - + // TODO + /* this.vertex = this.vertex .Select((v, i) => (Vertex: v, SortKey: near[i])) .OrderBy(x => x.SortKey) .Select(x => x.Vertex) .ToList(); + */ + var values = this.vertex.Values + .Select((v, i) => (Vertex: v, SortKey: near[i])) + .OrderBy(x => x.SortKey) + .Select(x => x.Vertex) + .ToArray(); + var keys = this.vertex.Keys.ToArray(); + for (int i = 0; i < keys.Length; ++i) + { + this.vertex[keys[i]] = values[i]; + } for (var i = 0; i < this.face.Count; i++) { @@ -850,7 +860,7 @@ namespace Metamesh public PolyhedronData ToGoldbergPolyhedronData() { var goldbergPolyhedronData = - new PolyhedronData("GeoDual", "Goldberg", new List(), new List>()); + new PolyhedronData("GeoDual", "Goldberg", new Dictionary(), new List>()); goldbergPolyhedronData.name = "GD dual"; var verticesNb = this.vertex.Count; var map = new List[verticesNb]; @@ -901,17 +911,7 @@ namespace Metamesh cz += vertex.z; } - var tempVertex = new Vector3(cx / 3, cy / 3, cz / 3); - if (goldbergPolyhedronData.vertex.Count <= el) - { - if (goldbergPolyhedronData.face.Count != el) - Debug.Log($"goldbergPolyhedronData.face.Count != el: {goldbergPolyhedronData.face.Count} != {el}"); - goldbergPolyhedronData.vertex.Add(tempVertex); - } - else - { - goldbergPolyhedronData.vertex[el] = tempVertex; - } + goldbergPolyhedronData.vertex[el] = new Vector3(cx / 3, cy / 3, cz / 3); } ; @@ -926,20 +926,20 @@ namespace Metamesh var geodesicData = new GeodesicData( "Geodesic-m-n", "Geodesic", - new List() - { - new Vector3(0, PHI, -1), - new Vector3(-PHI, 1, 0), - new Vector3(-1, 0, -PHI), - new Vector3(1, 0, -PHI), - new Vector3(PHI, 1, 0), - new Vector3(0, PHI, 1), - new Vector3(-1, 0, PHI), - new Vector3(-PHI, -1, 0), - new Vector3(0, -PHI, -1), - new Vector3(PHI, -1, 0), - new Vector3(1, 0, PHI), - new Vector3(0, -PHI, 1), + new Dictionary() + { + {0, new Vector3(0, PHI, -1)}, + {1,new Vector3(-PHI, 1, 0)}, + {2,new Vector3(-1, 0, -PHI)}, + {3,new Vector3(1, 0, -PHI)}, + {4,new Vector3(PHI, 1, 0)}, + {5,new Vector3(0, PHI, 1)}, + {6,new Vector3(-1, 0, PHI)}, + {7,new Vector3(-PHI, -1, 0)}, + {8,new Vector3(0, -PHI, -1)}, + {9,new Vector3(PHI, -1, 0)}, + {10,new Vector3(1, 0, PHI)}, + {11,new Vector3(0, -PHI, 1)}, }, new List>() ); @@ -973,17 +973,12 @@ namespace Metamesh geodesicData.OrderData(primTri); var radius = 1f; - geodesicData.vertex = geodesicData.vertex.Select((el) => - { - var a = el.x; - var b = el.y; - var c = el.z; - var d = Mathf.Sqrt(a * a + b * b + c * c); - //el[0] *= radius / d; - //el[1] *= radius / d; - //el[2] *= radius / d; - return el * radius / d; - }).ToList(); + var keys = geodesicData.vertex.Keys.ToArray(); + foreach (var key in keys) + { + var el = geodesicData.vertex[key]; + geodesicData.vertex[key] = el * radius / el.magnitude; + } return geodesicData; } diff --git a/Assets/Scripts/Editor/GeodesicMesh.cs.meta b/Assets/UltraCombos.Metamesh/Editor/GeodesicMesh.cs.meta similarity index 100% rename from Assets/Scripts/Editor/GeodesicMesh.cs.meta rename to Assets/UltraCombos.Metamesh/Editor/GeodesicMesh.cs.meta diff --git a/Assets/Scripts/Editor/GoldbergBuilder.cs b/Assets/UltraCombos.Metamesh/Editor/GoldbergBuilder.cs similarity index 100% rename from Assets/Scripts/Editor/GoldbergBuilder.cs rename to Assets/UltraCombos.Metamesh/Editor/GoldbergBuilder.cs diff --git a/Assets/Scripts/Editor/GoldbergBuilder.cs.meta b/Assets/UltraCombos.Metamesh/Editor/GoldbergBuilder.cs.meta similarity index 100% rename from Assets/Scripts/Editor/GoldbergBuilder.cs.meta rename to Assets/UltraCombos.Metamesh/Editor/GoldbergBuilder.cs.meta diff --git a/Assets/Scripts/Editor/GoldbergPolyhedronImporter.cs b/Assets/UltraCombos.Metamesh/Editor/GoldbergPolyhedronImporter.cs similarity index 98% rename from Assets/Scripts/Editor/GoldbergPolyhedronImporter.cs rename to Assets/UltraCombos.Metamesh/Editor/GoldbergPolyhedronImporter.cs index c10abee..695bbaf 100644 --- a/Assets/Scripts/Editor/GoldbergPolyhedronImporter.cs +++ b/Assets/UltraCombos.Metamesh/Editor/GoldbergPolyhedronImporter.cs @@ -64,7 +64,7 @@ namespace Metamesh mesh.SetIndices(indices, MeshTopology.Triangles, 0); mesh.RecalculateBounds(); - mesh.RecalculateNormals(); + //mesh.RecalculateNormals(); if (generateLightmapUVs) Unwrapping.GenerateSecondaryUVSet(mesh); mesh.UploadMeshData(!readWriteMeshes); diff --git a/Assets/Scripts/Editor/GoldbergPolyhedronImporter.cs.meta b/Assets/UltraCombos.Metamesh/Editor/GoldbergPolyhedronImporter.cs.meta similarity index 100% rename from Assets/Scripts/Editor/GoldbergPolyhedronImporter.cs.meta rename to Assets/UltraCombos.Metamesh/Editor/GoldbergPolyhedronImporter.cs.meta diff --git a/Assets/UltraCombos.Metamesh/Editor/UltraCombos.Metamesh.Editor.asmdef b/Assets/UltraCombos.Metamesh/Editor/UltraCombos.Metamesh.Editor.asmdef new file mode 100644 index 0000000..113688c --- /dev/null +++ b/Assets/UltraCombos.Metamesh/Editor/UltraCombos.Metamesh.Editor.asmdef @@ -0,0 +1,18 @@ +{ + "name": "UltraCombos.Metamesh.Editor", + "rootNamespace": "UltraCombos.Metamesh", + "references": [ + "GUID:83ed26dc2742d6d45a9a2c56bf6c7ae8" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/UltraCombos.Metamesh/Editor/UltraCombos.Metamesh.Editor.asmdef.meta b/Assets/UltraCombos.Metamesh/Editor/UltraCombos.Metamesh.Editor.asmdef.meta new file mode 100644 index 0000000..d7e8003 --- /dev/null +++ b/Assets/UltraCombos.Metamesh/Editor/UltraCombos.Metamesh.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 175a0da299bd7024fab52ceee6ed562c +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UltraCombos.Metamesh/Runtime.meta b/Assets/UltraCombos.Metamesh/Runtime.meta new file mode 100644 index 0000000..ffba5ac --- /dev/null +++ b/Assets/UltraCombos.Metamesh/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21b017472defa2a41882f6b2709a230f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Extensions.cs b/Assets/UltraCombos.Metamesh/Runtime/Extensions.cs similarity index 100% rename from Assets/Scripts/Extensions.cs rename to Assets/UltraCombos.Metamesh/Runtime/Extensions.cs diff --git a/Assets/Scripts/Extensions.cs.meta b/Assets/UltraCombos.Metamesh/Runtime/Extensions.cs.meta similarity index 100% rename from Assets/Scripts/Extensions.cs.meta rename to Assets/UltraCombos.Metamesh/Runtime/Extensions.cs.meta diff --git a/Assets/UltraCombos.Metamesh/Runtime/UltraCombos.Metamesh.Runtime.asmdef b/Assets/UltraCombos.Metamesh/Runtime/UltraCombos.Metamesh.Runtime.asmdef new file mode 100644 index 0000000..41e40ca --- /dev/null +++ b/Assets/UltraCombos.Metamesh/Runtime/UltraCombos.Metamesh.Runtime.asmdef @@ -0,0 +1,14 @@ +{ + "name": "UltraCombos.Metamesh.Runtime", + "rootNamespace": "UltraCombos.Metamesh", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/UltraCombos.Metamesh/Runtime/UltraCombos.Metamesh.Runtime.asmdef.meta b/Assets/UltraCombos.Metamesh/Runtime/UltraCombos.Metamesh.Runtime.asmdef.meta new file mode 100644 index 0000000..02d333d --- /dev/null +++ b/Assets/UltraCombos.Metamesh/Runtime/UltraCombos.Metamesh.Runtime.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 83ed26dc2742d6d45a9a2c56bf6c7ae8 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: