- Home /
Do mesh vertices have the same index as their corresponding normal?
For example, does the normal at mesh.normals[0] correspond to the vert at mesh.vertices[0]?
Answer by Owen-Reynolds · Aug 08, 2013 at 01:40 PM
Yes. Position, normal, UVs, ... are parallel arrays. [x] for any of them is data for vertex X.
You'd think there would just be a class vertexData_t. But the graphics card is much happier with simple arrays of basic data types, from before structs/classes were invented. Multiple simple arrays like this are the "official" format.
The Triangle array is the only one with arbitrary positions. T[3i] [3i+1] and [3i+2] can be the indexes of any triangle (but the clockwise/CCW order does matter for front/back face.) I assume Unity gathers them and makes tri-strips, so no point for you to optimize the order.
Thanks man. I wish I could vote you up, but I don't have enough reputation yet. I've been manually trying to set the edge normals on some tessellating terrain meshes because they're currently creating visible seams - without success :(