So I’ve generated a mesh from code ala Minecraft and have this strange clipping problem that I can’t figure out. I’ve checked and re-checked the vertices, the winding order of the triangles, the UVs, and the normals (whether manually or via RecalculateNormals()), and everything looks correct, however, I feel like I’ve missed an obvious step.
Any advice on where to look?
Here’s a video: http://player.vimeo.com/video/42946293
Here’s some example code for one face of a cube:
# check to the right of a spot and see if it needs squares built upwards (i.e. the spot to the right is higher)
if (x+1 < len(chunkHeights, 0)):
if (chunkHeights[x,y] < chunkHeights[x+1, y]): # if the block to the right is higher...
total_blocks_up = chunkHeights[x+1,y] - chunkHeights[x,y]
for b in range(total_blocks_up): # block to the right could be several spots higher
# vertices for square
vertex_list.Push(Vector3(x+1, h+1*b, y+1))
vertex_list.Push(Vector3(x+1, h+1*b, y))
vertex_list.Push(Vector3(x+1, h+1+1*b, y))
vertex_list.Push(Vector3(x+1, h+1+1*b, y+1))
# uvs. (16 textures per side in the texture sheet)
uv_list.Push(Vector2(0/16.0, 15/16.0))
uv_list.Push(Vector2(1/16.0, 15/16.0))
uv_list.Push(Vector2(1/16.0, 1))
uv_list.Push(Vector2(0/16.0, 1))
# normals point due left. this is also what's generated by RecalculateNormals()
normal_list.Push(Vector3(1,0,0))
normal_list.Push(Vector3(1,0,0))
normal_list.Push(Vector3(1,0,0))
normal_list.Push(Vector3(1,0,0))
# triangle list in proper order
triangle_list.Push(1+i*4)
triangle_list.Push(0+i*4)
triangle_list.Push(3+i*4)
triangle_list.Push(3+i*4)
triangle_list.Push(2+i*4)
triangle_list.Push(1+i*4)
i += 1 # keep track of triangle order in a big list