From 5fe06786a4d1c7afd310b24737817c6027fabcf3 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Wed, 19 Apr 2017 02:30:24 +0300 Subject: [PATCH 01/24] update polygon and height mods to support buildings with holes remove edge subdivision (will be added as a modifier) remove terrain snapping & min_height usage (will be added as a part of height modifier) --- .../Components/FeatureBehaviour.cs | 8 ++ .../Unity/MeshGeneration/Data/MeshData.cs | 47 +++---- .../LayerVisualizers/VectorLayerVisualizer.cs | 128 ++++++------------ .../Modifiers/MeshModifiers/HeightModifier.cs | 72 +++++----- .../MeshModifiers/PolygonMeshModifier.cs | 86 +++++++++--- 5 files changed, 184 insertions(+), 157 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Components/FeatureBehaviour.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Components/FeatureBehaviour.cs index 62339fab2..c0c186e0c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Components/FeatureBehaviour.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Components/FeatureBehaviour.cs @@ -12,11 +12,19 @@ public class FeatureBehaviour : MonoBehaviour [Multiline(10)] public string DataString; + [Multiline(10)] + public string Points; + public void Init(VectorFeatureUnity feature) { Transform = transform; Data = feature; DataString = string.Join(" \r\n ", Data.Properties.Select(x => x.Key + " - " + x.Value.ToString()).ToArray()); + foreach (var item in feature.Points) + { + Points += string.Join(",", item.Select(x => x.x + "-" + x.z).ToArray()); + Points += "\r\n "; + } } } } \ No newline at end of file diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs index 4e2ec6b53..1f7bf0f93 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs @@ -1,25 +1,26 @@ -namespace Mapbox.Unity.MeshGeneration.Data -{ - using System.Collections.Generic; - using UnityEngine; - using Utils; - - public class MeshData - { - public Vector2 MercatorCenter { get; set; } - public RectD TileRect { get; set; } +namespace Mapbox.Unity.MeshGeneration.Data +{ + using System.Collections.Generic; + using TriangleNet.Geometry; + using UnityEngine; + using Utils; + + public class MeshData + { + public Vector2 MercatorCenter { get; set; } + public RectD TileRect { get; set; } public List Vertices { get; set; } public List Normals { get; set; } - public List> Triangles { get; set; } - public List> UV { get; set; } - - public MeshData() - { - Vertices = new List(); - Normals = new List(); - Triangles = new List>(); - UV = new List>(); - UV.Add(new List()); - } - } -} + public List> Triangles { get; set; } + public List> UV { get; set; } + + public MeshData() + { + Vertices = new List(); + Normals = new List(); + Triangles = new List>(); + UV = new List>(); + UV.Add(new List()); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs index aedacab18..b0d1d4d1f 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs @@ -88,103 +88,65 @@ public override void Create(VectorTileLayer layer, UnityTile tile) } } - private void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent) + private bool IsFeatureValid(VectorFeatureUnity feature) { - if (feature.Properties.ContainsKey("extrude") && !bool.Parse(feature.Properties["extrude"].ToString())) - return; + return false; - //we're not cutting out the holes yet - foreach (var geometry in feature.Points) - { - var meshData = new MeshData(); - meshData.TileRect = tile.Rect; + if (feature.Points.Count < 1) + return false; - if (geometry.Count <= 1) - continue; + return true; + } - //this will be improved in next version and will probably be replaced by filters - string styleSelectorKey = ""; - if (string.IsNullOrEmpty(_classificationKey)) - { - if (feature.Properties.ContainsKey("type")) - { - styleSelectorKey = feature.Properties["type"].ToString().ToLowerInvariant(); - } - else if (feature.Properties.ContainsKey("class")) - { - styleSelectorKey = feature.Properties["class"].ToString().ToLowerInvariant(); - } - } - else if (feature.Properties.ContainsKey(_classificationKey)) - { - if (feature.Properties.ContainsKey(_classificationKey)) - { - styleSelectorKey = feature.Properties[_classificationKey].ToString().ToLowerInvariant(); - } - } + private void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent) + { + if (!IsFeatureValid(feature)) + return; - //we'll run all visualizers on MeshData here - var list = geometry; - //.Select(x => Conversions.GeoToWorldPosition(x.Lat, x.Lng, tile.Rect.Center).ToVector3xz()).ToList(); + //this will be improved in next version and will probably be replaced by filters + var styleSelectorKey = FindSelectorKey(feature); - //long straight edges looks bad on bumpy terrain - if (_subdivideLongEdges) - { - var verts = new List(); - if (list.Count > 1) - { - for (int i = 0; i < list.Count - 1; i++) - { - verts.Add(list[i]); - var dist = Vector3.Distance(list[i], list[i + 1]); - var step = Math.Min(_maxEdgeSectionCount, dist / _preferredEdgeSectionLength); - if (step > 1) - { - var counter = 1; - while (counter < step) - { - var nv = Vector3.Lerp(list[i], list[i + 1], Mathf.Min(1, counter / step)); - verts.Add(nv); - counter++; - } - } - } - } - verts.Add(list.Last()); - list = verts; - } + var meshData = new MeshData(); + meshData.TileRect = tile.Rect; + + //and finally, running the modifier stack on the feature + var mod = Stacks.FirstOrDefault(x => x.Type.Contains(styleSelectorKey)); + GameObject go; + if (mod != null) + { + go = mod.Stack.Execute(tile, feature, meshData, parent, mod.Type); + } + else + { + if (_defaultStack != null) + go = _defaultStack.Execute(tile, feature, meshData, parent, _key); + } + //go.layer = LayerMask.NameToLayer(_key); + } - //adding terrain & building min_height to vertices - //we may move this into height modifier in the future - meshData.Vertices = list.Select(vertex => + private string FindSelectorKey(VectorFeatureUnity feature) + { + if (string.IsNullOrEmpty(_classificationKey)) + { + if (feature.Properties.ContainsKey("type")) { - var h = tile.QueryHeightData((float)((vertex.x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((vertex.z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); - vertex += new Vector3(0, h, 0); - - if (feature.Properties.ContainsKey("min_height")) - { - var min_height = Convert.ToSingle(feature.Properties["min_height"]); - vertex += new Vector3(0, min_height, 0); - } - - return vertex; - }).ToList(); - - //and finally, running the modifier stack on the feature - var mod = Stacks.FirstOrDefault(x => x.Type.Contains(styleSelectorKey)); - GameObject go; - if (mod != null) + return feature.Properties["type"].ToString().ToLowerInvariant(); + } + else if (feature.Properties.ContainsKey("class")) { - go = mod.Stack.Execute(tile, feature, meshData, parent, mod.Type); + return feature.Properties["class"].ToString().ToLowerInvariant(); } - else + } + else if (feature.Properties.ContainsKey(_classificationKey)) + { + if (feature.Properties.ContainsKey(_classificationKey)) { - if (_defaultStack != null) - go = _defaultStack.Execute(tile, feature, meshData, parent, _key); + return feature.Properties[_classificationKey].ToString().ToLowerInvariant(); } - //go.layer = LayerMask.NameToLayer(_key); } + + return ""; } } } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index 455f4f076..5b7689d9a 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -65,16 +65,42 @@ public override void Run(VectorFeatureUnity feature, MeshData md) var wallTri = new List(); var wallUv = new List(); - - for (int i = 1; i < count; i++) + for (int i = 0; i < feature.Points.Count; i++) { - v1 = md.Vertices[vertsStartCount + i - 1]; - v2 = md.Vertices[vertsStartCount + i]; + var length = feature.Points[i].Count; + for (int j = 1; j < length; j++) + { + v1 = md.Vertices[vertsStartCount + j - 1]; + v2 = md.Vertices[vertsStartCount + j]; + ind = md.Vertices.Count; + md.Vertices.Add(v1); + md.Vertices.Add(v2); + md.Vertices.Add(new Vector3(v1.x, md.Vertices[j].y - hf, v1.z)); + md.Vertices.Add(new Vector3(v2.x, md.Vertices[j].y - hf, v2.z)); + + d = (v2 - v1).magnitude; + + wallUv.Add(new Vector2(0, 0)); + wallUv.Add(new Vector2(d, 0)); + wallUv.Add(new Vector2(0, -hf)); + wallUv.Add(new Vector2(d, -hf)); + + wallTri.Add(ind); + wallTri.Add(ind + 2); + wallTri.Add(ind + 1); + + wallTri.Add(ind + 1); + wallTri.Add(ind + 2); + wallTri.Add(ind + 3); + } + + v1 = md.Vertices[vertsStartCount]; + v2 = md.Vertices[vertsStartCount + length - 1]; ind = md.Vertices.Count; md.Vertices.Add(v1); md.Vertices.Add(v2); - md.Vertices.Add(new Vector3(v1.x, md.Vertices[i].y - hf, v1.z)); - md.Vertices.Add(new Vector3(v2.x, md.Vertices[i].y - hf, v2.z)); + md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); + md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); d = (v2 - v1).magnitude; @@ -84,42 +110,18 @@ public override void Run(VectorFeatureUnity feature, MeshData md) wallUv.Add(new Vector2(d, -hf)); wallTri.Add(ind); - wallTri.Add(ind + 2); wallTri.Add(ind + 1); + wallTri.Add(ind + 2); wallTri.Add(ind + 1); - wallTri.Add(ind + 2); wallTri.Add(ind + 3); - } - - - v1 = md.Vertices[vertsStartCount]; - v2 = md.Vertices[vertsStartCount + count - 1]; - ind = md.Vertices.Count; - md.Vertices.Add(v1); - md.Vertices.Add(v2); - md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); - md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); - - d = (v2 - v1).magnitude; - - wallUv.Add(new Vector2(0, 0)); - wallUv.Add(new Vector2(d, 0)); - wallUv.Add(new Vector2(0, -hf)); - wallUv.Add(new Vector2(d, -hf)); - - wallTri.Add(ind); - wallTri.Add(ind + 1); - wallTri.Add(ind + 2); - - wallTri.Add(ind + 1); - wallTri.Add(ind + 3); - wallTri.Add(ind + 2); - + wallTri.Add(ind + 2); + vertsStartCount += length; + } md.Triangles.Add(wallTri); - md.UV[0].AddRange(wallUv); + } } } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index 42fc47544..6ce94dfbb 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -12,35 +12,89 @@ public class PolygonMeshModifier : MeshModifier { public override ModifierType Type { get { return ModifierType.Preprocess; } } + public bool IsClockwise(IList vertices) + { + double sum = 0.0; + for (int i = 0; i < vertices.Count; i++) + { + Vector3 v1 = vertices[i]; + Vector3 v2 = vertices[(i + 1) % vertices.Count]; // % is the modulo operator + sum += (v2.x - v1.x) * (v2.z + v1.z); + } + return sum > 0.0; + } + public override void Run(VectorFeatureUnity feature, MeshData md) { - if (md.Vertices.Distinct().Count() < 3) + if (feature.Points[0].Count() < 3) return; var data = new List(); - var _mesh = new TriangleNet.Mesh(); - var inp = new InputGeometry(md.Vertices.Count); - for (int i = 0; i < md.Vertices.Count; i++) + var polygon = new Polygon(); + Vertex firstVert = null; + Vertex nextVert = null; + Vertex currentVert = null; + + foreach (var sub in feature.Points) { - var v = md.Vertices[i]; - inp.AddPoint(v.x, v.z); - inp.AddSegment(i, (i + 1) % md.Vertices.Count); + if(IsClockwise(sub)) + { + nextVert = null; + var wist = new List(); + for (int i = 0; i < sub.Count; i++) + { + if (nextVert == null) + { + currentVert = new Vertex(sub[i].x, sub[i].z); + nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z); + } + else + { + currentVert = nextVert; + if (i == sub.Count - 1) + { + nextVert = firstVert; + } + else + { + nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z); + } + } + + if (i == 0) + firstVert = currentVert; + + wist.Add(sub[i]); + polygon.Add(currentVert); + polygon.Add(new Segment(currentVert, nextVert)); + } + } + else + { + var cont = new List(); + var wist = new List(); + for (int i = 0; i < sub.Count; i++) + { + wist.Add(sub[i]); + cont.Add(new Vertex(sub[i].x, sub[i].z)); + } + polygon.Add(new Contour(cont), true); + } } - _mesh.Behavior.Algorithm = TriangulationAlgorithm.SweepLine; - _mesh.Behavior.Quality = true; - _mesh.Triangulate(inp); - foreach (var tri in _mesh.Triangles) + var mesh = polygon.Triangulate(); + + foreach (var tri in mesh.Triangles) { - data.Add(tri.P1); - data.Add(tri.P0); - data.Add(tri.P2); + data.Add(tri.GetVertexID(0)); + data.Add(tri.GetVertexID(2)); + data.Add(tri.GetVertexID(1)); } - if (_mesh.Vertices.Count != md.Vertices.Count) + if (mesh.Vertices.Count != md.Vertices.Count) { md.Vertices.Clear(); - using (var sequenceEnum = _mesh.Vertices.GetEnumerator()) + using (var sequenceEnum = mesh.Vertices.GetEnumerator()) { while (sequenceEnum.MoveNext()) { From 9812657d0749fb12724a566550a857baa6bc63c9 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Wed, 19 Apr 2017 23:12:58 +0300 Subject: [PATCH 02/24] add tile to modifier run parameters add height query to polygon modifier for testing (will moved out) --- .../LayerVisualizers/VectorLayerVisualizer.cs | 12 +++++++- .../Modifiers/MergedModifierStack.cs | 4 ++- .../MeshGeneration/Modifiers/MeshModifier.cs | 2 +- .../MeshModifiers/ChamferModifier.cs | 2 +- .../Modifiers/MeshModifiers/HeightModifier.cs | 29 +++++++++---------- .../MeshModifiers/LineMeshModifier.cs | 2 +- .../MeshModifiers/PolygonMeshModifier.cs | 13 +++++++-- .../Modifiers/MeshModifiers/UvModifier.cs | 2 +- .../MeshGeneration/Modifiers/ModifierStack.cs | 2 +- .../Modifiers/ModifierStackBase.cs | 15 ++++++++-- 10 files changed, 55 insertions(+), 28 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs index b0d1d4d1f..1dcc2c4d7 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs @@ -109,7 +109,17 @@ private void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent var meshData = new MeshData(); meshData.TileRect = tile.Rect; - + + foreach (var sub in feature.Points) + { + for (int i = 0; i < sub.Count; i++) + { + //sub[i].Set(sub[i].x, tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)), sub[i].z); + var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); + sub[i] += new Vector3(0, h, 0); + } + } + //and finally, running the modifier stack on the feature var mod = Stacks.FirstOrDefault(x => x.Type.Contains(styleSelectorKey)); GameObject go; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs index d41131d46..97cefb885 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs @@ -22,6 +22,8 @@ public class MergedModifierStack : ModifierStackBase public override GameObject Execute(UnityTile tile, VectorFeatureUnity feature, MeshData meshData, GameObject parent = null, string type = "") { + base.Execute(tile, feature, meshData, parent, type); + if (!_cacheVertexCount.ContainsKey(tile)) { _cacheVertexCount.Add(tile, 0); @@ -32,7 +34,7 @@ public override GameObject Execute(UnityTile tile, VectorFeatureUnity feature, M _buildingCount[tile]++; foreach (MeshModifier mod in MeshModifiers.Where(x => x.Active)) { - mod.Run(feature, meshData); + mod.Run(feature, meshData, tile); } GameObject go = null; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifier.cs index 244b2e4e0..1b545d30d 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifier.cs @@ -12,7 +12,7 @@ public class MeshModifier : ModifierBase { public virtual ModifierType Type { get { return ModifierType.Preprocess; } } - public virtual void Run(VectorFeatureUnity feature, MeshData md) + public virtual void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ChamferModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ChamferModifier.cs index 5eda8f755..deac08c5a 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ChamferModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ChamferModifier.cs @@ -10,7 +10,7 @@ public class ChamferModifier : MeshModifier [SerializeField] private float _size; - public override void Run(VectorFeatureUnity feature, MeshData md) + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { if (md.Vertices.Count == 0) return; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index 5b7689d9a..455ad98b6 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -3,7 +3,7 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers using System.Collections.Generic; using UnityEngine; using Mapbox.Unity.MeshGeneration.Data; - + public enum ExtrusionType { Wall, @@ -21,31 +21,28 @@ public class HeightModifier : MeshModifier public override ModifierType Type { get { return ModifierType.Preprocess; } } - public override void Run(VectorFeatureUnity feature, MeshData md) + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { - if (md.Vertices.Count == 0) + if (md.Vertices.Count == 0 || feature == null || feature.Points.Count < 1) return; float hf = _height; - if (feature != null) + if (!_forceHeight) { - if (!_forceHeight) + if (feature.Properties.ContainsKey("height")) { - if (feature.Properties.ContainsKey("height")) + if (float.TryParse(feature.Properties["height"].ToString(), out hf)) { - if (float.TryParse(feature.Properties["height"].ToString(), out hf)) + if (feature.Properties.ContainsKey("min_height")) { - if (feature.Properties.ContainsKey("min_height")) - { - hf -= float.Parse(feature.Properties["min_height"].ToString()); - } + hf -= float.Parse(feature.Properties["min_height"].ToString()); } } - if (feature.Properties.ContainsKey("ele")) + } + if (feature.Properties.ContainsKey("ele")) + { + if (float.TryParse(feature.Properties["ele"].ToString(), out hf)) { - if (float.TryParse(feature.Properties["ele"].ToString(), out hf)) - { - } } } } @@ -93,7 +90,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md) wallTri.Add(ind + 2); wallTri.Add(ind + 3); } - + v1 = md.Vertices[vertsStartCount]; v2 = md.Vertices[vertsStartCount + length - 1]; ind = md.Vertices.Count; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs index 8b400ba0c..e8b88f290 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs @@ -14,7 +14,7 @@ public class LineMeshModifier : MeshModifier private float Width; public override ModifierType Type { get { return ModifierType.Preprocess; } } - public override void Run(VectorFeatureUnity feature, MeshData md) + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { if (md.Vertices.Count < 2) return; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index 6ce94dfbb..dc2d9087c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -24,7 +24,7 @@ public bool IsClockwise(IList vertices) return sum > 0.0; } - public override void Run(VectorFeatureUnity feature, MeshData md) + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { if (feature.Points[0].Count() < 3) return; @@ -37,7 +37,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md) foreach (var sub in feature.Points) { - if(IsClockwise(sub)) + if (IsClockwise(sub)) { nextVert = null; var wist = new List(); @@ -98,11 +98,18 @@ public override void Run(VectorFeatureUnity feature, MeshData md) { while (sequenceEnum.MoveNext()) { - md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, 0, (float)sequenceEnum.Current.y)); + var h = 0f; + if (tile != null) + { + h = tile.QueryHeightData((float)((sequenceEnum.Current.x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sequenceEnum.Current.y + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); + } + md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, h, (float)sequenceEnum.Current.y)); } } } md.Triangles.Add(data); + + } } } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/UvModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/UvModifier.cs index e7a734f07..c8ebb73db 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/UvModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/UvModifier.cs @@ -10,7 +10,7 @@ public class UvModifier : MeshModifier public override ModifierType Type { get { return ModifierType.Preprocess; } } public bool UseSatelliteRoof = false; - public override void Run(VectorFeatureUnity feature, MeshData md) + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { var uv = new List(); foreach (var c in md.Vertices) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs index ed25a0feb..e1e351cec 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs @@ -16,7 +16,7 @@ public override GameObject Execute(UnityTile tile, VectorFeatureUnity feature, M { foreach (MeshModifier mod in MeshModifiers.Where(x => x.Active)) { - mod.Run(feature, meshData); + mod.Run(feature, meshData, tile); } var go = CreateGameObject(meshData, parent); diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStackBase.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStackBase.cs index fac59d67d..a17dc1a05 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStackBase.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStackBase.cs @@ -2,11 +2,22 @@ using System.Collections; using Mapbox.Map; using Mapbox.Unity.MeshGeneration.Data; +using System.Collections.Generic; namespace Mapbox.Unity.MeshGeneration.Modifiers { - public abstract class ModifierStackBase : ScriptableObject + public class ModifierStackBase : ScriptableObject { - public abstract GameObject Execute(UnityTile tile, VectorFeatureUnity feature, MeshData meshData, GameObject parent = null, string type = ""); + [SerializeField] + private List _baseModifiers; + + public virtual GameObject Execute(UnityTile tile, VectorFeatureUnity feature, MeshData meshData, GameObject parent = null, string type = "") + { + foreach (var mod in _baseModifiers) + { + mod.Run(feature, meshData, tile); + } + return null; + } } } \ No newline at end of file From f74b0b9382caf0172d7ae7fbe63d6daca067d274 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Sat, 22 Apr 2017 01:58:00 +0300 Subject: [PATCH 03/24] add smooth line modifier add snap terrain modifier remove snaping to terrain and line subdivision from layer visualizer add flat tops option to height modifier --- .../LayerVisualizers/VectorLayerVisualizer.cs | 18 +- .../Modifiers/MeshModifiers/HeightModifier.cs | 27 ++- .../MeshModifiers/PolygonMeshModifier.cs | 8 +- .../MeshModifiers/SmoothLineModifier.cs | 42 ++++ .../MeshModifiers/SmoothLineModifier.cs.meta | 12 + .../MeshModifiers/SnapTerrainModifier.cs | 25 +++ .../MeshModifiers/SnapTerrainModifier.cs.meta | 12 + .../Assets/Mapbox/Examples/Drive/Drive.unity | 208 +----------------- .../Examples/Drive/DriveVisualization.asset | 1 - .../Drive/Imagery/DriveImageFactory.asset | 5 +- .../DriveBuildingHeight.asset | 3 +- .../DriveMergedBuildingStack.asset | 2 + .../SmoothLineModifier.asset | 16 ++ .../SmoothLineModifier.asset.meta | 8 + .../SnapTerrainModifier.asset | 14 ++ .../SnapTerrainModifier.asset.meta | 8 + .../Drive/Mesh/DriveMeshFactory.asset | 3 +- .../Examples/Drive/Terrain/DriveTerrain.asset | 10 +- 18 files changed, 189 insertions(+), 233 deletions(-) create mode 100644 sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs create mode 100644 sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs.meta create mode 100644 sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs create mode 100644 sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs.meta create mode 100644 sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset.meta create mode 100644 sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset.meta diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs index 1dcc2c4d7..8f7d9048c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs @@ -110,15 +110,15 @@ private void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent var meshData = new MeshData(); meshData.TileRect = tile.Rect; - foreach (var sub in feature.Points) - { - for (int i = 0; i < sub.Count; i++) - { - //sub[i].Set(sub[i].x, tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)), sub[i].z); - var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); - sub[i] += new Vector3(0, h, 0); - } - } + //foreach (var sub in feature.Points) + //{ + // for (int i = 0; i < sub.Count; i++) + // { + // //sub[i].Set(sub[i].x, tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)), sub[i].z); + // var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); + // sub[i] += new Vector3(0, h, 0); + // } + //} //and finally, running the modifier stack on the feature var mod = Stacks.FirstOrDefault(x => x.Type.Contains(styleSelectorKey)); diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index 455ad98b6..e44bb21e9 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -14,6 +14,8 @@ public enum ExtrusionType [CreateAssetMenu(menuName = "Mapbox/Modifiers/Height Modifier")] public class HeightModifier : MeshModifier { + [SerializeField] + private bool _flatTops; [SerializeField] private float _height; [SerializeField] @@ -47,11 +49,30 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile } } - - for (int i = 0; i < md.Vertices.Count; i++) + var max = md.Vertices[0].y; + var min = md.Vertices[0].y; + if (_flatTops) { - md.Vertices[i] = new Vector3(md.Vertices[i].x, md.Vertices[i].y + hf, md.Vertices[i].z); + for (int i = 0; i < md.Vertices.Count; i++) + { + if (md.Vertices[i].y > max) + max = md.Vertices[i].y; + else if (md.Vertices[i].y < min) + min = md.Vertices[i].y; + } + for (int i = 0; i < md.Vertices.Count; i++) + { + md.Vertices[i] = new Vector3(md.Vertices[i].x, max + hf, md.Vertices[i].z); + } + hf += max - min; } + else + { + for (int i = 0; i < md.Vertices.Count; i++) + { + md.Vertices[i] = new Vector3(md.Vertices[i].x, md.Vertices[i].y + hf, md.Vertices[i].z); + } + } var vertsStartCount = 0; var count = md.Vertices.Count; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index dc2d9087c..1ebb6b265 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -45,8 +45,8 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile { if (nextVert == null) { - currentVert = new Vertex(sub[i].x, sub[i].z); - nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z); + currentVert = new Vertex(sub[i].x, sub[i].z, sub[i].y); + nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z, sub[i].y); } else { @@ -57,7 +57,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile } else { - nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z); + nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z, sub[i + 1].y); } } @@ -76,7 +76,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile for (int i = 0; i < sub.Count; i++) { wist.Add(sub[i]); - cont.Add(new Vertex(sub[i].x, sub[i].z)); + cont.Add(new Vertex(sub[i].x, sub[i].z, sub[i].y)); } polygon.Add(new Contour(cont), true); } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs new file mode 100644 index 000000000..e83ca71b9 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using Mapbox.Unity.MeshGeneration.Data; + +namespace Mapbox.Unity.MeshGeneration.Modifiers +{ + [CreateAssetMenu(menuName = "Mapbox/Modifiers/Smooth Line Modifier")] + public class SmoothLineModifier : MeshModifier + { + public override ModifierType Type { get { return ModifierType.Preprocess; } } + + public int _maxEdgeSectionCount = 40; + public int _preferredEdgeSectionLength = 10; + + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) + { + for (int i = 0; i < feature.Points.Count; i++) + { + var nl = new List(); + for (int j = 1; j < feature.Points[i].Count; j++) + { + nl.Add(feature.Points[i][j - 1]); + var dist = Vector3.Distance(feature.Points[i][j - 1], feature.Points[i][j]); + var step = Math.Min(_maxEdgeSectionCount, dist / _preferredEdgeSectionLength); + if (step > 1) + { + var counter = 1; + while (counter < step) + { + var nv = Vector3.Lerp(feature.Points[i][j - 1], feature.Points[i][j], Mathf.Min(1, counter / step)); + nl.Add(nv); + counter++; + } + } + nl.Add(feature.Points[i][j]); + } + feature.Points[i] = nl; + } + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs.meta new file mode 100644 index 000000000..b73eecef0 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SmoothLineModifier.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9558f79dbf9b00d488e061a68f8394aa +timeCreated: 1492731089 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs new file mode 100644 index 000000000..b9b4a31be --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using Mapbox.Unity.MeshGeneration.Data; + +namespace Mapbox.Unity.MeshGeneration.Modifiers +{ + [CreateAssetMenu(menuName = "Mapbox/Modifiers/Snap Terrain Modifier")] + public class SnapTerrainModifier : MeshModifier + { + public override ModifierType Type { get { return ModifierType.Preprocess; } } + + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) + { + foreach (var sub in feature.Points) + { + for (int i = 0; i < sub.Count; i++) + { + var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); + sub[i] += new Vector3(0, h, 0); + } + } + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs.meta new file mode 100644 index 000000000..cca88cb75 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 40bee3110109c0848bb86c9b5c436039 +timeCreated: 1492732222 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity b/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity index 6b07653cd..e94077790 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity @@ -183,9 +183,9 @@ MonoBehaviour: MapVisualization: {fileID: 11400000, guid: 4f4961d6f3e45f84f99bda9cdc9dbb2b, type: 2} TileSize: 100 _snapYToZero: 1 - LatLng: 37.781169, -122.409955 + LatLng: 37.790908, -122.403361 Zoom: 16 - Range: {x: 3, y: 3, z: 3, w: 3} + Range: {x: 1, y: 1, z: 1, w: 1} --- !u!4 &199863781 Transform: m_ObjectHideFlags: 0 @@ -199,210 +199,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 ---- !u!1 &248560052 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 248560056} - - 33: {fileID: 248560055} - - 65: {fileID: 248560054} - - 23: {fileID: 248560053} - m_Layer: 0 - m_Name: Target - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!23 &248560053 -MeshRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 248560052} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: 50b7ba2da8847fc49b37ca6d7f1b4ea1, type: 2} - m_SubsetIndices: - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 1 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedWireframeHidden: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingOrder: 0 ---- !u!65 &248560054 -BoxCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 248560052} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!33 &248560055 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 248560052} - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &248560056 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 248560052} - m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} - m_LocalPosition: {x: -25.9, y: 20.4, z: -110} - m_LocalScale: {x: 11, y: 11, z: 11} - m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} - m_Children: [] - m_Father: {fileID: 761742983} - m_RootOrder: 1 ---- !u!1 &761742981 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 761742983} - - 114: {fileID: 761742982} - m_Layer: 0 - m_Name: DirectionHelper - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &761742982 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 761742981} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3d8534d45be3bd44f84c41bc08827496, type: 3} - m_Name: - m_EditorClassIdentifier: - Directions: {fileID: 11400000, guid: d370b4703777f8c48b26eead134f2edb, type: 2} - Waypoints: - - {fileID: 1553875871} - - {fileID: 248560056} ---- !u!4 &761742983 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 761742981} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_Children: - - {fileID: 1553875871} - - {fileID: 248560056} - m_Father: {fileID: 0} - m_RootOrder: 3 ---- !u!1 &1553875867 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 4 - m_Component: - - 4: {fileID: 1553875871} - - 33: {fileID: 1553875870} - - 65: {fileID: 1553875869} - - 23: {fileID: 1553875868} - m_Layer: 0 - m_Name: Start - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!23 &1553875868 -MeshRenderer: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1553875867} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: 7c708c0bb5591844e8a1e7bc6ba7b55e, type: 2} - m_SubsetIndices: - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 1 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedWireframeHidden: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingOrder: 0 ---- !u!65 &1553875869 -BoxCollider: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1553875867} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!33 &1553875870 -MeshFilter: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1553875867} - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &1553875871 -Transform: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1553875867} - m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} - m_LocalPosition: {x: 75.3, y: 20.4, z: 71.3} - m_LocalScale: {x: 11, y: 11, z: 11} - m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} - m_Children: [] - m_Father: {fileID: 761742983} - m_RootOrder: 0 --- !u!1 &1872744247 GameObject: m_ObjectHideFlags: 0 diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset b/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset index d3eb47f1a..0e2e27683 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset @@ -15,4 +15,3 @@ MonoBehaviour: - {fileID: 11400000, guid: 0bbb865e3ab501a4ba8ed8cf759b6d34, type: 2} - {fileID: 11400000, guid: 534ecf4b5a553dd47a0c07a4265efdd6, type: 2} - {fileID: 11400000, guid: 5be1766dc865f9b4f9549cb75a1551b0, type: 2} - - {fileID: 11400000, guid: d370b4703777f8c48b26eead134f2edb, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset index fec775533..e8a27964b 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset @@ -11,6 +11,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2b10536479dade041b6db9893fdf723a, type: 3} m_Name: DriveImageFactory m_EditorClassIdentifier: - _createImagery: 1 - _mapId: mapbox://styles/mapbox/dark-v9 + _mapIdType: 0 + _customMapId: + _mapId: mapbox://styles/mapbox/satellite-v9 _baseMaterial: {fileID: 2100000, guid: 06b583c58078c164eb45358a14a5c66b, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset index b06bf192e..13a8f659b 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset @@ -12,7 +12,6 @@ MonoBehaviour: m_Name: DriveBuildingHeight m_EditorClassIdentifier: Active: 1 + _flatTops: 1 _height: 0 _forceHeight: 0 - _closeEnd: 0 - _flatTop: 0 diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveMergedBuildingStack.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveMergedBuildingStack.asset index a153d6b9d..97f2835e7 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveMergedBuildingStack.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveMergedBuildingStack.asset @@ -11,7 +11,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ef7239c46ddb6ab469994291c9603c01, type: 3} m_Name: DriveMergedBuildingStack m_EditorClassIdentifier: + _baseModifiers: [] MeshModifiers: + - {fileID: 11400000, guid: 5d2129c4f45752d449951b9f6e8f5c3f, type: 2} - {fileID: 11400000, guid: 8d03f81530c3c1f4f9b1df48c9480748, type: 2} - {fileID: 11400000, guid: 43492f8eaa132d044995aecfc9c08b6e, type: 2} - {fileID: 11400000, guid: ead6d9ed3e6317b47a3719e7dfad3bcf, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset new file mode 100644 index 000000000..42369f76a --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9558f79dbf9b00d488e061a68f8394aa, type: 3} + m_Name: SmoothLineModifier + m_EditorClassIdentifier: + Active: 1 + _maxEdgeSectionCount: 40 + _preferredEdgeSectionLength: 10 diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset.meta new file mode 100644 index 000000000..f2f9ad587 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SmoothLineModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0247f2e2a5a28d2479bf753faa6a5020 +timeCreated: 1492731122 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset new file mode 100644 index 000000000..4cb7ad18a --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 40bee3110109c0848bb86c9b5c436039, type: 3} + m_Name: SnapTerrainModifier + m_EditorClassIdentifier: + Active: 1 diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset.meta new file mode 100644 index 000000000..ed27f0acc --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/SnapTerrainModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5d2129c4f45752d449951b9f6e8f5c3f +timeCreated: 1492732239 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset index 5dd5dba0f..50e6d5f62 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset @@ -13,5 +13,4 @@ MonoBehaviour: m_EditorClassIdentifier: _mapId: mapbox.mapbox-traffic-v1,mapbox.mapbox-streets-v7 Visualizers: - - {fileID: 11400000, guid: 3a02dddaa897fd444b76d6ed1339dab6, type: 2} - - {fileID: 11400000, guid: 960fc9b7bdbc4f24b860f10bdfd7c165, type: 2} + - {fileID: 11400000, guid: e71aac5125636534886a86af764815c9, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Terrain/DriveTerrain.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Terrain/DriveTerrain.asset index 6f2d2910b..edb5146d9 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Terrain/DriveTerrain.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Terrain/DriveTerrain.asset @@ -11,8 +11,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8338f26893d62c1439f387800a8e1c9a, type: 3} m_Name: DriveTerrain m_EditorClassIdentifier: - _createFlatBase: 0 - _createRealTerrain: 1 + _generationType: 0 + _baseMaterial: {fileID: 0} + _mapIdType: 0 + _customMapId: mapbox.terrain-rgb _mapId: mapbox.terrain-rgb - _material: {fileID: 2100000, guid: d59af6ef7d16a004eabbf169fe7d6995, type: 2} - sampleCount: 40 + _heightModifier: 1 + _sampleCount: 40 From 0502b757d350789e8485ed45312b704a18209b9c Mon Sep 17 00:00:00 2001 From: brnkhy Date: Sat, 22 Apr 2017 01:59:38 +0300 Subject: [PATCH 04/24] fix line mesh modifier for new mesh factory refactoring --- .../MeshModifiers/LineMeshModifier.cs | 121 +++++++++--------- 1 file changed, 64 insertions(+), 57 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs index e8b88f290..642d41d5a 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs @@ -16,74 +16,81 @@ public class LineMeshModifier : MeshModifier public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { - if (md.Vertices.Count < 2) + if (feature.Points.Count < 1) return; - var count = md.Vertices.Count; - var newVerticeList = new Vector3[count * 2]; - var uvList = new Vector2[count * 2]; - - Vector3 norm; - var lastUv = 0f; - var p1 = Vector3.zero; - var p2 = Vector3.zero; - var p3 = Vector3.zero; - for (int i = 1; i < count; i++) + foreach (var segment in feature.Points) { - p1 = md.Vertices[i - 1]; - p2 = md.Vertices[i]; - p3 = p2; - if (i + 1 < md.Vertices.Count) - p3 = md.Vertices[i + 1]; + var count = segment.Count; + var newVerticeList = new Vector3[count * 2]; + var uvList = new Vector2[count * 2]; - if (i == 1) + Vector3 norm; + var lastUv = 0f; + var p1 = Vector3.zero; + var p2 = Vector3.zero; + var p3 = Vector3.zero; + for (int i = 1; i < count; i++) { - norm = GetNormal(p1, p1, p2) * Width; //road width - newVerticeList[0] = (p1 + norm); - newVerticeList[count * 2 - 1] = (p1 - norm); - uvList[0] = new Vector2(0, 0); - uvList[count * 2 - 1] = new Vector2(1, 0); - } - var dist = Vector3.Distance(p1, p2); - lastUv += dist; - norm = GetNormal(p1, p2, p3) * Width; - newVerticeList[i] = (p2 + norm); - newVerticeList[2 * count - 1 - i] = (p2 - norm); + p1 = segment[i - 1]; + p2 = segment[i]; + p3 = p2; + if (i + 1 < segment.Count) + p3 = segment[i + 1]; - uvList[i] = new Vector2(0, lastUv); - uvList[2 * count - 1 - i] = new Vector2(1, lastUv); - } + if (i == 1) + { + norm = GetNormal(p1, p1, p2) * Width; //road width + newVerticeList[0] = (p1 + norm); + newVerticeList[count * 2 - 1] = (p1 - norm); + uvList[0] = new Vector2(0, 0); + uvList[count * 2 - 1] = new Vector2(1, 0); + } + var dist = Vector3.Distance(p1, p2); + lastUv += dist; + norm = GetNormal(p1, p2, p3) * Width; + newVerticeList[i] = (p2 + norm); + newVerticeList[2 * count - 1 - i] = (p2 - norm); - if (_mergeStartEnd) - { - //brnkhy -2 because first and last items are same - p1 = md.Vertices[count - 2]; - p2 = md.Vertices[0]; - p3 = md.Vertices[1]; + uvList[i] = new Vector2(0, lastUv); + uvList[2 * count - 1 - i] = new Vector2(1, lastUv); + } - norm = GetNormal(p1, p2, p3) * Width; - newVerticeList[count - 1] = p2 + norm; - newVerticeList[0] = p2 + norm; - newVerticeList[count] = p2 - norm; - newVerticeList[2 * count - 1] = p2 - norm; - } + //if (_mergeStartEnd) + //{ + // //brnkhy -2 because first and last items are same + // p1 = segment[count - 2]; + // p2 = segment[0]; + // p3 = segment[1]; - md.Vertices = newVerticeList.ToList(); - md.UV[0].AddRange(uvList); - var lineTri = new List(); - var n = md.Vertices.Count / 2; + // norm = GetNormal(p1, p2, p3) * Width; + // newVerticeList[count - 1] = p2 + norm; + // newVerticeList[0] = p2 + norm; + // newVerticeList[count] = p2 - norm; + // newVerticeList[2 * count - 1] = p2 - norm; + //} - for (int i = 0; i < n - 1; i++) - { - lineTri.Add(i); - lineTri.Add(i + 1); - lineTri.Add(2 * n - 1 - i); + var pcount = md.Vertices.Count; + md.Vertices.AddRange(newVerticeList); + md.UV[0].AddRange(uvList); + var lineTri = new List(); + var n = count; - lineTri.Add(i + 1); - lineTri.Add(2 * n - i - 2); - lineTri.Add(2 * n - i - 1); - } - md.Triangles.Add(lineTri); + for (int i = 0; i < n - 1; i++) + { + lineTri.Add(pcount + i); + lineTri.Add(pcount + i + 1); + lineTri.Add(pcount + 2 * n - 1 - i); + + lineTri.Add(pcount + i + 1); + lineTri.Add(pcount + 2 * n - i - 2); + lineTri.Add(pcount + 2 * n - i - 1); + } + + if (md.Triangles.Count < 1) + md.Triangles.Add(new List()); + md.Triangles[0].AddRange(lineTri); + } } private Vector3 GetNormal(Vector3 p1, Vector3 newPos, Vector3 p2) From e9e05e570c5fd58d6ebd65402db836d3a5bd77fb Mon Sep 17 00:00:00 2001 From: brnkhy Date: Sun, 23 Apr 2017 02:52:52 +0300 Subject: [PATCH 05/24] fix a height modifier bug where side wall triangulation was wrong and connected start and edge vertices --- .../Modifiers/MeshModifiers/HeightModifier.cs | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index e44bb21e9..8752ce024 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -86,14 +86,14 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile for (int i = 0; i < feature.Points.Count; i++) { var length = feature.Points[i].Count; - for (int j = 1; j < length; j++) + for (int j = 1; j < 2*length; j++) { v1 = md.Vertices[vertsStartCount + j - 1]; v2 = md.Vertices[vertsStartCount + j]; ind = md.Vertices.Count; md.Vertices.Add(v1); md.Vertices.Add(v2); - md.Vertices.Add(new Vector3(v1.x, md.Vertices[j].y - hf, v1.z)); + md.Vertices.Add(new Vector3(v1.x, md.Vertices[j - 1].y - hf, v1.z)); md.Vertices.Add(new Vector3(v2.x, md.Vertices[j].y - hf, v2.z)); d = (v2 - v1).magnitude; @@ -112,28 +112,28 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile wallTri.Add(ind + 3); } - v1 = md.Vertices[vertsStartCount]; - v2 = md.Vertices[vertsStartCount + length - 1]; - ind = md.Vertices.Count; - md.Vertices.Add(v1); - md.Vertices.Add(v2); - md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); - md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); + //v1 = md.Vertices[vertsStartCount]; + //v2 = md.Vertices[vertsStartCount + length - 1]; + //ind = md.Vertices.Count; + //md.Vertices.Add(v1); + //md.Vertices.Add(v2); + //md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); + //md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); - d = (v2 - v1).magnitude; + //d = (v2 - v1).magnitude; - wallUv.Add(new Vector2(0, 0)); - wallUv.Add(new Vector2(d, 0)); - wallUv.Add(new Vector2(0, -hf)); - wallUv.Add(new Vector2(d, -hf)); + //wallUv.Add(new Vector2(0, 0)); + //wallUv.Add(new Vector2(d, 0)); + //wallUv.Add(new Vector2(0, -hf)); + //wallUv.Add(new Vector2(d, -hf)); - wallTri.Add(ind); - wallTri.Add(ind + 1); - wallTri.Add(ind + 2); + //wallTri.Add(ind); + //wallTri.Add(ind + 1); + //wallTri.Add(ind + 2); - wallTri.Add(ind + 1); - wallTri.Add(ind + 3); - wallTri.Add(ind + 2); + //wallTri.Add(ind + 1); + //wallTri.Add(ind + 3); + //wallTri.Add(ind + 2); vertsStartCount += length; } From 4b1a879f9b727dfd023462bae57062046b1811bf Mon Sep 17 00:00:00 2001 From: brnkhy Date: Sun, 23 Apr 2017 03:08:52 +0300 Subject: [PATCH 06/24] fix a height modifier bug where it connects side walls of separate feature geometries --- .../MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index 8752ce024..d301d010c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -135,7 +135,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile //wallTri.Add(ind + 3); //wallTri.Add(ind + 2); - vertsStartCount += length; + vertsStartCount += 2*length; } md.Triangles.Add(wallTri); md.UV[0].AddRange(wallUv); From 3eb8b9e798bbe9f2e66ab004434909bea3ae36a0 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 25 Apr 2017 22:37:17 +0300 Subject: [PATCH 07/24] introduce edge list to mesh data containing outer edges of building/road polygons --- .../Unity/MeshGeneration/Data/MeshData.cs | 4 + .../Modifiers/MeshModifiers/HeightModifier.cs | 131 +++++++++++------- .../MeshModifiers/LineMeshModifier.cs | 23 +-- .../MeshModifiers/PolygonMeshModifier.cs | 9 ++ 4 files changed, 107 insertions(+), 60 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs index 1f7bf0f93..51b4d863f 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/MeshData.cs @@ -2,11 +2,14 @@ namespace Mapbox.Unity.MeshGeneration.Data { using System.Collections.Generic; using TriangleNet.Geometry; + using TriangleNet.Meshing; using UnityEngine; using Utils; public class MeshData { + public List Edges { get; set; } + public IMesh PolygonMesh { get; set; } public Vector2 MercatorCenter { get; set; } public RectD TileRect { get; set; } public List Vertices { get; set; } @@ -16,6 +19,7 @@ public class MeshData public MeshData() { + Edges = new List(); Vertices = new List(); Normals = new List(); Triangles = new List>(); diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index d301d010c..f74779c24 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -83,60 +83,87 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile var wallTri = new List(); var wallUv = new List(); - for (int i = 0; i < feature.Points.Count; i++) - { - var length = feature.Points[i].Count; - for (int j = 1; j < 2*length; j++) - { - v1 = md.Vertices[vertsStartCount + j - 1]; - v2 = md.Vertices[vertsStartCount + j]; - ind = md.Vertices.Count; - md.Vertices.Add(v1); - md.Vertices.Add(v2); - md.Vertices.Add(new Vector3(v1.x, md.Vertices[j - 1].y - hf, v1.z)); - md.Vertices.Add(new Vector3(v2.x, md.Vertices[j].y - hf, v2.z)); - - d = (v2 - v1).magnitude; - - wallUv.Add(new Vector2(0, 0)); - wallUv.Add(new Vector2(d, 0)); - wallUv.Add(new Vector2(0, -hf)); - wallUv.Add(new Vector2(d, -hf)); - - wallTri.Add(ind); - wallTri.Add(ind + 2); - wallTri.Add(ind + 1); - - wallTri.Add(ind + 1); - wallTri.Add(ind + 2); - wallTri.Add(ind + 3); - } - - //v1 = md.Vertices[vertsStartCount]; - //v2 = md.Vertices[vertsStartCount + length - 1]; - //ind = md.Vertices.Count; - //md.Vertices.Add(v1); - //md.Vertices.Add(v2); - //md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); - //md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); - - //d = (v2 - v1).magnitude; - //wallUv.Add(new Vector2(0, 0)); - //wallUv.Add(new Vector2(d, 0)); - //wallUv.Add(new Vector2(0, -hf)); - //wallUv.Add(new Vector2(d, -hf)); - - //wallTri.Add(ind); - //wallTri.Add(ind + 1); - //wallTri.Add(ind + 2); - - //wallTri.Add(ind + 1); - //wallTri.Add(ind + 3); - //wallTri.Add(ind + 2); - - vertsStartCount += 2*length; + for (int i = 0; i < md.Edges.Count; i+=2) + { + v1 = md.Vertices[md.Edges[i]]; + v2 = md.Vertices[md.Edges[i + 1]]; + ind = md.Vertices.Count; + md.Vertices.Add(v1); + md.Vertices.Add(v2); + md.Vertices.Add(new Vector3(v1.x, v1.y - hf, v1.z)); + md.Vertices.Add(new Vector3(v2.x, v2.y - hf, v2.z)); + + d = (v2 - v1).magnitude; + + wallUv.Add(new Vector2(0, 0)); + wallUv.Add(new Vector2(d, 0)); + wallUv.Add(new Vector2(0, -hf)); + wallUv.Add(new Vector2(d, -hf)); + + wallTri.Add(ind); + wallTri.Add(ind + 1); + wallTri.Add(ind + 2); + + wallTri.Add(ind + 1); + wallTri.Add(ind + 3); + wallTri.Add(ind + 2); } + + //for (int i = 0; i < feature.Points.Count; i++) + //{ + // var length = feature.Points[i].Count; + // for (int j = 1; j < 2 * length; j++) + // { + // v1 = md.Vertices[vertsStartCount + j - 1]; + // v2 = md.Vertices[vertsStartCount + j]; + // ind = md.Vertices.Count; + // md.Vertices.Add(v1); + // md.Vertices.Add(v2); + // md.Vertices.Add(new Vector3(v1.x, md.Vertices[j - 1].y - hf, v1.z)); + // md.Vertices.Add(new Vector3(v2.x, md.Vertices[j].y - hf, v2.z)); + + // d = (v2 - v1).magnitude; + + // wallUv.Add(new Vector2(0, 0)); + // wallUv.Add(new Vector2(d, 0)); + // wallUv.Add(new Vector2(0, -hf)); + // wallUv.Add(new Vector2(d, -hf)); + + // wallTri.Add(ind); + // wallTri.Add(ind + 2); + // wallTri.Add(ind + 1); + + // wallTri.Add(ind + 1); + // wallTri.Add(ind + 2); + // wallTri.Add(ind + 3); + // } + + // //v1 = md.Vertices[vertsStartCount]; + // //v2 = md.Vertices[vertsStartCount + length - 1]; + // //ind = md.Vertices.Count; + // //md.Vertices.Add(v1); + // //md.Vertices.Add(v2); + // //md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); + // //md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); + + // //d = (v2 - v1).magnitude; + + // //wallUv.Add(new Vector2(0, 0)); + // //wallUv.Add(new Vector2(d, 0)); + // //wallUv.Add(new Vector2(0, -hf)); + // //wallUv.Add(new Vector2(d, -hf)); + + // //wallTri.Add(ind); + // //wallTri.Add(ind + 1); + // //wallTri.Add(ind + 2); + + // //wallTri.Add(ind + 1); + // //wallTri.Add(ind + 3); + // //wallTri.Add(ind + 2); + + // vertsStartCount += 2 * length; + //} md.Triangles.Add(wallTri); md.UV[0].AddRange(wallUv); diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs index 642d41d5a..a8ad09721 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs @@ -19,12 +19,19 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile if (feature.Points.Count < 1) return; - foreach (var segment in feature.Points) + foreach (var roadSegment in feature.Points) { - var count = segment.Count; + var count = roadSegment.Count; + for (int i = 1; i < count*2; i++) + { + md.Edges.Add(md.Vertices.Count + i); + md.Edges.Add(md.Vertices.Count + i - 1); + } + md.Edges.Add(md.Vertices.Count); + md.Edges.Add(md.Vertices.Count + (count*2) - 1); + var newVerticeList = new Vector3[count * 2]; var uvList = new Vector2[count * 2]; - Vector3 norm; var lastUv = 0f; var p1 = Vector3.zero; @@ -32,11 +39,11 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile var p3 = Vector3.zero; for (int i = 1; i < count; i++) { - p1 = segment[i - 1]; - p2 = segment[i]; + p1 = roadSegment[i - 1]; + p2 = roadSegment[i]; p3 = p2; - if (i + 1 < segment.Count) - p3 = segment[i + 1]; + if (i + 1 < roadSegment.Count) + p3 = roadSegment[i + 1]; if (i == 1) { @@ -51,7 +58,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile norm = GetNormal(p1, p2, p3) * Width; newVerticeList[i] = (p2 + norm); newVerticeList[2 * count - 1 - i] = (p2 - norm); - + uvList[i] = new Vector2(0, lastUv); uvList[2 * count - 1 - i] = new Vector2(1, lastUv); } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index 1ebb6b265..33c9f8f8c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -91,6 +91,15 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile data.Add(tri.GetVertexID(1)); } + foreach (var edge in mesh.Edges) + { + if (edge.Label == 0) + continue; + + md.Edges.Add(edge.P0); + md.Edges.Add(edge.P1); + } + if (mesh.Vertices.Count != md.Vertices.Count) { md.Vertices.Clear(); From 208dde8bbaba0ce0c23e7aeb686d2cb86d516025 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Wed, 26 Apr 2017 19:08:21 +0300 Subject: [PATCH 08/24] fix height modifier bugs where min_height wasn't used properly remove terrain snapping from polygon modifier add meshdata vertex snapping to snapping modifier (along with original feature point snapping, which will probably be removed in the future) --- .../LayerVisualizers/VectorLayerVisualizer.cs | 12 +--- .../Modifiers/MeshModifiers/HeightModifier.cs | 63 ++----------------- .../MeshModifiers/PolygonMeshModifier.cs | 32 +++++----- .../MeshModifiers/SnapTerrainModifier.cs | 19 ++++-- .../Drive/Imagery/DriveImageFactory.asset | 2 +- .../DriveBuildingHeight.asset | 4 +- 6 files changed, 42 insertions(+), 90 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs index 8f7d9048c..b863939c2 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs @@ -109,17 +109,7 @@ private void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent var meshData = new MeshData(); meshData.TileRect = tile.Rect; - - //foreach (var sub in feature.Points) - //{ - // for (int i = 0; i < sub.Count; i++) - // { - // //sub[i].Set(sub[i].x, tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)), sub[i].z); - // var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); - // sub[i] += new Vector3(0, h, 0); - // } - //} - + //and finally, running the modifier stack on the feature var mod = Stacks.FirstOrDefault(x => x.Type.Contains(styleSelectorKey)); GameObject go; diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs index f74779c24..422011916 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs @@ -28,6 +28,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile if (md.Vertices.Count == 0 || feature == null || feature.Points.Count < 1) return; + var minHeight = 0f; float hf = _height; if (!_forceHeight) { @@ -37,7 +38,8 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile { if (feature.Properties.ContainsKey("min_height")) { - hf -= float.Parse(feature.Properties["min_height"].ToString()); + minHeight = float.Parse(feature.Properties["min_height"].ToString()); + hf -= minHeight; } } } @@ -62,7 +64,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile } for (int i = 0; i < md.Vertices.Count; i++) { - md.Vertices[i] = new Vector3(md.Vertices[i].x, max + hf, md.Vertices[i].z); + md.Vertices[i] = new Vector3(md.Vertices[i].x, max + minHeight + hf, md.Vertices[i].z); } hf += max - min; } @@ -70,11 +72,10 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile { for (int i = 0; i < md.Vertices.Count; i++) { - md.Vertices[i] = new Vector3(md.Vertices[i].x, md.Vertices[i].y + hf, md.Vertices[i].z); + md.Vertices[i] = new Vector3(md.Vertices[i].x, md.Vertices[i].y + minHeight + hf, md.Vertices[i].z); } } - var vertsStartCount = 0; var count = md.Vertices.Count; float d = 0f; Vector3 v1; @@ -110,60 +111,6 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile wallTri.Add(ind + 2); } - //for (int i = 0; i < feature.Points.Count; i++) - //{ - // var length = feature.Points[i].Count; - // for (int j = 1; j < 2 * length; j++) - // { - // v1 = md.Vertices[vertsStartCount + j - 1]; - // v2 = md.Vertices[vertsStartCount + j]; - // ind = md.Vertices.Count; - // md.Vertices.Add(v1); - // md.Vertices.Add(v2); - // md.Vertices.Add(new Vector3(v1.x, md.Vertices[j - 1].y - hf, v1.z)); - // md.Vertices.Add(new Vector3(v2.x, md.Vertices[j].y - hf, v2.z)); - - // d = (v2 - v1).magnitude; - - // wallUv.Add(new Vector2(0, 0)); - // wallUv.Add(new Vector2(d, 0)); - // wallUv.Add(new Vector2(0, -hf)); - // wallUv.Add(new Vector2(d, -hf)); - - // wallTri.Add(ind); - // wallTri.Add(ind + 2); - // wallTri.Add(ind + 1); - - // wallTri.Add(ind + 1); - // wallTri.Add(ind + 2); - // wallTri.Add(ind + 3); - // } - - // //v1 = md.Vertices[vertsStartCount]; - // //v2 = md.Vertices[vertsStartCount + length - 1]; - // //ind = md.Vertices.Count; - // //md.Vertices.Add(v1); - // //md.Vertices.Add(v2); - // //md.Vertices.Add(new Vector3(v1.x, md.Vertices[ind].y - hf, v1.z)); - // //md.Vertices.Add(new Vector3(v2.x, md.Vertices[ind].y - hf, v2.z)); - - // //d = (v2 - v1).magnitude; - - // //wallUv.Add(new Vector2(0, 0)); - // //wallUv.Add(new Vector2(d, 0)); - // //wallUv.Add(new Vector2(0, -hf)); - // //wallUv.Add(new Vector2(d, -hf)); - - // //wallTri.Add(ind); - // //wallTri.Add(ind + 1); - // //wallTri.Add(ind + 2); - - // //wallTri.Add(ind + 1); - // //wallTri.Add(ind + 3); - // //wallTri.Add(ind + 2); - - // vertsStartCount += 2 * length; - //} md.Triangles.Add(wallTri); md.UV[0].AddRange(wallUv); diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index 33c9f8f8c..0500698fe 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -6,11 +6,23 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers using TriangleNet.Geometry; using UnityEngine; using Mapbox.Unity.MeshGeneration.Data; + using TriangleNet.Meshing; + using System; + using TriangleNet.Smoothing; [CreateAssetMenu(menuName = "Mapbox/Modifiers/Polygon Mesh Modifier")] public class PolygonMeshModifier : MeshModifier { public override ModifierType Type { get { return ModifierType.Preprocess; } } + private ConstraintOptions options; + private QualityOptions quality; + + public void OnEnable() + { + options = new ConstraintOptions() { ConformingDelaunay = true }; + quality = new QualityOptions() { MinimumAngle = 25.0 }; + quality.MaximumArea = 100; + } public bool IsClockwise(IList vertices) { @@ -83,6 +95,8 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile } var mesh = polygon.Triangulate(); + //smoother mesh with smaller triangles and extra vertices in the middle + //var mesh = (TriangleNet.Mesh)polygon.Triangulate(options, quality); foreach (var tri in mesh.Triangles) { @@ -100,25 +114,15 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile md.Edges.Add(edge.P1); } - if (mesh.Vertices.Count != md.Vertices.Count) + md.Vertices.Clear(); + using (var sequenceEnum = mesh.Vertices.GetEnumerator()) { - md.Vertices.Clear(); - using (var sequenceEnum = mesh.Vertices.GetEnumerator()) + while (sequenceEnum.MoveNext()) { - while (sequenceEnum.MoveNext()) - { - var h = 0f; - if (tile != null) - { - h = tile.QueryHeightData((float)((sequenceEnum.Current.x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sequenceEnum.Current.y + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); - } - md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, h, (float)sequenceEnum.Current.y)); - } + md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, 0, (float)sequenceEnum.Current.y)); } } md.Triangles.Add(data); - - } } } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs index b9b4a31be..dc04bd4cc 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/SnapTerrainModifier.cs @@ -12,12 +12,23 @@ public class SnapTerrainModifier : MeshModifier public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) { - foreach (var sub in feature.Points) + if (md.Vertices.Count > 0) { - for (int i = 0; i < sub.Count; i++) + for (int i = 0; i < md.Vertices.Count; i++) { - var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); - sub[i] += new Vector3(0, h, 0); + var h = tile.QueryHeightData((float)((md.Vertices[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((md.Vertices[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); + md.Vertices[i] += new Vector3(0, h, 0); + } + } + else + { + foreach (var sub in feature.Points) + { + for (int i = 0; i < sub.Count; i++) + { + var h = tile.QueryHeightData((float)((sub[i].x + tile.Rect.Size.x / 2) / tile.Rect.Size.x), (float)((sub[i].z + tile.Rect.Size.y / 2) / tile.Rect.Size.y)); + sub[i] += new Vector3(0, h, 0); + } } } } diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset index e8a27964b..50fbbda67 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset @@ -13,5 +13,5 @@ MonoBehaviour: m_EditorClassIdentifier: _mapIdType: 0 _customMapId: - _mapId: mapbox://styles/mapbox/satellite-v9 + _mapId: mapbox://styles/mapbox/streets-v10 _baseMaterial: {fileID: 2100000, guid: 06b583c58078c164eb45358a14a5c66b, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset index 13a8f659b..e542cab63 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset @@ -13,5 +13,5 @@ MonoBehaviour: m_EditorClassIdentifier: Active: 1 _flatTops: 1 - _height: 0 - _forceHeight: 0 + _height: 1 + _forceHeight: 1 From a8a10f8f834d5267b347cda41e2bdfb10ca9afc5 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Fri, 28 Apr 2017 01:08:46 +0300 Subject: [PATCH 09/24] add a new line mesh modifier using clipper offsetting --- .../MeshModifiers/ClipperLineMeshModifier.cs | 184 ++++++++++++++++++ .../ClipperLineMeshModifier.cs.meta | 12 ++ .../ClipperLineMeshModifier.asset | 15 ++ .../ClipperLineMeshModifier.asset.meta | 8 + 4 files changed, 219 insertions(+) create mode 100644 sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs create mode 100644 sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs.meta create mode 100644 sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset.meta diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs new file mode 100644 index 000000000..88cd337b3 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs @@ -0,0 +1,184 @@ +namespace Mapbox.Unity.MeshGeneration.Modifiers +{ + using System.Collections.Generic; + using System.Linq; + using UnityEngine; + using Mapbox.Unity.MeshGeneration.Data; + using VectorTile.InteralClipperLib; + using TriangleNet.Geometry; + + [CreateAssetMenu(menuName = "Mapbox/Modifiers/Clipper Line Mesh Modifier")] + public class ClipperLineMeshModifier : MeshModifier + { + [SerializeField] + private float Width; + public override ModifierType Type { get { return ModifierType.Preprocess; } } + + public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile = null) + { + if (feature.Points.Count < 1) + return; + + InternalClipper.PolyTree solution = new InternalClipper.PolyTree(); + InternalClipper.ClipperOffset co = new InternalClipper.ClipperOffset(); + + foreach (var roadSegment in feature.Points) + { + co.AddPath(roadSegment.Select(i => new InternalClipper.IntPoint(i.x, i.z)).ToList(), InternalClipper.JoinType.jtSquare, InternalClipper.EndType.etOpenButt); + } + + co.Execute(ref solution, Width/2); + var x = solution; + + var polygon = new Polygon(); + Vertex prev = null; + Vertex current = null; + Vertex first = null; + foreach (var poly in solution.m_AllPolys) + { + prev = null; + current = null; + first = null; + foreach (var item in poly.Contour) + { + prev = current; + current = new Vertex(item.X, item.Y, 0); + if (first == null) + first = current; + polygon.Add(current); + if(prev != null) + polygon.Add(new Segment(current, prev)); + } + polygon.Add(new Segment(first, current)); + } + + var mesh = polygon.Triangulate(); + var data = new List(); + foreach (var tri in mesh.Triangles) + { + data.Add(tri.GetVertexID(0)); + data.Add(tri.GetVertexID(2)); + data.Add(tri.GetVertexID(1)); + } + + foreach (var edge in mesh.Edges) + { + if (edge.Label == 0) + continue; + + md.Edges.Add(edge.P0); + md.Edges.Add(edge.P1); + } + md.Vertices.Clear(); + using (var sequenceEnum = mesh.Vertices.GetEnumerator()) + { + while (sequenceEnum.MoveNext()) + { + md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, 0, (float)sequenceEnum.Current.y)); + } + } + md.Triangles.Add(data); + + //foreach (var roadSegment in feature.Points) + //{ + // var count = roadSegment.Count; + // for (int i = 1; i < count*2; i++) + // { + // md.Edges.Add(md.Vertices.Count + i); + // md.Edges.Add(md.Vertices.Count + i - 1); + // } + // md.Edges.Add(md.Vertices.Count); + // md.Edges.Add(md.Vertices.Count + (count*2) - 1); + + // var newVerticeList = new Vector3[count * 2]; + // var uvList = new Vector2[count * 2]; + // Vector3 norm; + // var lastUv = 0f; + // var p1 = Vector3.zero; + // var p2 = Vector3.zero; + // var p3 = Vector3.zero; + // for (int i = 1; i < count; i++) + // { + // p1 = roadSegment[i - 1]; + // p2 = roadSegment[i]; + // p3 = p2; + // if (i + 1 < roadSegment.Count) + // p3 = roadSegment[i + 1]; + + // if (i == 1) + // { + // norm = GetNormal(p1, p1, p2) * Width; //road width + // newVerticeList[0] = (p1 + norm); + // newVerticeList[count * 2 - 1] = (p1 - norm); + // uvList[0] = new Vector2(0, 0); + // uvList[count * 2 - 1] = new Vector2(1, 0); + // } + // var dist = Vector3.Distance(p1, p2); + // lastUv += dist; + // norm = GetNormal(p1, p2, p3) * Width; + // newVerticeList[i] = (p2 + norm); + // newVerticeList[2 * count - 1 - i] = (p2 - norm); + + // uvList[i] = new Vector2(0, lastUv); + // uvList[2 * count - 1 - i] = new Vector2(1, lastUv); + // } + + // //if (_mergeStartEnd) + // //{ + // // //brnkhy -2 because first and last items are same + // // p1 = segment[count - 2]; + // // p2 = segment[0]; + // // p3 = segment[1]; + + // // norm = GetNormal(p1, p2, p3) * Width; + // // newVerticeList[count - 1] = p2 + norm; + // // newVerticeList[0] = p2 + norm; + // // newVerticeList[count] = p2 - norm; + // // newVerticeList[2 * count - 1] = p2 - norm; + // //} + + // var pcount = md.Vertices.Count; + // md.Vertices.AddRange(newVerticeList); + // md.UV[0].AddRange(uvList); + // var lineTri = new List(); + // var n = count; + + // for (int i = 0; i < n - 1; i++) + // { + // lineTri.Add(pcount + i); + // lineTri.Add(pcount + i + 1); + // lineTri.Add(pcount + 2 * n - 1 - i); + + // lineTri.Add(pcount + i + 1); + // lineTri.Add(pcount + 2 * n - i - 2); + // lineTri.Add(pcount + 2 * n - i - 1); + // } + + // if (md.Triangles.Count < 1) + // md.Triangles.Add(new List()); + // md.Triangles[0].AddRange(lineTri); + //} + } + + private Vector3 GetNormal(Vector3 p1, Vector3 newPos, Vector3 p2) + { + if (newPos == p1 || newPos == p2) + { + var n = (p2 - p1).normalized; + return new Vector3(-n.z, 0, n.x); + } + + var b = (p2 - newPos).normalized + newPos; + var a = (p1 - newPos).normalized + newPos; + var t = (b - a).normalized; + + if (t == Vector3.zero) + { + var n = (p2 - p1).normalized; + return new Vector3(-n.z, 0, n.x); + } + + return new Vector3(-t.z, 0, t.x); + } + } +} diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs.meta b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs.meta new file mode 100644 index 000000000..be8b53c9b --- /dev/null +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0f336c96bbad10f4188e275dd470363e +timeCreated: 1493309511 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset new file mode 100644 index 000000000..9c3d224f7 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0f336c96bbad10f4188e275dd470363e, type: 3} + m_Name: ClipperLineMeshModifier + m_EditorClassIdentifier: + Active: 1 + Width: 5 diff --git a/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset.meta new file mode 100644 index 000000000..427e81bf0 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/RoadModifierStack/ClipperLineMeshModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c4c1674e9b6d2d64181d7fa3cbcbb3bd +timeCreated: 1493309530 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: From 967554cf4885a55248e8d6f272a06716fc2f74eb Mon Sep 17 00:00:00 2001 From: brnkhy Date: Fri, 5 May 2017 21:03:36 +0300 Subject: [PATCH 10/24] change PolygonMeshModifier to use new parameter order of vertex class --- .../Modifiers/MeshModifiers/PolygonMeshModifier.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index 93b45a67f..6822288e0 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -61,8 +61,8 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile { if (nextVert == null) { - currentVert = new Vertex(sub[i].x, sub[i].z, sub[i].y); - nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z, sub[i].y); + currentVert = new Vertex(sub[i].x, sub[i].y, sub[i].z); + nextVert = new Vertex(sub[i + 1].x, sub[i].y, sub[i + 1].z); } else { @@ -73,7 +73,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile } else { - nextVert = new Vertex(sub[i + 1].x, sub[i + 1].z, sub[i + 1].y); + nextVert = new Vertex(sub[i + 1].x, sub[i + 1].y, sub[i + 1].z); } } @@ -92,7 +92,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile for (int i = 0; i < sub.Count; i++) { wist.Add(sub[i]); - cont.Add(new Vertex(sub[i].x, sub[i].z, sub[i].y)); + cont.Add(new Vertex(sub[i].x, sub[i].y, sub[i].z)); } polygon.Add(new Contour(cont), true); } From fcbb0eafee4c679ea291d41b5643a9e3888ca107 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Mon, 8 May 2017 13:59:10 -0600 Subject: [PATCH 11/24] bumping submodules --- dependencies/mapbox-sdk-cs | 2 +- dependencies/triangle.net-uwp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index 558cb770a..4c004a746 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit 558cb770ade50ff737bf4d6001b88af6e68578ba +Subproject commit 4c004a746e4c82770d99f59325209995d37339f4 diff --git a/dependencies/triangle.net-uwp b/dependencies/triangle.net-uwp index f636c758b..4995526c5 160000 --- a/dependencies/triangle.net-uwp +++ b/dependencies/triangle.net-uwp @@ -1 +1 @@ -Subproject commit f636c758b44e38827a66dbb7e1ae392a37bf9e8a +Subproject commit 4995526c5fa1015a9c356aec667c9331c8e05b61 From 7c4f789fe5f285b3fdadafbb3c4acd8b440e214f Mon Sep 17 00:00:00 2001 From: brnkhy Date: Mon, 15 May 2017 16:49:04 +0300 Subject: [PATCH 12/24] fix a bug where y coordinate is lost and not used in polygon modifier --- .../Modifiers/MeshModifiers/PolygonMeshModifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs index 6822288e0..34f2b5fb7 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs @@ -123,7 +123,7 @@ public override void Run(VectorFeatureUnity feature, MeshData md, UnityTile tile { while (sequenceEnum.MoveNext()) { - md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, 0, (float)sequenceEnum.Current.y)); + md.Vertices.Add(new Vector3((float)sequenceEnum.Current.x, (float)sequenceEnum.Current.z, (float)sequenceEnum.Current.y)); } } md.Triangles.Add(data); From d345ef7e7f4fa28378a1ffb893373423ab46606c Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 16 May 2017 18:26:34 +0300 Subject: [PATCH 13/24] fix snap y axis to 0 function fix drive and slippy scenes' module links --- .../Unity/MeshGeneration/MapController.cs | 20 +++++++++---------- .../Drive/Imagery/DriveImageFactory.asset | 2 +- .../DriveBuildingHeight.asset | 4 ++-- .../Drive/Mesh/DriveBuildingVisualizer.asset | 4 +--- .../Drive/Mesh/DriveMeshFactory.asset | 3 ++- .../BuildingLayerModifier.asset | 15 ++++++++++++++ .../BuildingLayerModifier.asset.meta | 8 ++++++++ .../ColliderModifier.asset | 15 ++++++++++++++ .../ColliderModifier.asset.meta | 8 ++++++++ .../SnapTerrainModifier.asset | 14 +++++++++++++ .../SnapTerrainModifier.asset.meta | 8 ++++++++ .../TerrainDemoDefaultBuildingStack.asset | 2 ++ .../SnapTerrainModifier.asset | 14 +++++++++++++ .../SnapTerrainModifier.asset.meta | 8 ++++++++ 14 files changed, 107 insertions(+), 18 deletions(-) create mode 100644 sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset.meta create mode 100644 sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset.meta create mode 100644 sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset.meta create mode 100644 sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset create mode 100644 sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset.meta diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs index fa88cca0f..dbb00b056 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs @@ -47,18 +47,11 @@ public void Start() /// /// Pulls the root world object to origin for ease of use/view /// - public void Update() + private void SnapZero(UnityTile s, object e) { - if (_snapYToZero) - { - var ray = new Ray(new Vector3(0, 1000, 0), Vector3.down); - RaycastHit rayhit; - if (Physics.Raycast(ray, out rayhit)) - { - _root.transform.position = new Vector3(0, -rayhit.point.y, 0); - _snapYToZero = false; - } - } + var h = Conversions.GetRelativeHeightFromColor(s.HeightData.GetPixel(127, 127), s.RelativeScale); + _root.transform.position = new Vector3(0, -h * WorldScaleFactor, 0); + s.HeightDataChanged -= SnapZero; } public void Execute() @@ -106,6 +99,11 @@ public void Execute(double lat, double lng, int zoom, Vector4 frame) tile.transform.position = new Vector3((float)(tile.Rect.Center.x - ReferenceTileRect.Center.x), 0, (float)(tile.Rect.Center.y - ReferenceTileRect.Center.y)); tile.transform.SetParent(_root.transform, false); MapVisualization.ShowTile(tile); + + if (_snapYToZero && j == tms.y && i == tms.x) + { + tile.HeightDataChanged += SnapZero; + } } } } diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset index 50fbbda67..9f66b7e17 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Imagery/DriveImageFactory.asset @@ -13,5 +13,5 @@ MonoBehaviour: m_EditorClassIdentifier: _mapIdType: 0 _customMapId: - _mapId: mapbox://styles/mapbox/streets-v10 + _mapId: mapbox://styles/mapbox/dark-v9 _baseMaterial: {fileID: 2100000, guid: 06b583c58078c164eb45358a14a5c66b, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset index e542cab63..13a8f659b 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingStyle/DriveBuildingHeight.asset @@ -13,5 +13,5 @@ MonoBehaviour: m_EditorClassIdentifier: Active: 1 _flatTops: 1 - _height: 1 - _forceHeight: 1 + _height: 0 + _forceHeight: 0 diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingVisualizer.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingVisualizer.asset index 3320fdf15..70874cfd3 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingVisualizer.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveBuildingVisualizer.asset @@ -16,6 +16,4 @@ MonoBehaviour: _key: building Filters: [] _defaultStack: {fileID: 11400000, guid: 571ce5811f4b94246b9d4c96499d61b7, type: 2} - Stacks: - - Type: default - Stack: {fileID: 11400000, guid: 571ce5811f4b94246b9d4c96499d61b7, type: 2} + Stacks: [] diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset index 50e6d5f62..807149517 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Mesh/DriveMeshFactory.asset @@ -13,4 +13,5 @@ MonoBehaviour: m_EditorClassIdentifier: _mapId: mapbox.mapbox-traffic-v1,mapbox.mapbox-streets-v7 Visualizers: - - {fileID: 11400000, guid: e71aac5125636534886a86af764815c9, type: 2} + - {fileID: 11400000, guid: 960fc9b7bdbc4f24b860f10bdfd7c165, type: 2} + - {fileID: 11400000, guid: 3a02dddaa897fd444b76d6ed1339dab6, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset new file mode 100644 index 000000000..ef2e6f107 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a4644f4fa4408d144a9c7927401f3807, type: 3} + m_Name: BuildingLayerModifier + m_EditorClassIdentifier: + Active: 1 + _layerId: 10 diff --git a/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset.meta new file mode 100644 index 000000000..4ec1c5e03 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/BuildingLayerModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0e9403508685d6c4f98a9d95e8e79baa +timeCreated: 1494350247 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset new file mode 100644 index 000000000..24674c102 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 288d05a2dbabb0f46a5fa6c85102780a, type: 3} + m_Name: ColliderModifier + m_EditorClassIdentifier: + Active: 1 + _colliderType: 1 diff --git a/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset.meta new file mode 100644 index 000000000..cc0c88c92 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/MeshGenerationBasics/MapVisualization/Factories/MeshFactory/BuildingModifierStack/ColliderModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7b664c5d0b1dfd4ea8bf239a71912ef +timeCreated: 1494350935 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset new file mode 100644 index 000000000..4cb7ad18a --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 40bee3110109c0848bb86c9b5c436039, type: 3} + m_Name: SnapTerrainModifier + m_EditorClassIdentifier: + Active: 1 diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset.meta new file mode 100644 index 000000000..00c74e6d3 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/SnapTerrainModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f07994411a271a2488d65887412818b9 +timeCreated: 1492732239 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset index bc2710daa..873d45fdb 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset @@ -11,7 +11,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 25f09effe9db3dd4e9e825475d698ca3, type: 3} m_Name: TerrainDemoDefaultBuildingStack m_EditorClassIdentifier: + _baseModifiers: [] MeshModifiers: + - {fileID: 11400000, guid: 5d2129c4f45752d449951b9f6e8f5c3f, type: 2} - {fileID: 11400000, guid: 22fdc44ee48832a4cb46adeb9123e5f7, type: 2} - {fileID: 11400000, guid: 99edcda8cdbf6da488c3da361c881bf8, type: 2} - {fileID: 11400000, guid: 941309cd0c1ac6949951075da621d483, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset new file mode 100644 index 000000000..4cb7ad18a --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 40bee3110109c0848bb86c9b5c436039, type: 3} + m_Name: SnapTerrainModifier + m_EditorClassIdentifier: + Active: 1 diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset.meta b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset.meta new file mode 100644 index 000000000..3031ff0e5 --- /dev/null +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/SnapTerrainModifier.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 86a20dba8c16aaa4c9eeed167327a764 +timeCreated: 1494947833 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: From d811402598fad5eec73edadb3ac0af8f5f94e05e Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 16 May 2017 10:08:44 -0600 Subject: [PATCH 14/24] submodule update --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index 4c004a746..a41e0a5d1 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit 4c004a746e4c82770d99f59325209995d37339f4 +Subproject commit a41e0a5d16030d022d1d407c535854ac47f84747 From 315ca866837cce265d4823e7e8f90c82aaccb78b Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 16 May 2017 10:09:57 -0600 Subject: [PATCH 15/24] roll back submodule --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index a41e0a5d1..4c004a746 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit a41e0a5d16030d022d1d407c535854ac47f84747 +Subproject commit 4c004a746e4c82770d99f59325209995d37339f4 From dbbfbb2bbf6c8d18d9ff58c68e6b5d1ab2de424e Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 16 May 2017 19:40:17 +0300 Subject: [PATCH 16/24] add empty constructor to VectorFeatureUnity change directions factory to create a VectorFeatureUnity for modifiers --- .../Core/Unity/MeshGeneration/Data/VectorFeatureUnity.cs | 7 ++++++- .../Unity/MeshGeneration/Factories/DirectionsFactory.cs | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/VectorFeatureUnity.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/VectorFeatureUnity.cs index 0264537ed..7d5acce7f 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/VectorFeatureUnity.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Data/VectorFeatureUnity.cs @@ -12,6 +12,11 @@ public class VectorFeatureUnity public Dictionary Properties { get; set; } public List> Points; + public VectorFeatureUnity() + { + Points = new List>(); + } + public VectorFeatureUnity(VectorTileFeature feature, UnityTile tile, float layerExtent) { Data = feature; @@ -24,7 +29,7 @@ public VectorFeatureUnity(VectorTileFeature feature, UnityTile tile, float layer for (int j = 0; j < feature.Geometry[i].Count; j++) { var point = feature.Geometry[i][j]; - nl.Add(new Vector3((float)(point.X / layerExtent * tile.Rect.Size.x - (tile.Rect.Size.x/2)), 0, (float)((layerExtent - point.Y) / layerExtent * tile.Rect.Size.y - (tile.Rect.Size.y / 2)))); + nl.Add(new Vector3((float)(point.X / layerExtent * tile.Rect.Size.x - (tile.Rect.Size.x / 2)), 0, (float)((layerExtent - point.Y) / layerExtent * tile.Rect.Size.y - (tile.Rect.Size.y / 2)))); } Points.Add(nl); } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs index cfa365d9f..6298c15a8 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs @@ -34,18 +34,21 @@ public void Query(List waypoints) void HandleDirectionsResponse(DirectionsResponse response) { var meshData = new MeshData(); - + var dat = new List(); foreach (var leg in response.Routes[0].Legs) { foreach (var point in response.Routes[0].Geometry) { - meshData.Vertices.Add(Conversions.GeoToWorldPosition(point.x, point.y, MapController.ReferenceTileRect.Center, MapController.WorldScaleFactor).ToVector3xz()); + dat.Add(Conversions.GeoToWorldPosition(point.x, point.y, MapController.ReferenceTileRect.Center, MapController.WorldScaleFactor).ToVector3xz()); } } + var feat = new VectorFeatureUnity(); + feat.Points.Add(dat); + foreach (MeshModifier mod in MeshModifiers.Where(x => x.Active)) { - mod.Run(null, meshData); + mod.Run(feat, meshData); } CreateGameObject(meshData); From 524b14f4a72d1e399ae51ae641764fd1fb790e44 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 16 May 2017 19:41:43 +0300 Subject: [PATCH 17/24] update scene and some asset files --- .../Assets/Mapbox/Examples/Drive/Drive.unity | 210 +++++++++++++++++- .../Examples/Drive/DriveVisualization.asset | 1 + .../TerrainDemoBuildingHeightModifier.asset | 1 + .../TerrainDemoDefaultBuildingStack.asset | 2 +- .../Resources/TerrainRoadMaterial.mat | 2 +- .../TerrainDemoDefaultRoadStack.asset | 2 + .../TerrainDemoRoadHeightModifier.asset | 5 +- .../TerrainDemoRoadLineModifier.asset | 2 +- .../Factories/TerrainDemoTerrainFactory.asset | 2 +- 9 files changed, 218 insertions(+), 9 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity b/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity index 9ddc7cf4e..6b07653cd 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity @@ -37,7 +37,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44692504, g: 0.4967869, b: 0.57508504, a: 1} + m_IndirectSpecularColor: {r: 0.44692492, g: 0.4967869, b: 0.57508546, a: 1} --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -183,9 +183,9 @@ MonoBehaviour: MapVisualization: {fileID: 11400000, guid: 4f4961d6f3e45f84f99bda9cdc9dbb2b, type: 2} TileSize: 100 _snapYToZero: 1 - LatLng: 37.790908, -122.403361 + LatLng: 37.781169, -122.409955 Zoom: 16 - Range: {x: 1, y: 1, z: 1, w: 1} + Range: {x: 3, y: 3, z: 3, w: 3} --- !u!4 &199863781 Transform: m_ObjectHideFlags: 0 @@ -199,6 +199,210 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 +--- !u!1 &248560052 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 248560056} + - 33: {fileID: 248560055} + - 65: {fileID: 248560054} + - 23: {fileID: 248560053} + m_Layer: 0 + m_Name: Target + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &248560053 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 248560052} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 50b7ba2da8847fc49b37ca6d7f1b4ea1, type: 2} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedWireframeHidden: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!65 &248560054 +BoxCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 248560052} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &248560055 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 248560052} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &248560056 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 248560052} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: -25.9, y: 20.4, z: -110} + m_LocalScale: {x: 11, y: 11, z: 11} + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 761742983} + m_RootOrder: 1 +--- !u!1 &761742981 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 761742983} + - 114: {fileID: 761742982} + m_Layer: 0 + m_Name: DirectionHelper + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &761742982 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 761742981} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d8534d45be3bd44f84c41bc08827496, type: 3} + m_Name: + m_EditorClassIdentifier: + Directions: {fileID: 11400000, guid: d370b4703777f8c48b26eead134f2edb, type: 2} + Waypoints: + - {fileID: 1553875871} + - {fileID: 248560056} +--- !u!4 &761742983 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 761742981} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1553875871} + - {fileID: 248560056} + m_Father: {fileID: 0} + m_RootOrder: 3 +--- !u!1 &1553875867 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1553875871} + - 33: {fileID: 1553875870} + - 65: {fileID: 1553875869} + - 23: {fileID: 1553875868} + m_Layer: 0 + m_Name: Start + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1553875868 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1553875867} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 7c708c0bb5591844e8a1e7bc6ba7b55e, type: 2} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedWireframeHidden: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!65 &1553875869 +BoxCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1553875867} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!33 &1553875870 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1553875867} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1553875871 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1553875867} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 75.3, y: 20.4, z: 71.3} + m_LocalScale: {x: 11, y: 11, z: 11} + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 761742983} + m_RootOrder: 0 --- !u!1 &1872744247 GameObject: m_ObjectHideFlags: 0 diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset b/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset index 0e2e27683..d3eb47f1a 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset +++ b/sdkproject/Assets/Mapbox/Examples/Drive/DriveVisualization.asset @@ -15,3 +15,4 @@ MonoBehaviour: - {fileID: 11400000, guid: 0bbb865e3ab501a4ba8ed8cf759b6d34, type: 2} - {fileID: 11400000, guid: 534ecf4b5a553dd47a0c07a4265efdd6, type: 2} - {fileID: 11400000, guid: 5be1766dc865f9b4f9549cb75a1551b0, type: 2} + - {fileID: 11400000, guid: d370b4703777f8c48b26eead134f2edb, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoBuildingHeightModifier.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoBuildingHeightModifier.asset index 85af0667b..3e19a8594 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoBuildingHeightModifier.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoBuildingHeightModifier.asset @@ -12,5 +12,6 @@ MonoBehaviour: m_Name: TerrainDemoBuildingHeightModifier m_EditorClassIdentifier: Active: 1 + _flatTops: 1 _height: 0 _forceHeight: 0 diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset index 873d45fdb..6199079ff 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/BuildingModifierStack/TerrainDemoDefaultBuildingStack.asset @@ -13,7 +13,7 @@ MonoBehaviour: m_EditorClassIdentifier: _baseModifiers: [] MeshModifiers: - - {fileID: 11400000, guid: 5d2129c4f45752d449951b9f6e8f5c3f, type: 2} + - {fileID: 11400000, guid: f07994411a271a2488d65887412818b9, type: 2} - {fileID: 11400000, guid: 22fdc44ee48832a4cb46adeb9123e5f7, type: 2} - {fileID: 11400000, guid: 99edcda8cdbf6da488c3da361c881bf8, type: 2} - {fileID: 11400000, guid: 941309cd0c1ac6949951075da621d483, type: 2} diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/Resources/TerrainRoadMaterial.mat b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/Resources/TerrainRoadMaterial.mat index daa854314..d6a27f638 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/Resources/TerrainRoadMaterial.mat +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/Resources/TerrainRoadMaterial.mat @@ -121,7 +121,7 @@ Material: m_Colors: - first: name: _Color - second: {r: 1, g: 1, b: 1, a: 1} + second: {r: 0.6764706, g: 0.27357268, b: 0.6153412, a: 1} - first: name: _EmissionColor second: {r: 0, g: 0, b: 0, a: 1} diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoDefaultRoadStack.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoDefaultRoadStack.asset index 823d34e17..b96647ebb 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoDefaultRoadStack.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoDefaultRoadStack.asset @@ -11,7 +11,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 25f09effe9db3dd4e9e825475d698ca3, type: 3} m_Name: TerrainDemoDefaultRoadStack m_EditorClassIdentifier: + _baseModifiers: [] MeshModifiers: + - {fileID: 11400000, guid: 86a20dba8c16aaa4c9eeed167327a764, type: 2} - {fileID: 11400000, guid: 4ef2eed850b24404faac9fb8d49350a7, type: 2} - {fileID: 11400000, guid: c5ef3557587c7a445bc8022429cc74bf, type: 2} GoModifiers: diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadHeightModifier.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadHeightModifier.asset index 847679374..8d1051783 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadHeightModifier.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadHeightModifier.asset @@ -12,5 +12,6 @@ MonoBehaviour: m_Name: TerrainDemoRoadHeightModifier m_EditorClassIdentifier: Active: 1 - _height: 1 - _forceHeight: 0 + _flatTops: 0 + _height: 21 + _forceHeight: 1 diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadLineModifier.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadLineModifier.asset index 62d397dfc..0b74270ce 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadLineModifier.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/MeshFactory/RoadModifierStack/TerrainDemoRoadLineModifier.asset @@ -13,4 +13,4 @@ MonoBehaviour: m_EditorClassIdentifier: Active: 1 _mergeStartEnd: 0 - Width: 3 + Width: 22 diff --git a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/TerrainDemoTerrainFactory.asset b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/TerrainDemoTerrainFactory.asset index e2e0565fe..343256387 100644 --- a/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/TerrainDemoTerrainFactory.asset +++ b/sdkproject/Assets/Mapbox/Examples/SlippyVectorTerrain/Factories/TerrainDemoTerrainFactory.asset @@ -17,4 +17,4 @@ MonoBehaviour: _customMapId: mapbox.terrain-rgb _mapId: mapbox.terrain-rgb _heightModifier: 1 - _sampleCount: 40 + _sampleCount: 80 From 9fe30f4bc7b26738032387de4ddfbbdbd336964e Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 16 May 2017 20:24:53 +0300 Subject: [PATCH 18/24] fix branch for latest static field removal --- .../Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs | 2 +- .../Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs | 4 ++-- .../Modifiers/MeshModifiers/ClipperLineMeshModifier.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs index bccf4754f..c0bea050b 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/DirectionsFactory.cs @@ -44,7 +44,7 @@ void HandleDirectionsResponse(DirectionsResponse response) { foreach (var point in response.Routes[0].Geometry) { - dat.Add(Conversions.GeoToWorldPosition(point.x, point.y, MapController.ReferenceTileRect.Center, MapController.WorldScaleFactor).ToVector3xz()); + dat.Add(Conversions.GeoToWorldPosition(point.x, point.y, Parameters.ReferenceTileRect.Center, Parameters.WorldScaleFactor).ToVector3xz()); } } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs index 50416bad3..701164076 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs @@ -70,7 +70,7 @@ public void Start() private void SnapZero(UnityTile s, object e) { var h = Conversions.GetRelativeHeightFromColor(s.HeightData.GetPixel(127, 127), s.RelativeScale); - _root.transform.position = new Vector3(0, -h * WorldScaleFactor, 0); + Root.transform.position = new Vector3(0, -h * WorldParameters.WorldScaleFactor, 0); s.HeightDataChanged -= SnapZero; } @@ -103,7 +103,7 @@ public void Execute(double lat, double lng, int zoom, Vector4 frame) tile.transform.SetParent(Root.transform, false); MapVisualization.ShowTile(tile); - if (_snapYToZero && j == tms.y && i == tms.x) + if (_snapYToZero && j == _refTile.y && i == _refTile.x) { tile.HeightDataChanged += SnapZero; } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs index 88cd337b3..40578e5c3 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs @@ -4,8 +4,8 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers using System.Linq; using UnityEngine; using Mapbox.Unity.MeshGeneration.Data; - using VectorTile.InteralClipperLib; using TriangleNet.Geometry; + using Mapbox.VectorTile.Geometry.InteralClipperLib; [CreateAssetMenu(menuName = "Mapbox/Modifiers/Clipper Line Mesh Modifier")] public class ClipperLineMeshModifier : MeshModifier From 430909598343a6dc837555bd916dc54a2fa4039a Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 16 May 2017 20:33:46 +0300 Subject: [PATCH 19/24] fix broken using statement path --- .../Modifiers/MeshModifiers/ClipperLineMeshModifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs index 40578e5c3..d80fc1b5c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs @@ -5,7 +5,7 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers using UnityEngine; using Mapbox.Unity.MeshGeneration.Data; using TriangleNet.Geometry; - using Mapbox.VectorTile.Geometry.InteralClipperLib; + using Mapbox.VectorTile.InteralClipperLib; [CreateAssetMenu(menuName = "Mapbox/Modifiers/Clipper Line Mesh Modifier")] public class ClipperLineMeshModifier : MeshModifier From 48b99c72e3c8d12095630649fcfa29c7bd8d81b0 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 16 May 2017 11:37:45 -0600 Subject: [PATCH 20/24] point to proper triangle branch --- dependencies/triangle.net-uwp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/triangle.net-uwp b/dependencies/triangle.net-uwp index 4ce02ce07..4995526c5 160000 --- a/dependencies/triangle.net-uwp +++ b/dependencies/triangle.net-uwp @@ -1 +1 @@ -Subproject commit 4ce02ce072698e2433184cf4b49e6450e286ef01 +Subproject commit 4995526c5fa1015a9c356aec667c9331c8e05b61 From 9792343669f09bf1f00226ecf95c90593d660744 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 16 May 2017 11:40:25 -0600 Subject: [PATCH 21/24] update cs module --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index 4c004a746..e7430f5ca 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit 4c004a746e4c82770d99f59325209995d37339f4 +Subproject commit e7430f5ca70cb031df7c2cec31cbfff6f2ce986e From 28ae04b8e26756a10d4c921241e50d1e851eb2a6 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 16 May 2017 11:42:06 -0600 Subject: [PATCH 22/24] bump vector module --- dependencies/vector-tile-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/vector-tile-cs b/dependencies/vector-tile-cs index c99cc8435..4b1abd4c3 160000 --- a/dependencies/vector-tile-cs +++ b/dependencies/vector-tile-cs @@ -1 +1 @@ -Subproject commit c99cc8435ae177e4e54ed9b11397934c648868be +Subproject commit 4b1abd4c32066728579fdd9eafd21a1dda4d84f3 From 660c7cb694e61f733fd21f288b3458eca1df1bf2 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Tue, 16 May 2017 20:45:43 +0300 Subject: [PATCH 23/24] fix using statement after submodule update --- .../Modifiers/MeshModifiers/ClipperLineMeshModifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs index d80fc1b5c..40578e5c3 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ClipperLineMeshModifier.cs @@ -5,7 +5,7 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers using UnityEngine; using Mapbox.Unity.MeshGeneration.Data; using TriangleNet.Geometry; - using Mapbox.VectorTile.InteralClipperLib; + using Mapbox.VectorTile.Geometry.InteralClipperLib; [CreateAssetMenu(menuName = "Mapbox/Modifiers/Clipper Line Mesh Modifier")] public class ClipperLineMeshModifier : MeshModifier From baac8196c758d43f115ce547883bbab7b44db721 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 16 May 2017 11:53:41 -0600 Subject: [PATCH 24/24] Smaller map for building to mobile Fixed missing reference to map controller --- sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity b/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity index b20558f07..7309fe2ac 100644 --- a/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity +++ b/sdkproject/Assets/Mapbox/Examples/Drive/Drive.unity @@ -37,7 +37,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44692492, g: 0.4967869, b: 0.57508546, a: 1} + m_IndirectSpecularColor: {r: 0.44692504, g: 0.4967869, b: 0.57508504, a: 1} --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -185,7 +185,8 @@ MonoBehaviour: _snapYToZero: 1 LatLng: 37.781169, -122.409955 Zoom: 16 - Range: {x: 3, y: 3, z: 3, w: 3} + Range: {x: 1, y: 1, z: 1, w: 1} + Root: {fileID: 0} --- !u!4 &199863781 Transform: m_ObjectHideFlags: 0 @@ -306,7 +307,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: MapController: {fileID: 199863780} - MapVisualization: {fileID: 11400000, guid: 4f4961d6f3e45f84f99bda9cdc9dbb2b, type: 2} Directions: {fileID: 11400000, guid: d370b4703777f8c48b26eead134f2edb, type: 2} Waypoints: - {fileID: 1553875871}