The big picture: Road map for our voxel engine.
1.) CHUNKS:
A chunk is a ‘block of blocks’ (a 16x16x16 cube of blocks in our case).
1A.) Make a “chunk mesh” generator. (A part of our program that turns voxel data into a JMonkey geometry object that can be shown on screen.)
—No landscape noise yet…so test this by making a solid dirt chunk and a ‘staircase of dirt’ chunk (only two kinds of blocks at this point: dirt and air) or some other silly configuration of blocks.
…time passes….
1B.) THE CHUNK CLASS/TERRAIN MAP CLASS: ’phew!’ we have a mesh generator. It can take any combination of voxels in a 16x16x16 chunk and turn it into geometry. We plan to create a lot of these to make a landscape out of them, and we should take some steps to get organized. What we want is an easy way of getting the geometry at a 3D point—for example, (337,45, -1052) or any arbitrary point (x, y, z). There might be a number of ways to keep track of our chunks but we will do so with the following scheme:
THE MAP SCHEME:
MAP SCHEME part 1) CHUNK: We will create a class called: “Chunk.” (no need to get creative with our name for it). It will own a reference to its Geometry. This way, elsewhere, we’ll be able to say:
rootNode.addChild(chunk.getGeometry()); //nice and clean!
MAP SCHEME part 2) COORDINATES: We need an easy way of grabbing any chunk at any given X,Y,Z. To facilitate this, we are going to use a java “collection class” called a “HashMap.” We will explore the details of HashMaps later but for now, think of a hash map as a big set of cubby holes. We need a way of referring to any one of these cubby holes, so we will “name” each of them (maybe not surprisingly) after the X,Y,Z coordinate of the Chunk that it holds.
And yet…the “name” won’t be a “normal” name. Instead, we’ll make another class, which will call COORD, whose only purpose will be to hold three X,Y and Z coordinates (as three “ints”).
MAP SCHEME part 3) TERRAIN MAP: The terrain map will be responsible for managing, owning and granting access to the HashMap of chunks. Elsewhere in the voxel engine, you’ll be able to get any chunk you might want by asking the terrainMap for a “chunk at coord.” The code will look something like:
Chunk someChunk = terrainMap.getChunkAt(someCoord);
The point of having a terrain map class is to relieve the rest of your code of the job of looking up chunks and consolidate all of the look-up logic in one place.
Next up: Noise
2.) NOISE:
Coherent noise allows us to generate random numbers that change in smooth increments. We’ll use a library called “Joise” (Java noise) to generate noise that mimics a the contours of a landscape.
3.) STRUCTURES:
Trees, temples, ??
4.) INTERACTING WITH THE LANDSCAPE:
4A.) Collisions
4B.) Breaking and placing blocks.
Beyond the basics….
Mobs, efficiency, multi threading and world expansion