Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Triangulating a surface constructed by 3D curves

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    21

    Triangulating a surface constructed by 3D curves

    I have a 3D polygon (i wonder if polygon is the correct term here) that is constructed from 3D curves. These curves are basically lists of 3D points.

    I would like to triangulate this surface so i could draw it using OpenGL.

    Are there any recommended algorithms and/or code libraries (preferably in c++) that i could use?

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    29
    The example that I provided (creating a sphere from a single triangle strip) in this forum sounds close to what you are trying to do.
    assume:
    float curve[n][npoints][3]; // this assumes that all curves have the same number of points
    int i, j;
    curve[i][j][0] = x;
    curve[i][j][1] = y;
    curve[i][j][2] = z

    for(i=0; i , (n-1); i++){
    glBegin(GL_TRIANGLE_STRIP);
    for(j=0; j < npoints; j++){
    glVertex3fv(curve[i]j]);
    glVertex(3v([i+1][j]);
    }
    glEnd();
    }

    This is just the code fragment that draws the triangles.
    If curves intersect (share common vertices) you could have problems. One simple way to avoid that is to move one of those common vertices just a bit.

    Quote Originally Posted by esapir View Post
    I have a 3D polygon (i wonder if polygon is the correct term here) that is constructed from 3D curves. These curves are basically lists of 3D points.

    I would like to triangulate this surface so i could draw it using OpenGL.

    Are there any recommended algorithms and/or code libraries (preferably in c++) that i could use?

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    21
    Quote Originally Posted by wmelgaard View Post
    The example that I provided (creating a sphere from a single triangle strip) in this forum sounds close to what you are trying to do.
    assume:
    float curve[n][npoints][3]; // this assumes that all curves have the same number of points
    int i, j;
    curve[i][j][0] = x;
    curve[i][j][1] = y;
    curve[i][j][2] = z

    for(i=0; i , (n-1); i++){
    glBegin(GL_TRIANGLE_STRIP);
    for(j=0; j < npoints; j++){
    glVertex3fv(curve[i]j]);
    glVertex(3v([i+1][j]);
    }
    glEnd();
    }

    This is just the code fragment that draws the triangles.
    If curves intersect (share common vertices) you could have problems. One simple way to avoid that is to move one of those common vertices just a bit.

    I think this kind of solution will work only for planar polygons. I don't think it will work for real 3D polygons

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    I doubt if you will find source code for this. My son was working on a similar project recently for his company. He found quite a few papers on algorithms but had to implement it himself. The basic idea is to expand each edge line into a quad but avoid overlapping quads. For optimum performance and shape definition the quads should be approximately the same area.

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2014
    Posts
    21
    It was also my intuition - that i need to construct quads. However, there are several problems that i am not sure how to solve:

    1. Number of points on the curves is not equal and more than that - the distance between every two samples is not the same.
    2. I am not sure how this algorithm should work. At first my idea was to start on one of the polygon edges (i cam assume for simplicity that the polygon always has exactly 4 curves) and iteratively build the grid. However, i think that the grid will look different if i will start for different edges. Am i correct? How i should approach to this problem?

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    29
    Again without having seen your data, it sounds like the same problem as meshing a Finite Element Analysis (FEA) model. The Finite Element Method Its Basis And Fundamentals , by Ziendiewicz, Taylor & Zhu has an entire chapter on that subject.

    Quote Originally Posted by esapir View Post
    It was also my intuition - that i need to construct quads. However, there are several problems that i am not sure how to solve:

    1. Number of points on the curves is not equal and more than that - the distance between every two samples is not the same.
    2. I am not sure how this algorithm should work. At first my idea was to start on one of the polygon edges (i cam assume for simplicity that the polygon always has exactly 4 curves) and iteratively build the grid. However, i think that the grid will look different if i will start for different edges. Am i correct? How i should approach to this problem?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •