Results 1 to 2 of 2

Thread: Height Map

  1. #1
    Guest

    Height Map

    void GLClass::GLDrawHeightField (Object *GLObjTmp, int GLwire)
    {
    int X, Y;
    float x, y, z;
    _HeightField *HF;
    CObjects *CObj;
    int step_size, width, height, color;
    CTransformations *CTrans;

    glPushMatrix ();

    CTrans = new CTransformations;
    CTrans->ExecuteObjTranslations (GLObjTmp);

    HF = new _HeightField;
    HF = (_HeightField *)GLObjTmp->ObjProperties;
    CObj = new CObjects;

    step_size = HF->step_size;

    width = HF->width;
    height = HF->height;

    if (!HF->image)
    return;

    if (GLwire)
    {
    if (GLObjTmp->Selected)
    glColor3f (1.0, 1.0, 0.0);
    else
    glColor3f (1.0, 1.0, 1.0);
    }

    glBegin (GL_QUADS);

    for (X = 0; X < width; X += step_size)
    for (Y = 0; Y < height; Y += step_size)
    {
    x = X;
    y = CObj->HF_Height (HF, X, Y);
    z = Y;

    if (!GLwire)
    {
    //Texture Stuff
    color = CObj->HF_SetVertexColor (HF, x, z);
    glColor3f (color, color, 0.0);
    }

    glVertex3d (x, y, z);

    x = X;
    y = CObj->HF_Height (HF, X, Y + step_size);
    z = Y + step_size;

    if (!GLwire)
    {
    //Texture Stuff
    color = CObj->HF_SetVertexColor (HF, x, z);
    glColor3f (color, color, 0.0);
    }

    glVertex3d (x, y, z);

    x = X + step_size;
    y = CObj->HF_Height (HF, X + step_size, Y + step_size);
    z = Y + step_size;

    if (!GLwire)
    {
    //Texture Stuff
    color = CObj->HF_SetVertexColor (HF, x, z);
    glColor3f (color, color, 0.0);
    }

    glVertex3d (x, y, z);

    x = X + step_size;
    y = CObj->HF_Height (HF, X + step_size, Y);
    z = Y;

    if (!GLwire)
    {
    //Texture Stuff
    color = CObj->HF_SetVertexColor (HF, x, z);
    glColor3f (color, color, 0.0);
    }

    glVertex3d (x, y, z);
    }
    glEnd();
    glPopMatrix();
    }

    i know it is long, but i need help please! the code above draws my height field that is loaded. that parts works sortof. the problem i have is it will not shoe th 3d perspective view. it will shpow ortho, bbut not perspective...why? also, if i have a height map 1024x1024 what is appropriate to scale it down to?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Height Map

    You don't show your projection matrix setup, so it's hard to answer your question. Most likely you are drawing it outside the viewing area of your perspective view.

    Make sure that for your perspective view, the near clip plane is greater than 0.

    One other brief comment. I noticed you were using quads. Have you done anything to ensure that the vertices of your quads will all be planar? If they aren't, the behavior will be undefined. It's usually better to use triangles or triangle strips for a heightmap.
    Deiussum
    Software Engineer and OpenGL enthusiast

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 aus79er in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-05-2002, 05:47 PM

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