Generating maps and loading them on runtime

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
pedrosal
Posts: 5
Joined: Tue Sep 20, 2005 12:01 pm

Generating maps and loading them on runtime

Post by pedrosal »

I posted this on Beginners also but I think it might be better here:

Hello,

I'm trying to find an algoritm to do this wit irrlicht:

1 - Have a binary 2d array on wich every position maps a world cell and the value of the byte indicates the type of terrain (Grass, land, rock).

2 - Have a bmp heightmap representing the y axis of the terrain. (And detail map, ...)

This is the solution I'm idealizing:

> Use the terrain APIs in irrlicht to generate the terrain mesh.
> Put all the textures on the same texture map and use the tu and tv components to select the right texture according to the type of terrain.

> Does anyone ever seen something like this done? Code samples?
> How can I alter the tu and tv coordinates of every point in the mess to point to the right texture?
> Any comments on the algorithm?

Thanks,
Pedro
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

Sounds pretty tricky.

An easier solution would be to choose 1 textue as the main texture (say grass, or dirt, or sand, whatever) and then make another texture and use it as a detail map. I've been experimenting with making a say 128x128 heightmap, then loading that map up in photoshop, blowing it up to like 512x512 and applying different layers to it, then fading in / out other texture maps (like rocks or grass) and drawing a path or road on the map where I want it to be. When I am satisfied with this map, I use the large map as a detail map on the terrrain. Note that the heightmap image is still 128x128, I only blow it up to get more detail on the detail map.

If you want to implement your idea, take a look at CTerrainSceneNode::ScaleTexture

It shows you how to set the u,v for each coordinate on a terrain node.
pedrosal
Posts: 5
Joined: Tue Sep 20, 2005 12:01 pm

Post by pedrosal »

Thanks pfo,

I will try to do as you say to test the concept. But imagine you want to be able to generate dinamic maps like the god old settlers. Have you ever played it? The only way I see to do that is by manipulating the detail map on runtime. Irrlicht has some good texture manipulation routines. So maybe it is possible... nothing like trying!

Pedro
Post Reply