I’m trying to do a siemple mesh triangle. What happens is if a change the order of the triangle vertices the mesh view change.
Here’s the code:
void Start ()
{
MeshFilter filter = GetComponent ();
Mesh mesh = filter.mesh;
mesh.Clear ();
Vector3[] vertices=
{
new Vector3(0,0,0),
new Vector3(0,1,0),
new Vector3(1,0,0)
};
Vector3[] normals=
{
Vector3.forward,
Vector3.forward,
Vector3.forward
};
Vector2[] uVs=
{
new Vector2(0,0),
new Vector2(0,1),
new Vector2(1,0)
};
int[] triangles=
{
0,1,2 // if I change this to: 1,0,2 or 2,0,1 for example the mesh is now viewed // from the oposite perspective. It's like the normal of the triangle had changed its direction to backwards.
};
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.uv = uVs;
mesh.normals = normals;
mesh.RecalculateBounds ();
mesh.Optimize ();
}
I hope I had explained well.
Thanks.