Are there any elegant soloution to generate a simple-six sided cube, where each cube is made out of more than one face? The method I have used ended up a horrible and complicated mess of logic that is imopssible to follow and most likely to maintain. The algorithm should not generate reduntant vertices, and should output the indice list for the mesh as well.

The reason I need this is that the cubes vertices will be deformed depending on various factors, meaning that a simple six-faced cube will nto do.

  • \$\begingroup\$ What you mean by multifaced? Every cube has at least 6 faces. \$\endgroup\$
    – kravemir
    Aug 17, 2012 at 23:17
  • 1
    \$\begingroup\$ I suppose the term you're looking for is tesselation. \$\endgroup\$ Sep 17, 2012 at 10:35

1 Answer 1


The way I'd approach this is to first write an algorithm that generates the mesh for just one side of the cube - that is, just a square, subdivided into as many polygons as you want. This should be easy to get right since it's just a grid.

Run this six times to generate the six sides of the cube, then concatenate all the meshes together and weld the shared verts at the edges and corners. The welding can be accomplished by explicitly keeping track of the edges and corners of each square during the initial generation and concatenation phases and hard-coding the logic for which ones should be welded together, or it can be done by a generic algorithm that detects pairs of vertices within a certain distance of each other and welds them. (For the latter you'd probably want to build an octree or something to accelerate queries for nearby vertices, else the whole thing will be O(n^2), not good if you subdivide finely and have a lot of vertices.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .