Hello again. I have started a project that will be somewhat like minecraft. The main problem I have right now is random terrain. I have an idea of how to do it, but I think it involves python, which I don’t know very well. The way I think it could be done, is to start with a base grid of cubes that will act as the ground. At the beginning of the game, an invisible cube (only so the player can’t see it) will move over the top of the ground. It will start in a random direction, and pick a new random direction every so often. When it goes over top of a cube on the ground, it will create one on top of it (the cube would be a few blocks higher than the ground). After a certain amount of cubes is created, it will be deleted, and the player created. I think this will work, but don’t know exactly how to do it. I would appreciate anyone’s help. Thanks!
You’ll definitely want to learn some Python if you want to make a terrain generator that is half way decent. For the implementation, I would suggest dividing up the world into segments (similar to how Notch used “chunks”) and then give each segment a terrain type. The types could be things like plains, mountains, forest, ocean, etc. Then have some statistics that define how each terrain type should behave, e.g. for a forest how many trees should be in a segment, what’s the average separation between them, and how much should the terrain height vary? Then using a random system, construct the terrain based on these parameters.
What you describe is very similar to procedural terrain and I think its you’re best bet. Procedural terrain is a way to generate pseudo random terrain based on equations, for every coordinate x,y it can return a z (height).
Oh and btw blender comes with a few different procedurals built in so it wouldn’t be too hard to code.
Minecraft uses procedural terrain. It uses 3d perlin noise. Using the X, y coordinates you can get an intensity value. Then, getting the z coordinate at that value you can get the density for block type. Add the offset for z position from sea level, you can ensure that the sky is empty and the ground is more dense.
Thanks for all the replies. I will definitely look into these solutions and how to make them work… which is my problem. Since I know little to no python, I have absolutely no idea how to do this. If anyone could write a small script or something to get me started with the terrain, it would be a huge help.
Actually, I just tried out my idea, and this is the result:
I just used a Cloud texture on the plane for the displacement map. One thing I didn’t think about, is how to generate a random cloud texture when the game starts, and how to apply the dupli-vert to the plane with the game engine. I’m not sure. Anyway, any input would be great.
Thanks for all the help!
Would it also be possible to use procedural textures for adding geometry to a subdivided plane? Then how would you get the information of the texture and apply it to the verts on the plane?
EDIT: stupid me, I never noticed there was a displace modifier.
I have read over the posts a few times in order to solve my problem. I decded to re-read yours because it seems to make the most sense (no offense to anyone else, and i appreciate all of the input ). Ok: you say split the terrrain into segments/chunks. Do you mean physically put it into segments, or just to come up with types that will make up the terrain? I think i understand the whole statistics idea:
Also, I’m not too sure what you mean by ‘random system.’ I still don’t know how to script this with python. That’s what I need the most help with. Any help with scripting this terrain generator would be amazing. Thanks.
The separation is more of an aid to help with managing the terrain from a coding aspect, not necessarily a physical separation.
You have the right idea for the terrain types. Just remember that the more parameters you come up with, the more control you’ll have over your system.
There are a lot of things you could do to implement the randomness part. As some people mentioned you could use a noise texture to generate a height map. For trees, if the terrain type should have 20% tree coverage, then you could just iterate through every grid in the segment and use the random function (e.g. if random.random() < .2: add a tree to this grid). Those are just a couple examples what you could do.