Hey guys,
I’d like to write a little block engine (like in minecraft) not because I wanna copy the game but to understand how it works and learn how it’s done. I assume that shouldn’t be a big issue using low poly models (same size, different textures) and place them pseudo-randomly into the scene.
But I don’t know how to improve my project any further. I do know that I may need some terrainQuads and I suggest LOD is certain by this amount of models. However the most important for me would be the get the Idea of how to deal with the random gerneration of the (infinite) map using models instead of textures only.
Ok first of all the staff that I made therefor:
- Block class (abstract, used to load model, set textures, set position, actions later on …)
- BlockGrass, BlockEarth, BlockWoodblock … (each extends Block, handle textures usage, convert to Spatial)
- MapReader (creates terrain based on a heightmap)
- A scene with my skybox
- Main (put all things together)
I read about seeds and their attributes but can’t imagine how this works on a heightmap.
So I tried to reach my aim by performing the next few steps:
- For the terrain I took the heightmap image width and set a custom value for the height.
- I looped all three axis and saved my coordinates to a Vector3f array. The y coordinate I got from the function getTrueHeightAtPoint() and let it snap to grid:
[java] int realY = (int) heightmap.getTrueHeightAtPoint(x + MAP_WIDTH / 2, z + MAP_WIDTH / 2);
int y = 0;
if (realY % Block.BLOCK_SIZE != 0) {
y = ((int) Math.round(realY % Block.BLOCK_SIZE)) * Block.BLOCK_SIZE; // SNAP TO GRID
}[/java]
- Added directionalLight to be able to see the models
- Looped array with Vector3f from MapReader
- Let yMin be 0 and yMax the y position of the current Vector3f (from MapReader)
- Loop y axis
Finished …
Can somebody help me get the right idea of what I have to learn, read trough or deal with in the editor?
PS: It is not the idea, that you have to present me the source code right away I mainly need some Ideas.
Thanks for any hint! I’d appreciate it.