JustinC
Senior Newbie 
|
 |
«
Posted
2012-04-02 00:06:23 » |
|
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.
|
|
|
|
Orangy Tang
|
 |
«
Reply #1 - Posted
2012-04-02 00:14:06 » |
|
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?
|
|
|
|
JustinC
Senior Newbie 
|
 |
«
Reply #2 - Posted
2012-04-02 00:17:33 » |
|
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.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Orangy Tang
|
 |
«
Reply #3 - Posted
2012-04-02 00:22:31 » |
|
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.
|
|
|
|
JustinC
Senior Newbie 
|
 |
«
Reply #4 - Posted
2012-04-02 00:24:53 » |
|
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.
|
|
|
|
Orangy Tang
|
 |
«
Reply #5 - Posted
2012-04-02 00:28:47 » |
|
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.
|
|
|
|
JustinC
Senior Newbie 
|
 |
«
Reply #6 - Posted
2012-04-02 00:31:06 » |
|
1 2 3 4 5 6 7 8 9 10 11 12 13
| 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.
|
|
|
|
Orangy Tang
|
 |
«
Reply #7 - Posted
2012-04-02 00:34:21 » |
|
Ok, so that draws a single quad - have you tried changing that code so you get a grid of quads? What have you tried?
|
|
|
|
JustinC
Senior Newbie 
|
 |
«
Reply #8 - Posted
2012-04-02 00:38:27 » |
|
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?
|
|
|
|
Orangy Tang
|
 |
«
Reply #9 - Posted
2012-04-02 00:40:40 » |
|
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/
|
|
|
|
Games published by our own members! Check 'em out!
|
|
JustinC
Senior Newbie 
|
 |
«
Reply #10 - Posted
2012-04-02 00:41:49 » |
|
Thank you for this and i will study hard.
|
|
|
|
Danny02
|
 |
«
Reply #11 - Posted
2012-04-02 09:44:22 » |
|
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
|
|
|
|
|