/// <summary> /// Generates the line meshes. /// Meshes are built of indices. Every vertices x-position will contain a vertex list index. /// </summary> /// <returns>The line meshes.</returns> protected Mesh[] GenerateLineMeshes() { // Counter int indexCounter = 0; MeshBuilder meshBuilder = new MeshBuilder(MeshTopology.Lines); // Write all indices to the meshes for (int i = 0; i < this.master.hairData.m_pVertices.Length; i += 2) { // Check for space if (!meshBuilder.HasSpace(2)) { // Reset index counter indexCounter = 0; } Vector3[] vertices = new Vector3[2]; Vector3[] normals = new Vector3[2]; int[] indices = new int[2]; Vector2[] uvs = new Vector2[2]; // Add vertices for (int j = 0; j < 2; j++) { // Prepare data vertices[j] = new Vector3(this.master.hairData.m_LineIndices[i + j], 0, 0); normals[j] = Vector3.up; indices[j] = indexCounter + j; uvs[j] = Vector2.one; } // Add mesh data to builder meshBuilder.AddVertices(vertices, indices, uvs, normals); indexCounter += 2; } return(meshBuilder.GetMeshes()); }
/// <summary> /// Generates the triangle meshes. /// Meshes are built of indices. Every vertices x-position will contain a triangleindex buffer index. /// </summary> /// <returns>The triangle meshes.</returns> protected virtual Mesh[] GenerateTriangleMeshes() { // Counter int indexCounter = 0; MeshBuilder meshBuilder = new MeshBuilder(MeshTopology.Triangles); // Write all indices to the meshes for (int i = 0; i < this._master.hairData.m_TriangleIndices.Length; i += 6) { // Check for space if (!meshBuilder.HasSpace(6)) { // Reset index counter indexCounter = 0; } Vector3[] vertices = new Vector3[6]; Vector3[] normals = new Vector3[6]; int[] indices = new int[6]; Vector2[] uvs = new Vector2[6]; // Add vertices for (int j = 0; j < 6; j++) { // Prepare data vertices[j] = new Vector3(i + j, 0, 0); normals[j] = Vector3.up; indices[j] = indexCounter + j; uvs[j] = Vector2.one; } // Add mesh data to builder meshBuilder.AddVertices(vertices, indices, uvs, normals); indexCounter += 6; } return(meshBuilder.GetMeshes()); }
/// <summary> /// Generates the triangle meshes. /// Meshes are built of indices. Every vertices x-position will contain a triangleindex buffer index. /// </summary> /// <returns>The triangle meshes.</returns> protected virtual Mesh[] GenerateTriangleMeshes() { // Counter int indexCounter = 0; MeshBuilder meshBuilder = new MeshBuilder (MeshTopology.Triangles); // Write all indices to the meshes for (int i = 0; i < this._master.hairData.m_TriangleIndices.Length; i+=6) { // Check for space if (!meshBuilder.HasSpace(6)) { // Reset index counter indexCounter = 0; } Vector3[] vertices = new Vector3[6]; Vector3[] normals = new Vector3[6]; int[] indices = new int[6]; Vector2[] uvs = new Vector2[6]; // Add vertices for (int j = 0; j < 6; j++) { // Prepare data vertices[j] = new Vector3(i+j,0,0); normals[j] = Vector3.up; indices[j] = indexCounter+j; uvs[j] = Vector2.one; } // Add mesh data to builder meshBuilder.AddVertices(vertices, indices, uvs, normals); indexCounter += 6; } return meshBuilder.GetMeshes (); }
/// <summary> /// Generates the line meshes. /// Meshes are built of indices. Every vertices x-position will contain a vertex list index. /// </summary> /// <returns>The line meshes.</returns> protected Mesh[] GenerateLineMeshes() { // Counter int indexCounter = 0; MeshBuilder meshBuilder = new MeshBuilder (MeshTopology.Lines); // Write all indices to the meshes for (int i = 0; i < this.master.hairData.m_pVertices.Length; i+=2) { // Check for space if (!meshBuilder.HasSpace(2)) { // Reset index counter indexCounter = 0; } Vector3[] vertices = new Vector3[2]; Vector3[] normals = new Vector3[2]; int[] indices = new int[2]; Vector2[] uvs = new Vector2[2]; // Add vertices for (int j = 0; j < 2; j++) { // Prepare data vertices[j] = new Vector3(this.master.hairData.m_LineIndices[i+j],0,0); normals[j] = Vector3.up; indices[j] = indexCounter+j; uvs[j] = Vector2.one; } // Add mesh data to builder meshBuilder.AddVertices(vertices, indices, uvs, normals); indexCounter += 2; } return meshBuilder.GetMeshes (); }