Terrain Question

So i have spent 3 days looking for open source for heightmap/landscape/terrain loaders and cant find anything besides engines like Xith3D or JmonkeyEngine to load these. However i wish to create my own.

I need help with loading a the heightmap, if i could have a little help with this i would be forever grateful. This is one of my only problems i have had along the way.

So… what bit are you having problems with? Are you loading from an existing heightmap file format, or do you want to make your own? Have you managed to get a flat terrain grid drawing (without loading any heights)? What kind of terrain are you aiming for?

So… what bit are you having problems with?
I am having problems with getting the heightmap/terrain loaded.

Are you loading from an existing heightmap file format, or do you want to make your own?
I think i have my own, is a heightmap a 2d image? If not i can easily make a heightmap through a program.

Have you managed to get a flat terrain grid drawing (without loading any heights)?
Yes, i have a 3d system with a flat floor with 8x8 textures.

What kind of terrain are you aiming for?
Just a simple one for now with a few hills so i can test with it an later make a real one that will be used.
3D terrain i meant to add.

Ok, so you want to store your heightmap as a greyscale image and convert colour to height?

If so that’s pretty simple - what’s causing you trouble? Load your image with ImageIO, then pull out the rgb value at each pixel, average the rgb to get a brightness, then convert the brightness into a height value.

Its a 3D heightmap, what would be the commands for this. This is why i wanted an open source, i cant really find anything for heightmaps open source.

There are no commands to make a heightmap, you have to make it yourself out of triangles. If you already have a flat floor then you know how to draw triangles - a heightmap is just a grid of triangles with different heights.

Maybe try and get a flat grid of triangles drawing first, with random colours at each point or something. Then adding heights from an image file will be easy.

floorDisplayList = glGenLists(1);
        glNewList(floorDisplayList, GL_COMPILE);
	        glBegin(GL_QUADS);
		        glTexCoord2f(0, 0);
		        	glVertex3f(-gridSize, floorHeight, -gridSize);
		        glTexCoord2f(0, gridSize * 10 * tileSize);
		        	glVertex3f(-gridSize, floorHeight, gridSize);
		        glTexCoord2f(gridSize * 10 * tileSize, gridSize * 10 * tileSize);
		        	glVertex3f(gridSize, floorHeight, gridSize);
		        glTexCoord2f(gridSize * 10 * tileSize, 0);
		        	glVertex3f(gridSize, floorHeight, -gridSize);
	        glEnd();
        glEndList();

Is what im using.

Ok, so that draws a single quad - have you tried changing that code so you get a grid of quads? What have you tried?

No i havent, i got that piece of code from a tutorial which i have analyzed well. I am really despirate for this, is it possible we can communicate via a messenger?

I think a heightmap may be a little beyond your abilities right now. I suggest you start from the beginning with the opengl red book: http://www.glprogramming.com/red/

Thank you for this and i will study hard.

just to add something for others searching how to render a highmap.

  • render a normal grid(like a chess board) where each grid point gets its Y(UP) value from some dataset(i.e. a texture which can be read from a vertex shader)
  • to get the normal for each grid point, calculate the sobel gradient(google it) from the height dataset around this point