diff options
| author | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-04 14:06:01 -0400 |
|---|---|---|
| committer | dereelatwit <54997325+dereelatwit@users.noreply.github.com> | 2023-08-04 14:06:01 -0400 |
| commit | f815986c6325d91dcbd07dc5ebac476a50660227 (patch) | |
| tree | aab8b93bc0f680b615016fb83896bfb7636871c8 /Pathfinding Visualizer/Assets/Scripts | |
| parent | 4e7d3ec38ab42bd4524f4a28e9021061330c490c (diff) | |
| parent | e6bd6d2c587c7bbe3aa5ef4fa72ebe91befb5c1f (diff) | |
Merge branch 'main' of https://github.com/osheas1atwit/pathfinding-visualizer
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts')
| -rw-r--r-- | Pathfinding Visualizer/Assets/Scripts/Main.cs | 2 | ||||
| -rw-r--r-- | Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs | 53 |
2 files changed, 48 insertions, 7 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/Main.cs b/Pathfinding Visualizer/Assets/Scripts/Main.cs index a9d87e7..44e2212 100644 --- a/Pathfinding Visualizer/Assets/Scripts/Main.cs +++ b/Pathfinding Visualizer/Assets/Scripts/Main.cs @@ -13,7 +13,7 @@ public class Main : MonoBehaviour void Start() { // Create world - world = new LogicGrid(5, 5, 10f, new Vector3(-10, -30)); + world = new LogicGrid(5, 5, 10f, new Vector3(0, 0)); // Set default placement to Obstacle placementValue = -1; diff --git a/Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs b/Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs index 06c8090..5baba56 100644 --- a/Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs +++ b/Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs @@ -4,8 +4,12 @@ using UnityEngine; public class MeshTesting : MonoBehaviour { + + Material m_Material; + void Start() { + m_Material = GetComponent<Renderer>().material; Debug.Log("Mesh Testing"); @@ -13,14 +17,24 @@ public class MeshTesting : MonoBehaviour // Build required data-structures for triangle mesh - Vector3[] vertices = new Vector3[3]; - Vector2[] uv = new Vector2[3]; - int[] triangles = new int[3]; + Vector3[] vertices = new Vector3[4]; + Vector2[] uv = new Vector2[4]; + int[] triangles = new int[6]; - // Set vertices of polygon (triangle) + // Set vertices of polygon (2 triangles -> 1 quad) vertices[0] = new Vector3( 0, 0); - vertices[1] = new Vector3( 0, 100); - vertices[2] = new Vector3(100, 100); + vertices[1] = new Vector3( 0, 10); + vertices[2] = new Vector3(10, 10); + vertices[3] = new Vector3(10, 0); + + + + // UV index contains texture position that should match to vertex with same index + uv[0] = new Vector2(0, 0); + uv[1] = new Vector2(0, 1); + uv[2] = new Vector2(1, 1); + uv[3] = new Vector2(1, 0); + // Set order of indexes of vertices to draw polygon (v1 -> v2 -> v3 -> v1) // Note: always set clockwise, otherwise mesh will be facing backwards @@ -28,6 +42,9 @@ public class MeshTesting : MonoBehaviour triangles[1] = 1; triangles[2] = 2; + triangles[3] = 0; + triangles[4] = 2; + triangles[5] = 3; mesh.vertices = vertices; mesh.uv = uv; @@ -36,4 +53,28 @@ public class MeshTesting : MonoBehaviour GetComponent<MeshFilter>().mesh = mesh; } + + private void Update() + { + if(Input.GetKeyDown("1")) + { + Debug.Log("1"); + m_Material.color = Color.white; + //m_Material.SetColor("_Color", Color.white); + } + + if (Input.GetKeyDown("2")) + { + Debug.Log("2"); + m_Material.color = Color.black; + //m_Material.SetColor("_Color", Color.white); + } + + if (Input.GetKeyDown("3")) + { + Debug.Log("3"); + m_Material.color = Color.green; + //m_Material.SetColor("_Color", Color.white); + } + } } |
