Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (499)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Terrain Question  (Read 3128 times)
0 Members and 1 Guest are viewing this topic.
Offline JustinC

Senior Newbie





« Posted 2012-04-02 02: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.
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #1 - Posted 2012-04-02 02: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?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline JustinC

Senior Newbie





« Reply #2 - Posted 2012-04-02 02: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!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #3 - Posted 2012-04-02 02: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.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline JustinC

Senior Newbie





« Reply #4 - Posted 2012-04-02 02: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.
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #5 - Posted 2012-04-02 02: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.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline JustinC

Senior Newbie





« Reply #6 - Posted 2012-04-02 02: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.
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #7 - Posted 2012-04-02 02: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?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline JustinC

Senior Newbie





« Reply #8 - Posted 2012-04-02 02: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?
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #9 - Posted 2012-04-02 02: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/

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JustinC

Senior Newbie





« Reply #10 - Posted 2012-04-02 02:41:49 »

Thank you for this and i will study hard.
Offline Danny02
« Reply #11 - Posted 2012-04-02 11: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
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (46 views)
2014-04-15 18:08:23

BurntPizza (42 views)
2014-04-15 03:46:01

UprightPath (58 views)
2014-04-14 17:39:50

UprightPath (40 views)
2014-04-14 17:35:47

Porlus (56 views)
2014-04-14 15:48:38

tom_mai78101 (79 views)
2014-04-10 04:04:31

BurntPizza (138 views)
2014-04-08 23:06:04

tom_mai78101 (238 views)
2014-04-05 13:34:39

trollwarrior1 (199 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!