summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs
diff options
context:
space:
mode:
authorSimon O'Shea <osheas1@wit.edu>2023-08-03 15:55:52 -0400
committerSimon O'Shea <osheas1@wit.edu>2023-08-03 15:55:52 -0400
commite6bd6d2c587c7bbe3aa5ef4fa72ebe91befb5c1f (patch)
tree271b1aff526e9d3980867ddcfc77180ccf4eeb97 /Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs
parent78c5f3689cacd3551b2cd0d020b9ffb7361dec54 (diff)
colored mesh made
have a single mesh that changes color based on keyboard input. needs to be made for each cell and have color based on cell-value
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/MeshTesting.cs53
1 files changed, 47 insertions, 6 deletions
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);
+ }
+ }
}