I had fun with this for the past day or so (using my code as a base (but stole an idea or two from Schranz0r!). I found a few bugs in my original code postings - oops!).
Only exposed faces are added to the mesh, as expected.
I added an automatic chunking mechanism.
This means that a 16,16,16 map with a chunk size of 8,8,8 will generate 2x2x2 (eight) chunk meshes.
This reduced my 16x16x16 map generation from 10seconds to 1second!.
It seems the more triangles in a mesh, the longer it takes for GLBasic (or OpenGL) to generate and finalize the mesh.
Same total triangles, but as 1 mesh took 10+seconds, but as 8 different meshes, takes just over a second, total.
I included the project files as a zip, instead of posting each file (4 files) contents.
I tried commenting the main Voxel TYPE as best I could, so hopefully it is easy to follow and understand.
To Do:
- Perlin Noise Generator for MineCraft style landscapes
- UpdateVoxel(x,y,z, cubeType) -> To allow dynamic voxel editing. Will regenerate the affected chunk(s)
- Interface to delete or add a new voxel to the map, and display the new map
- Texture Map: Use an external texture map tool to design the voxel textures, allow multiple voxel types (dirt, grass), auto map the textures to the model