Page 1 of 1

Game Engine: Random terrain generation within BGE

Posted: Thu May 05, 2011 3:21 am
by MirceaKitsune
Hey everyone. I looked a bit at BGE today, and learned the basics of how it works. I wanna try doing something I had in mind for a while, but I'm not sure if there's any method of doing this... even a sloppy way of simulating it.

What I wanna do is have Blender Game Engine auto-generate a random terrain each time I start it up. So basically, I tell it the X and Y size of the flat plane (or specify an existing subdivided plane), then tell it the minimum and maximum Z axis by which it can randomize each vertex on it, as well as the polygon count of the terrain. Don't care if it can do overhead cliffs or not.

I heard that using Proportional Edit with random Falloff can generate such terrains. But I want BGE to do it each run automatically, not to be a real model. I also wish for the terrain to collide properly, and it should also generate a random layer map for mapping different terrain textures randomly (if possible, based on terrain height at a given spot). Preferably without a Python script, though that's ok if BGE can't do it on its own.

Is there any idea or tactic that can be used here? Has anyone got this working to any extent, and can share how they did it?

Posted: Thu May 05, 2011 7:09 am
by SolarLune
I did it here - it's a bit slow, but for your purposes, it might work alright.

Posted: Thu May 05, 2011 3:10 pm
by MirceaKitsune
SolarLune wrote:I did it here - it's a bit slow, but for your purposes, it might work alright.
Thank you, that is an useful script. Though sadly, it wouldn't work for what I'm looking for. The generated terrain is too spikey, even if the plane is Set Smooth. I'm aiming to generate smooth hills and such, without using a lot of vertices. I was hoping that with Set Smooth, the real vertices would be spikey, but the terrain would be rendered as fully smooth and maybe collide accordingly.

It also has issues with collisions, and collides in places it shouldn't and vice versa. Also takes a lot to generate huge terrains, which is one thing I was hoping I could do in a timely manner.

Perhaps other similar methods exist, that can do all these things? I'm thinking that maybe, instead of modifying the real vertices, it could generate a heightmap texture (using the cloud method), then render the terrain with that texture as an offset map. IIRC this should be possible to some extent, but I'm not sure if it includes collisions :(

[EDIT] I already found something that seems to do EXACTLY what I'm looking for. It's a script and blend file that someone posted over here. However, that script no longer works in Blender 2.5, and only in 2.4 :cry: But I tested it there and it's just what I'm looking for. Anyone know any 2.5 alternatives for achieving the exact same thing?