Mesh Box Reference : Vertices / Triangles / UV / Normals

Mesh Box Reference Image

If you want to build a simple mesh box with scripts in Unity, this kind of image helped me to understand how it works..

Also have a look of the ChunkRender example,
how it builds the mesh by adding 4 vertices on each box face: ChunkRenderer

Main image ^
– Vertice locations / coordinates are shown: Vector3(x,y,z)

Part#2 : Lets build a simple mesh

What are we doing:
– Initialize vertex points array (it is a list of points in 3D space)
– Initialize triangle index array (this list tells Unity how to connect the points, to build a polygon face = triangle)
– Add 1st point to the vertex array (0,0,0)
– Add 2nd point to the vertex array (0,1,0)
– Add 3rd point to the vertex array (1,1,0)
– Now we have 3 points in 3D space..(but we cannot see anything, since we just have points..)
– Assign triangle list [0,1,2] (“connect the points”, we start from (0,0,0), then go to (0,1,0), then (1,1,0))
– Last step: Assign the points and triangle list to our Unity mesh (and then we have a visible mesh)

Download Source #1: (creating single triangle mesh with javascript)

– In the image we have 3 points (vertices), marked with white “x”
– Dotted lines are showing how we connect the points (clockwise), to build a polygon face (triangle)
– See also: http://en.wikipedia.org/wiki/Polygon_mesh#Elements_of_mesh_modeling


Our mesh box is actually build from bunch of triangles:

14 Comments + Add Comment

Leave a comment


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.