diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/Factory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/Factory.cs
index 91b2499a0..b473599ab 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/Factory.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/Factory.cs
@@ -4,6 +4,9 @@ namespace Mapbox.Unity.MeshGeneration.Factories
using Mapbox.Unity.MeshGeneration.Data;
using Mapbox.Platform;
+ ///
+ /// Corresponds to Mapbox Api end points like raster image, vector tile or directions. Makes the web calls and handles the response.
+ ///
public class Factory : ScriptableObject
{
protected IFileSource FileSource;
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs
index 71cb034b5..4f6ad271c 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs
@@ -15,6 +15,9 @@ public enum MapImageType
None
}
+ ///
+ /// Uses raster image services to create materials & textures for terrain
+ ///
[CreateAssetMenu(menuName = "Mapbox/Factories/Map Image Factory")]
public class MapImageFactory : Factory
{
@@ -51,6 +54,11 @@ public override void Update()
}
}
+ ///
+ /// Fetches the image and applies it to tile material.
+ /// MapImage factory currently supports both new (RasterTile) and classic (ClassicRasterTile) Mapbox styles.
+ ///
+ ///
private void Run(UnityTile tile)
{
if (!string.IsNullOrEmpty(_mapId))
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MeshFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MeshFactory.cs
index 39b1897f9..8f1d190eb 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MeshFactory.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MeshFactory.cs
@@ -7,6 +7,10 @@ namespace Mapbox.Unity.MeshGeneration.Factories
using Mapbox.Unity.MeshGeneration.Interfaces;
using Mapbox.Platform;
+ ///
+ /// Uses vector tile api to visualize vector data.
+ /// Fetches the vector data for given tile and passes layer data to layer visualizers.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Factories/Mesh Factory")]
public class MeshFactory : Factory
{
@@ -17,6 +21,10 @@ public class MeshFactory : Factory
private Dictionary _tiles;
private Dictionary> _layerBuilder;
+ ///
+ /// Sets up the Mesh Factory
+ ///
+ ///
public override void Initialize(IFileSource fs)
{
base.Initialize(fs);
@@ -42,6 +50,10 @@ public override void Register(UnityTile tile)
Run(tile);
}
+ ///
+ /// Mesh Factory waits for both Height and Image data to be processed if they are requested
+ ///
+ ///
private void Run(UnityTile tile)
{
if (tile.HeightDataState == TilePropertyState.Loading ||
@@ -68,6 +80,12 @@ private void ImageDataChangedHandler(UnityTile t, object e)
CreateMeshes(t, e);
}
+
+ ///
+ /// Fetches the vector data and passes each layer to relevant layer visualizers
+ ///
+ ///
+ ///
private void CreateMeshes(UnityTile tile, object e)
{
tile.HeightDataChanged -= HeightDataChangedHandler;
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/TerrainFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/TerrainFactory.cs
index 569b3b893..72ad51f43 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/TerrainFactory.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/TerrainFactory.cs
@@ -22,6 +22,9 @@ public enum MapIdType
Custom
}
+ ///
+ /// Uses Mapbox Terrain api and creates terrain meshes.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Factories/Terrain Factory")]
public class TerrainFactory : Factory
{
@@ -57,6 +60,9 @@ public override void Register(UnityTile tile)
Run(tile);
}
+ ///
+ /// Clears the mesh data and re-runs the terrain creation procedure using current settings. Clearing the old mesh data is important as terrain stitching function checks if the data exists or not.
+ ///
public override void Update()
{
base.Update();
@@ -69,7 +75,7 @@ public override void Update()
Run(tile);
}
}
-
+
private void Run(UnityTile tile)
{
if (_generationType == TerrainGenerationType.Height)
@@ -86,6 +92,11 @@ private void Run(UnityTile tile)
}
}
+ ///
+ /// Creates the non-flat terrain using a height multiplier
+ ///
+ ///
+ /// Multiplier for queried height value
private void CreateTerrainHeight(UnityTile tile, float heightMultiplier = 1)
{
if (tile.HeightData == null)
@@ -120,6 +131,12 @@ private void CreateTerrainHeight(UnityTile tile, float heightMultiplier = 1)
}
}
+ ///
+ /// Creates the non-flat terrain mesh, using a grid by defined resolution (_sampleCount). Vertex order goes right & up. Normals are calculated manually and UV map is fitted/stretched 1-1.
+ /// Any additional scripts or logic, like MeshCollider or setting layer, can be done here.
+ ///
+ ///
+ /// Multiplier for queried height value
private void GenerateTerrainMesh(UnityTile tile, float heightMultiplier)
{
var go = tile.gameObject;
@@ -144,7 +161,6 @@ private void GenerateTerrainMesh(UnityTile tile, float heightMultiplier)
(int)((1 - yrat) * 255)),
tile.RelativeScale),
(float)(yy - tile.Rect.Center.y)));
- mesh.Normals.Add(Vector3.up);
mesh.UV[0].Add(new Vector2(x * step, 1 - (y * step)));
}
}
@@ -205,6 +221,11 @@ private void GenerateTerrainMesh(UnityTile tile, float heightMultiplier)
//go.layer = LayerMask.NameToLayer("terrain");
}
+ ///
+ /// Creates a basic quad to be used as flat base mesh. Normals are up and UV is fitted to quad.
+ /// A quad is enough for basic usage but the resolution should be increased if any mesh deformation, like bending, to work.
+ ///
+ ///
private void CreateFlatMesh(UnityTile tile)
{
var mesh = new Mesh();
@@ -236,6 +257,11 @@ private void CreateFlatMesh(UnityTile tile)
//go.layer = LayerMask.NameToLayer("terrain");
}
+ ///
+ /// Checkes all neighbours of the given tile and stitches the edges to achieve a smooth mesh surface.
+ ///
+ ///
+ ///
private void FixStitches(UnityTile tile, MeshData tmesh)
{
_stitchTarget.Set(tile.TileCoordinate.x, tile.TileCoordinate.y - 1);
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Interfaces/LayerVisualizerBase.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Interfaces/LayerVisualizerBase.cs
index 9f14e9b5b..cbf24f10c 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Interfaces/LayerVisualizerBase.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Interfaces/LayerVisualizerBase.cs
@@ -4,6 +4,9 @@ namespace Mapbox.Unity.MeshGeneration.Interfaces
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Data;
+ ///
+ /// Layer visualizers contains sytling logic and processes features
+ ///
public abstract class LayerVisualizerBase : ScriptableObject
{
public bool Active = true;
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs
index aedacab18..19b2e4108 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs
@@ -17,6 +17,16 @@ public class TypeVisualizerTuple
public ModifierStackBase Stack;
}
+
+ ///
+ /// VectorLayerVisualizer is a specialized layer visualizer working on polygon and line based vector data (i.e. building, road, landuse) using modifier stacks.
+ /// Each feature is preprocessed and passed down to a modifier stack, which will create and return a game object for that given feature.
+ /// Key is the name of the layer to be processed.
+ /// Classification Key is the property name to be used for stack selection.
+ /// It also supports filters; objects that goes over features and decides if it'll be visualized or not.
+ /// Default Stack is the stack that'll be used for any feature that passes the filters but isn't matched to any special stack.
+ ///
+ ///
[CreateAssetMenu(menuName = "Mapbox/Layer Visualizer/Vector Layer Visualizer")]
public class VectorLayerVisualizer : LayerVisualizerBase
{
@@ -44,6 +54,11 @@ public override string Key
private GameObject _container;
+ ///
+ /// Creates an object for each layer, extract and filter in/out the features and runs Build method on them.
+ ///
+ ///
+ ///
public override void Create(VectorTileLayer layer, UnityTile tile)
{
_container = new GameObject(Key + " Container");
@@ -88,9 +103,14 @@ public override void Create(VectorTileLayer layer, UnityTile tile)
}
}
+ ///
+ /// Preprocess features, finds the relevant modifier stack and passes the feature to that stack
+ ///
+ ///
+ ///
+ ///
private void Build(VectorFeatureUnity feature, UnityTile tile, GameObject parent)
{
-
if (feature.Properties.ContainsKey("extrude") && !bool.Parse(feature.Properties["extrude"].ToString()))
return;
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs
index 224ce95d7..fa88cca0f 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapController.cs
@@ -8,6 +8,9 @@ namespace Mapbox.Unity.MeshGeneration
using Mapbox.Unity.Utilities;
using Utils;
+ ///
+ /// MapController is just an helper class imitating the game/app logic controlling the map. It creates and passes the tiles requests to MapVisualization.
+ ///
public class MapController : MonoBehaviour
{
public static RectD ReferenceTileRect { get; set; }
@@ -27,6 +30,9 @@ public class MapController : MonoBehaviour
private GameObject _root;
private Dictionary _tiles;
+ ///
+ /// Resets the map controller and initializes the map visualization
+ ///
public void Awake()
{
MapVisualization.Initialize(MapboxAccess.Instance);
@@ -38,6 +44,9 @@ public void Start()
Execute();
}
+ ///
+ /// Pulls the root world object to origin for ease of use/view
+ ///
public void Update()
{
if (_snapYToZero)
@@ -58,6 +67,13 @@ public void Execute()
Execute(double.Parse(parm[0]), double.Parse(parm[1]), Zoom, Range);
}
+ ///
+ /// World creation call used in the demos. Destroys and existing worlds and recreates another one.
+ ///
+ /// Latitude of the requested point
+ /// Longitude of the requested point
+ /// Zoom/Detail level of the world
+ /// Tiles to load around central tile in each direction; west-north-east-south
public void Execute(double lat, double lng, int zoom, Vector4 frame)
{
//frame goes left-top-right-bottom here
@@ -104,6 +120,11 @@ public void Execute(double lat, double lng, int zoom, int range)
Execute(lat, lng, zoom, new Vector4(range, range, range, range));
}
+ ///
+ /// Used for loading new tiles on the existing world. Unlike Execute function, doesn't destroy the existing ones.
+ ///
+ /// Tile coordinates of the requested tile
+ /// Zoom/Detail level of the requested tile
public void Request(Vector2 pos, int zoom)
{
if (!_tiles.ContainsKey(pos))
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapVisualization.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapVisualization.cs
index 525289c93..5d575b1fd 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapVisualization.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/MapVisualization.cs
@@ -12,6 +12,10 @@ public class MapVisualization : ScriptableObject
{
public List Factories;
+ ///
+ /// Initializes the factories by passing the file source down, which's necessary for data (web/file) calls
+ ///
+ ///
public void Initialize(IFileSource fs)
{
foreach (Factory fac in Factories.Where(x => x != null))
@@ -20,6 +24,10 @@ public void Initialize(IFileSource fs)
}
}
+ ///
+ /// Registers requested tiles to the factories
+ ///
+ ///
public void ShowTile(UnityTile tile)
{
foreach (var fac in Factories.Where(x => x != null))
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/GameObjectModifiers/TextureModifier.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/GameObjectModifiers/TextureModifier.cs
index e40e1592c..12a095abf 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/GameObjectModifiers/TextureModifier.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/GameObjectModifiers/TextureModifier.cs
@@ -3,6 +3,10 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Components;
+ ///
+ /// Texture Modifier is a basic modifier which simply adds a TextureSelector script to the features.
+ /// Logic is all pushed into this TextureSelector mono behaviour to make it's easier to change it in runtime.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Texture Modifier")]
public class TextureModifier : GameObjectModifier
{
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs
index d41131d46..084580d3a 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MergedModifierStack.cs
@@ -10,6 +10,11 @@
namespace Mapbox.Unity.MeshGeneration.Modifiers
{
+ ///
+ /// Merged Modifier Stack, just like regular Modifier stack, creates a game object from features. But the difference is, regular modifier stack creates a game object for each given faeture meanwhile Merged Modifier Stack merges meshes and creates one game object for all features (until the 65k vertex limit).
+ /// It has extremely higher performance compared to regular modifier stack but since it merged all entities together, it also loses all individual entity data & makes it harder to interact with them.
+ /// It pools and merges objects based on the tile contains them.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Merged Modifier Stack")]
public class MergedModifierStack : ModifierStackBase
{
@@ -51,7 +56,6 @@ public override GameObject Execute(UnityTile tile, VectorFeatureUnity feature, M
private GameObject CreateGameObject(MeshData data, GameObject main)
{
- //Debug.Log("building count " + _buildingCount[tile]);
var go = new GameObject();
var mesh = go.AddComponent().mesh;
var rend = go.AddComponent();
@@ -84,7 +88,6 @@ private GameObject CreateGameObject(MeshData data, GameObject main)
public GameObject End(UnityTile tile, GameObject parent)
{
-
var md = new MeshData();
md.UV = new List>() { new List(), new List() };
md.Triangles = new List>() { new List(), new List() };
@@ -111,7 +114,6 @@ public GameObject End(UnityTile tile, GameObject parent)
_cached[tile].Clear();
return go;
}
-
}
return 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..f6dc2d6f2 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ChamferModifier.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/ChamferModifier.cs
@@ -4,6 +4,10 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Data;
+ ///
+ /// Chamfer modifiers adds an extra vertex and a line segmet at each corner, making corners and line smoother.
+ /// Generally used for smoother building meshes and should be used before Polygon Mesh Modifier.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Chamfer Modifier")]
public class ChamferModifier : MeshModifier
{
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..b8a281063 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/HeightModifier.cs
@@ -11,6 +11,11 @@ public enum ExtrusionType
FirstMidTopFloor
}
+ ///
+ /// Height Modifier is responsible for the y axis placement of the feature. It pushes the original vertices upwards by "height" value and creates side walls around that new polygon down to "min_height" value.
+ /// It also checkes for "ele" (elevation) value used for contour lines in Mapbox Terrain data.
+ /// Height Modifier also creates a continuous UV mapping for side walls.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Height Modifier")]
public class HeightModifier : MeshModifier
{
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..294172414 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/LineMeshModifier.cs
@@ -5,6 +5,11 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Data;
+ ///
+ /// Line Mesh Modifier creates line polygons from a list of vertices. It offsets the original vertices to both sides using Width parameter and triangulates them manually.
+ /// It also creates tiled UV mapping using the line length.
+ /// MergeStartEnd parameter connects both edges of the line segment and creates a closed loop which is useful for some cases like pavements around a building block.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Line Mesh Modifier")]
public class LineMeshModifier : MeshModifier
{
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..3ae3edc2d 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/PolygonMeshModifier.cs
@@ -7,6 +7,10 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Data;
+ ///
+ /// Polygon modifier creates the polygon (vertex&triangles) using the original vertex list.
+ /// Currently uses Triangle.Net for triangulation, which occasionally adds extra vertices to maintain a good triangulation so output vertex list might not be exactly same as the original vertex list.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Polygon Mesh Modifier")]
public class PolygonMeshModifier : MeshModifier
{
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..6418f16bf 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/UvModifier.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/MeshModifiers/UvModifier.cs
@@ -4,6 +4,10 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers
using UnityEngine;
using Mapbox.Unity.MeshGeneration.Data;
+ ///
+ /// UV Modifier works only with (and right after) Polygon Modifier and not with Line Mesh Modifier.
+ /// If UseSatelliteRoof parameter is false, it creates a tiled UV map, otherwise it creates a stretched UV map.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/UV Modifier")]
public class UvModifier : MeshModifier
{
diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs
index ed25a0feb..5664175db 100644
--- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs
+++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Modifiers/ModifierStack.cs
@@ -6,6 +6,10 @@ namespace Mapbox.Unity.MeshGeneration.Modifiers
using Mapbox.Unity.MeshGeneration.Data;
using Mapbox.Unity.MeshGeneration.Components;
+ ///
+ /// Modifier Stack creates a game object from a feature using given modifiers.
+ /// It runs mesh modifiers, creates the game object and then run the game object modifiers.
+ ///
[CreateAssetMenu(menuName = "Mapbox/Modifiers/Modifier Stack")]
public class ModifierStack : ModifierStackBase
{