CombineInstanceIndexes.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace LunarCatsStudio.SuperCombiner
  4. {
  5. /// <summary>
  6. /// The combine instance indexes of vertex and triangles
  7. /// </summary>
  8. [System.Serializable]
  9. public class CombineInstanceIndexes
  10. {
  11. // Index of the first vertex in mesh.vertices
  12. public int firstVertexIndex;
  13. // The vertexcount
  14. public int vertexCount;
  15. // Index of the first triangle in mesh.triangles
  16. public int firstTriangleIndex;
  17. // The trianglecount
  18. public int triangleCount;
  19. // Editor display parameter
  20. public bool showCombinedInstanceIndex;
  21. /// <summary>
  22. /// Constructor
  23. /// </summary>
  24. /// <param name="mesh"></param>
  25. /// <param name="vertexIndex"></param>
  26. /// <param name="trianglesIndex"></param>
  27. public CombineInstanceIndexes(Mesh mesh, int vertexIndex, int trianglesIndex)
  28. {
  29. vertexCount = mesh.vertexCount;
  30. firstVertexIndex = vertexIndex;
  31. triangleCount = mesh.triangles.Length;
  32. firstTriangleIndex = trianglesIndex;
  33. }
  34. /// <summary>
  35. /// Offset first indexes for vertices and triangles
  36. /// </summary>
  37. /// <param name="vertexOffset"></param>
  38. /// <param name="triangleOffset"></param>
  39. public void MoveIndexes(int vertexOffset_p, int triangleOffset_p)
  40. {
  41. firstVertexIndex -= vertexOffset_p;
  42. firstTriangleIndex -= triangleOffset_p;
  43. }
  44. }
  45. }