I have a Ribbon object, which I am creating dynamically and appending quads to it's mesh each frame.
In order for it to remain visible as it twist due to backface-culling I have to have two meshes one with the normals facing one direction, and one with the normals facing the opposite direction (front/back).
Is it possible to have two meshes for one game object?
Here's how the mesh is created for reference:
mesh = new Mesh();
filter = GetComponent();
filter.mesh = mesh;
vertices = new Vector3[ len * 4 ];
vertices[0] = new Vector3(0, 0, 0);
vertices[1] = new Vector3(width, 0, 0);
vertices[2] = new Vector3(0, height, 0);
vertices[3] = new Vector3(width, height, 0);
mesh.vertices = vertices;
// Create two triangles pointing using the vertices array index positions
triangles = new int[ len * 6 ];
// 1
triangles[0] = 0;
triangles[1] = 2;
triangles[2] = 1;
// 2
triangles[3] = 2;
triangles[4] = 3;
triangles[5] = 1;
mesh.triangles = triangles;
// Create the normals all pointing outward
normals = new Vector3[ len * 4];
normals[0] = -Vector3.forward;
normals[1] = -Vector3.forward;
normals[2] = -Vector3.forward;
normals[3] = -Vector3.forward;
mesh.normals = normals;
// Create UV's at each corner
uvs = new Vector2[ len * 4];
uvs[0] = new Vector2(0, 0);
uvs[1] = new Vector2(1, 0);
uvs[2] = new Vector2(0, 1);
uvs[3] = new Vector2(1, 1);
mesh.uv = uvs;
↧