- Home /
Procedual created mesh flipped (using clockwise ordered vertices(
Hi All,
Just starting out with procedual meshes. And seem to have bumped into a common problem but couldn't find the answer somewere else on the forum (or just suck at searching :p).
The answer that solves most peoples problem is that the vertices of triangles should be ordered clockwise. I'm doing this, but it still appears with 'flipped' normals. Hope someone can help a newbie out.
The code:
private void CreateRoomMesh()
{
MeshRenderer mr = gameObject.AddComponent<MeshRenderer>() as MeshRenderer;
MeshFilter mf = gameObject.AddComponent<MeshFilter>() as MeshFilter;
Vector3[] newVertices = new Vector3[] {
new Vector3(-1, 0, -1),
new Vector3(1, 0, -1),
new Vector3(1, 0, 1),
new Vector3(-1, 0, 1),
new Vector3(0, 2, 0)
};
//Vector2[] newUV;
int[] newTriangles = new int[] {
3,4,2,
0,4,3,
1,4,0,
2,4,1,
0,1,2,
2,3,0,
};
Mesh mesh = new Mesh();
mesh.vertices = newVertices;
mesh.triangles = newTriangles;
mf.mesh = mesh;
}
Also tried RecalculateNormals, Recalculate Bounds and Optimize but they didn't work for me.
Thank you guys!
Your answer
Follow this Question
Related Questions
Trouble with Inaccurate Mesh Collider 0 Answers
Applying UV to plane mesh is pixel imperfect. 0 Answers
How to colorize a face of a Mesh 0 Answers
creating a mesh procedurally 4 Answers
Easy way to convert a bunch of vertices to triangles or uv's? 1 Answer