Results 1 to 6 of 6

Thread: HEIGHT MAP

  1. #1
    Member Contributor
    Join Date
    Mar 2002
    Location
    CA,USA
    Posts
    57

    HEIGHT MAP

    Hello,

    I am using MFC and OpenGL to display 3D surface.
    Now I want to highlight the difference in the height by using different colors...i.e each region having same height should have same color and there should be difference in the color...to display different height..
    So how should i go about it..

    I am using glBegin(GL_LINES) command to display the 3D mesh

    I need some help in this matter...

    Thanks
    aus

  2. #2
    Member Contributor
    Join Date
    Jul 2001
    Posts
    59

    Re: HEIGHT MAP

    Use a 1D texture...

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jun 2002
    Location
    Philadelphia, PA, US
    Posts
    108

    Re: HEIGHT MAP

    yeah, a 1d texture is definitely the way to go. i have a nice one that i use for the same purpose if you want it.

  4. #4
    Member Contributor
    Join Date
    Mar 2002
    Location
    CA,USA
    Posts
    57

    Re: HEIGHT MAP

    Thanks,Pat & SThomas


    SThomas,I am interested in your code can you help me.

    Also I am new to Texturing ..so can you explain in detail..
    Currently I am drawing the 3D mesh using following commands..
    glBegin(GL_LINES) ;
    glColor3f(1.0f,0.0f,0.0f);


    for(i=1;i<=98;i++)
    {
    for(j=1;j<=98;j++)
    {

    n1=check.CCalNormal(i,j,1);
    glNormal3f(n1.x,n1.z,n1.y);
    glVertex3f (xw[i],zw[i][j]-99.4,-yw[j]) ;
    glVertex3f (xw[i+1],zw[i+1][j]-99.4,-yw[j]) ;
    glVertex3f (xw[i+1],zw[i+1][j+1]-99.4,-yw[j+1]) ;

    // n2=check.CCalNormal(i,j,2);
    glNormal3f(n1.x,n1.z,n1.y);
    glVertex3f (xw[i+1],zw[i+1][j+1]-99.4,-yw[j+1]) ;
    glVertex3f (xw[i],zw[i][j+1]-99.4,-yw[j+1]) ;
    glVertex3f (xw[i],zw[i][j]-99.4,-yw[j]) ;


    }
    }
    glEnd();

    Thanks
    aus

  5. #5
    Member Contributor
    Join Date
    Mar 2002
    Location
    CA,USA
    Posts
    57

    Re: HEIGHT MAP

    SThomas Thanks for offering your code..
    My email id is aus79er@yahoo.com
    Please mail it to me


    Bye
    aus

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jun 2002
    Location
    Philadelphia, PA, US
    Posts
    108

    Re: HEIGHT MAP

    suppose the height field is a two dimensional array of 3-d vectors (which are stored as floats) declared as:
    Vector3 terrainMesh[100][100];

    to draw the terrain in wireframe mode, i'd do something like this:
    Code :
    //make sure front face winding is counter clockwise
    //don't worry about normals since we're in wireframe mode
    glBegin(GL_QUADS);
    for (int i = 0; i < 99; i++)
       for (int j = 0; j < 99; j++)
       {
          glVertex3fv(terrainMesh[i][j]);
          glVertex3fv(terrainMesh[i+1][j]);
          glVertex3fv(terrainMesh[i+1][j+1]);
          glVertex3fv(terrainMesh[i][j+1]);
       }
    glEnd();
    that'll be real slow though. to make that faster, you could:
    a) use a quad strip for each row of the terrain instead of individual quads
    b) use vertex arrays to store the quad strips
    c) compile the quad strips into a display list

    for info on loading textures and what not, check out nehe.gamedev.net

Similar Threads

  1. How to use a height map
    By ei05tbe in forum OpenGL: GLSL
    Replies: 8
    Last Post: 08-18-2010, 02:00 PM
  2. Using A Height Map
    By wvufan87 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-17-2008, 03:24 AM
  3. height map
    By jide in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 09-23-2006, 07:38 AM
  4. building up an height map
    By gunslinger in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 04-22-2004, 01:45 PM
  5. Height Map
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-13-2002, 05:40 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