Generating terrain

Hello guys,

Is it possible to generate terrain at runtime ? For example by loading heightmap ?
Is there any tutorial or some documentation with this problem?

Thanks for your answers

Yes you can, but you shouldn’t.
The problem is in how you solve the logic/physics calculations.

These are based of the things i have done:

  1. Fastest: shader.
    This is the most efficient i believe.
    Harder to code, but even I could write a shader that deformed a mesh based on it’s texture.
    But collision detection doesn’t work.
    Only visual.

2)Python vertex manipulation.
Slow, but you have much more control.
Probably could get raycasts and collision working on the changed mesh.

3)Socket calls to instances of blender( modelling part ) to create the meshes outside of the game,
and then libload them to the game.
Very complex, but result is as good as pre done maps.

I’ve done it before using blender 2.49 and it ran ok. There’s a lot of research to do in this area though if you want to get it to work well.

some general tips:
You will need python. This can’t be done only with logic bricks if you want it to be random.
Get the verts from the mesh by xyzposition not index order.
dont use textures or bitmaps, instead work with arrays.
Find some general procedural generators like perlin noise or cellular automata to drive your terrain generation. There are python examples around if you look for them.
Spend some time getting to know the poly proxy and vertex proxy API. It’s not easy at first but once you get in to it you can do almost anything.
Good luck, I invested a lot of time in this area, but it was worth it. Good procedurally generated terrain is often even better than hand modeled meshes.

Is it possible to generate terrain at runtime ?

depending on just WHAT the terrain is and how big you need it
Blender might not be a good tool

for example if you need something bigger that a 2048x2048 pixel area a blender 2kx 2k mesh is BIG
and a smallish 8192x4096 grid might not load in blender
but a a raster image is only 50 meg VS 8 Gig for a mesh

For example by loading heightmap ?

as in NOT using blender to create it
say a small 8192x4096 world map created using Wilbur
then rendering it is Blender ?
if so you will need 24+ gig of ram

or
a tiny 256 x256 grid ?

Is there any tutorial or some documentation with this problem?

without knowing more details ???

just a random GUESS so…
use the plugin " import image as plain"
then use the 32 bit floating point “heightmap” as a displacement map

for example like this i posted on a different forum
http://6.t.imgbox.com/qWU8Xn3v.jpg http://1.t.imgbox.com/2TUQLJ7A.jpg
that above is only a very small 512 x512 grid well 514x514 with the edges this is 343 Meg

You could avoid that problem if you create a samller “mesh-grid” and place it as a prefab in an inactive layer.
When you process the (bigger) hightmap image and exceed the width/height of your mesh just addObject a new copy, place it next to the previous one and adjust the vertex hight to mathch the last row of vertexes of the former mesh.
This would also harmonize with a LOD system in which you unload parts of the map that are far away.