Results 1 to 6 of 6

Thread: Heightmapped Terrain

  1. #1
    Member Newbie
    Join Date
    Jan 2010
    Location
    Mars
    Posts
    30

    Heightmapped Terrain

    Hello everyone.

    I am new to this forum and I have a problem regarding OpenGL heightmaps.
    My goal is to create an image reading function then create a 3D terrain from the image read.

    I am using the SOIL library , which does come with a heightmap function, but I am not sure what it does. Here is the 'help file':

    /* load an image as a heightmap, forcing greyscale (so channels should be 1) */
    int width, height, channels;
    unsigned char *ht_map = SOIL_load_image
    (
    "terrain.tga",
    &width, &height, &channels,
    SOIL_LOAD_L
    );
    I could probably work out drawing code from an array, but how do I load an image into an array?

    If anyone knows anything about the SOIL library, or a useable alternative, please help.

    Thanks in advance

    mikeynovemberoscar

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2009
    Location
    French
    Posts
    117

    Re: Heightmapped Terrain

    You can load the tga file using a tga loader with something like

    http://nehe.gamedev.net/data/lessons....asp?lesson=24

    and make your terrain such as width x height quads when the (x,y,z) values of vertices are (x,y,imageData[y*width+x]) where 0<=x<width and 0<=y<height.

    The imageData[y*width+x] is now the height of the vertex at the position (x,y)
    (but this work only with a greyscale file, with a rgb file you can handle something like a displacement map with x,y,z=r,g,b )

    Something, it's exactely the type of things that I project to make using geometry/vertex/fragment shaders and/or instanciation or something like this for to can use a basic quad (or very more that only one ...) where I can easily bumpmap and display a video stream on it (for to handle realistics animated waves for example).

    @+
    Yannoo
    @+
    Yannoo

  3. #3
    Member Newbie
    Join Date
    Jan 2010
    Location
    Mars
    Posts
    30

    Re: Heightmapped Terrain

    Thankyou very much, this was just what I was looking for. I read one nehe tutorial which was designed for windows and just assumed they were all.

    P.S. I'm a MAC

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2009
    Location
    French
    Posts
    117

    Re: Heightmapped Terrain

    There is a Mac OS X/Cocoa version at the end of the page.

    And you can too use gcc and/or g++ with a makefile on MacOS

    Here is a makefile that I use with gcc and g++ on the MacOS plateform with SDL, GLUT and AVCODEC libraries


    all : vdj vdj2

    frameworks = -framework SDL -framework Cocoa -framework GLUT -framework OpenGL
    includes = -I/Library/Frameworks/SDL.framework/Headers
    links = -L/usr/local/lib -lavcodec -lavutil -lavformat -lswscale -lz -lbz2 -I/usr/local/include/ffmpeg/

    vdj : vdj.* shader.* avread.h cube.*
    gcc $(includes) vdj.c SDLmain.m shader.c cube.c $(frameworks) -o vdj $(links)

    vdj2 : vdj.* shader.* avread.h cube.*
    g++ $(includes) vdj.c SDLmain.m shader.c cube.c $(frameworks) -o vdj2 $(links) -D__STDC_CONSTANT_MACROS

    clean :
    rm vdj vdj2

    (this is for a program that display/mix in real time various audio/video files/streams on a 3D rotated cube)

    You can find alls frameworks (and a lot of others) at http://www.macports.org


    @+
    Yannoo

    @+
    Yannoo

  5. #5
    Member Newbie
    Join Date
    Jan 2010
    Location
    Mars
    Posts
    30

    Re: Heightmapped Terrain

    Thankyou for the advice. I am actually using Xcode but I have solved my problem now.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Aug 2009
    Posts
    126

    Re: Heightmapped Terrain

    NEHE Lesson 45 also loads a heightmap, you could check it out to "extend" your own loader if you want


    ^^


Similar Threads

  1. Terrain Generation / Displaying terrain
    By _Syndic in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 05-06-2013, 04:29 AM
  2. Terrain
    By Rodrix in forum OpenGL: Advanced Coding
    Replies: 31
    Last Post: 09-14-2006, 10:25 AM
  3. Multitexturing a heightmapped terrain
    By Ganymede in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-15-2002, 10:37 AM
  4. Terrain And Fog
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-19-2002, 07:05 AM
  5. Terrain
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-30-2001, 04:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean