Advertisement
Guest User

MeshData

a guest
Apr 13th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class MeshData
  6. {
  7.     public List<Vector3> vertices = new List<Vector3> ();
  8.     public List<int> triangles = new List<int> ();
  9.     public List<Vector2> uv = new List<Vector2> ();
  10.  
  11.     public List<Vector3> colVertices = new List<Vector3> ();
  12.     public List<int> colTriangles = new List<int> ();
  13.  
  14.     public bool useRenderDataForCol;
  15.  
  16.     public MeshData ()
  17.     {
  18.     }
  19.  
  20.     public void AddQuadTriangles ()
  21.     {
  22.         triangles.Add (vertices.Count - 4);
  23.         triangles.Add (vertices.Count - 3);
  24.         triangles.Add (vertices.Count - 2);
  25.  
  26.         triangles.Add (vertices.Count - 4);
  27.         triangles.Add (vertices.Count - 2);
  28.         triangles.Add (vertices.Count - 1);
  29.  
  30.         if (useRenderDataForCol) {
  31.             colTriangles.Add (colVertices.Count - 4);
  32.             colTriangles.Add (colVertices.Count - 3);
  33.             colTriangles.Add (colVertices.Count - 2);
  34.             colTriangles.Add (colVertices.Count - 4);
  35.             colTriangles.Add (colVertices.Count - 2);
  36.             colTriangles.Add (colVertices.Count - 1);
  37.         }
  38.     }
  39.  
  40.     public void AddVertex (Vector3 vertex)
  41.     {
  42.         vertices.Add (vertex);
  43.  
  44.         if (useRenderDataForCol) {
  45.             colVertices.Add (vertex);
  46.         }
  47.  
  48.     }
  49.  
  50.     public void AddTriangle (int tri)
  51.     {
  52.         triangles.Add (tri);
  53.  
  54.         if (useRenderDataForCol) {
  55.             colTriangles.Add (tri - (vertices.Count - colVertices.Count));
  56.         }
  57.     }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement