Random heightmap/texture generator

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Random heightmap/texture generator

Post by RayOfAsh »

Does anyone know of a heightmap/texture generator that works with IrrLicht? I want to generate terrains, textures for them, and then apply them to a sphere. Something like Populous.
Image
Virion
Competition winner
Posts: 2148
Joined: Mon Dec 18, 2006 5:04 am

Post by Virion »

You can try Terragen.
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Post by RayOfAsh »

Virion wrote:You can try Terragen.
I want the program I'm making to generate them on the fly. Terragen would be nice if I wanted to make a huge amount of them, but I could just create hundreds of perlin noise clouds in Photoshop for that. I want my program to generate random heightmaps on the fly.

Okay, I took the 2D code from this: http://freespace.virgin.net/hugo.elias/ ... perlin.htm and got it to compile without warnings or errors.

Now how on earth do I use it? When I print the results of PerlinNoise2D it's always something like -0.33399 .
Image
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Post by RayOfAsh »

Nobody can help me? I want to use it to generate a heightmap (preferably in text for easy storage, I plan on making a lot of these) and then applying it to a 3D model (sphere). It will look like something from Populous.
Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

that's one value. i guess you need to do that for each pixel
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Post by RayOfAsh »

bitplane wrote:that's one value. i guess you need to do that for each pixel
I thought maybe that was it, how can I test to see if this is the case?

Edit: Okay, I currently have a 2 dimensional array (10 by 10) and I have a loop to fille it:

Code: Select all

void DrawGrid()
{
    for(int x = 0; x < 10; x++)
    {
        for(int y = 0; y < 10; y++)
        {
            map[x][y]=PerlinNoise2D(x, y);
        }
    }
}
And code to write it all out to a text file:

Code: Select all

    ofstream mapfile;
    mapfile.open("map.txt");
    for(int x = 0; x < 10; x++)
    {
        for(int y = 0; y < 10; y++)
        {
            mapfile << map[x][y] << '\n';
        }
    }
    mapfile.close();
Sample output:

Code: Select all

0.0371491
0.692023
0.496631
0.766835
-0.407069
-2.04812
-1.30434
-0.948782
-1.87947
-1.24445
-0.448668
-0.33399
-0.590847
-0.411724
-0.0696558
-0.462679
I have no idea what order it's in, I'm going to try to find a way to organise it.

Edit 3:

Here we go:

Code: Select all

[0][0]=0.0371491 
[0][1]=0.692023 
[0][2]=0.496631 
[0][3]=0.766835 
[0][4]=-0.407069 
[0][5]=-2.04812 
[0][6]=-1.30434 
[0][7]=-0.948782 
[0][8]=-1.87947 
[0][9]=-1.24445 
[1][0]=-0.448668 
[1][1]=-0.33399 
[1][2]=-0.590847 
[1][3]=-0.411724 
[1][4]=-0.0696558 
[1][5]=-0.462679 
[1][6]=0.0111715 
[1][7]=-0.171141 
[1][8]=-1.90765 
[1][9]=-1.0964 
[2][0]=-0.283585 
Nifty! Now how can I turn this into an image so I can see if it's working or not?

Also, I've got it generating a random seed now! Yay!
Image
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Post by RayOfAsh »

Is there a function to draw pixels in Irrlicht? How would I convert all these numbers to pixels?

Edit: How about that: http://libnoise.sourceforge.net/tutoria ... #heightmap

Edit 2: Stupid Code::Blocks never working:

.objs\main.o:main.cpp:(.text$_ZN5noise6module6PerlinD1Ev[noise::module::Perlin::~Perlin()]+0x16): undefined reference to `noise::module::Module::~Module()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)

I've linked to all the header files and libraries, what does it want from me?
Image
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

hey RayOfAsh

I'm getting the same general error compiling libnoise using Dev-C++.
I was able to get it to compile using Visual Studio 2005 by adding the libnoise.lib file to the Configuration Properties > Linker > Input list.
If I could get libnoise to work with Dev-C++, I'd be more likely to use it since I only have VS2005 on my work machine.

--Carl
Post Reply