Results 1 to 5 of 5

Thread: surfaces....using triangle strips or meshes

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    pakistan
    Posts
    6

    surfaces....using triangle strips or meshes

    hi,
    iam new tp open gl, i've got a problem that i have a 2D data set a height field of an area and i have to display a 3D surface.
    to be more precise i have to read from a given data file(.dat format)display a 3D surface. the data is stored a 8 bit signed integers.
    i have been able to read the data from the file but i don't know how to start making a surface from it........iam confused . should i use triangle strips or meshes.....plz do guide me cause iam in a lot of trouble and i'll be very gratefull if u reply soon.
    thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    442

    Re: surfaces....using triangle strips or meshes

    Use triangle strips - something like this (not tested, not checked just off the top of me head) - change xi, yi for larger or smaller heightfield:

    int Heights [256][256];
    float xp = 0.0f, yp = 0.0f;
    float xi = 10.0f, yi = 10.0f;

    for ( int x = 0; x < 256; x++, xp += xi )
    {
    yi = 0.0f;
    glBegin ( GL_TRIANGLE_STRIP );
    for ( int y = 0; y < 255; y++, yp += yi )
    {
    glVertex3f ( xp, yp, (float) Heights [x][y] );
    glVertex3f ( xp + xi, yp, (float) Heights [x+1][y] );
    }
    glEnd ();
    }

  3. #3
    Member Contributor
    Join Date
    Jan 2001
    Location
    Portland, ME., USA
    Posts
    86

    Re: surfaces....using triangle strips or meshes

    Hi,
    Use triangle strips and don't use quads. Later when you'll want to add textures, quads will do some "funky" stuff with them that will catch you completely off guard.

    lobstah...
    lobstah

  4. #4
    Guest

    Re: surfaces....using triangle strips or meshes

    need some help. i have to read a data from (*.dat) and display it in 3d. my data include the vertex but i just don't have any idea to display it and reading the data. i want to display the data in 3d. so any idea or help ..

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: surfaces....using triangle strips or meshes

    I have a sequence of terrain demos that I wrote. They are available on http://141.217.140.88/miguel/

    You will see how to build a terrain in a rather inneficient way, and then it is improved to using triangle_strip in a fairly good manner. I did it this way just for the sake of showing how much better the performance is with strips and how simple it is to convert from quads to triangle_strip or quad_strip.

    I just read a gray scale TGA file to create the terrain.

    There is no kind of LOD involved here, but I will prolly give my terrain engine with a CLOD algo. after I fix a few things.


    I hope it helps.

Similar Threads

  1. An alternative to triangle strips and triangle fans
    By vincoof in forum OpenGL: General
    Replies: 8
    Last Post: 10-26-2012, 04:04 AM
  2. triangle strips
    By captainfreedom in forum COLLADA
    Replies: 5
    Last Post: 05-08-2008, 10:25 AM
  3. Triangle strips vs triangle fans
    By zeraiam in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-17-2001, 11:06 AM
  4. Triangle Strips.
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-09-2001, 09:27 PM
  5. Triangle Strips
    By msteinberg in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 11-18-2000, 08:35 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