Results 1 to 3 of 3

Thread: [solved] 3D Object visualisation problem

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2006
    Location
    QC,Canada
    Posts
    17

    [solved] 3D Object visualisation problem

    Hello, I am drawing tetrahedrons (4 triangular faces polygons) with OpenGL.

    There is a huge visualisation problem (the drawing itself and the coordinates are okay though)

    You can see a video sample here


    I want to draw the tetrahedrons and also their borders.

    So here is what I do

    Code :
    /* Draw full tetrahedrons */
                    glColor3d(m_RGBRender[0],m_RGBRender[1],m_RGBRender[2]);          
                    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
                    glBegin(GL_TRIANGLES);
                    for (pos = tetras.begin() ; pos + 4 < tetras.end() ; pos+=4) {
                                             glVertex3d((*pos)->get_x(),(*pos)->get_y(),(*pos)->get_z());
                         glVertex3d((*(pos+3))->get_x(),(*(pos+3))->get_y(),(*(pos+3))->get_z());
                         glVertex3d((*(pos+2))->get_x(),(*(pos+2))->get_y(),(*(pos+2))->get_z());
     
                         glVertex3d((*pos)->get_x(),(*pos)->get_y(),(*pos)->get_z());
                         glVertex3d((*(pos+1))->get_x(),(*(pos+1))->get_y(),(*(pos+1))->get_z());
                         glVertex3d((*(pos+2))->get_x(),(*(pos+2))->get_y(),(*(pos+2))->get_z());
     
                         glVertex3d((*pos)->get_x(),(*pos)->get_y(),(*pos)->get_z());
                         glVertex3d((*(pos+1))->get_x(),(*(pos+1))->get_y(),(*(pos+1))->get_z());
                         glVertex3d((*(pos+3))->get_x(),(*(pos+3))->get_y(),(*(pos+3))->get_z());
     
                         glVertex3d((*(pos+1))->get_x(),(*(pos+1))->get_y(),(*(pos+1))->get_z());
                         glVertex3d((*(pos+2))->get_x(),(*(pos+2))->get_y(),(*(pos+2))->get_z());
                         glVertex3d((*(pos+3))->get_x(),(*(pos+3))->get_y(),(*(pos+3))->get_z());
     
                    }     
                    glEnd();
     
     
       /* Draw borders of the tetrahedrons */
                    glColor3d(m_RGBBordersW[0],m_RGBBordersW[1],m_RGBBordersW[2]);          
                    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
                    glBegin(GL_TRIANGLES);
                    for (pos = tetras.begin() ; pos + 4 < tetras.end() ; pos+=4) {
                         glVertex3d((*pos)->get_x(),(*pos)->get_y(),(*pos)->get_z());
                         glVertex3d((*(pos+3))->get_x(),(*(pos+3))->get_y(),(*(pos+3))->get_z());
                         glVertex3d((*(pos+2))->get_x(),(*(pos+2))->get_y(),(*(pos+2))->get_z());
     
                         glVertex3d((*pos)->get_x(),(*pos)->get_y(),(*pos)->get_z());
                         glVertex3d((*(pos+1))->get_x(),(*(pos+1))->get_y(),(*(pos+1))->get_z());
                         glVertex3d((*(pos+2))->get_x(),(*(pos+2))->get_y(),(*(pos+2))->get_z());
     
                         glVertex3d((*pos)->get_x(),(*pos)->get_y(),(*pos)->get_z());
                         glVertex3d((*(pos+1))->get_x(),(*(pos+1))->get_y(),(*(pos+1))->get_z());
                         glVertex3d((*(pos+3))->get_x(),(*(pos+3))->get_y(),(*(pos+3))->get_z());
     
                         glVertex3d((*(pos+1))->get_x(),(*(pos+1))->get_y(),(*(pos+1))->get_z());
                         glVertex3d((*(pos+2))->get_x(),(*(pos+2))->get_y(),(*(pos+2))->get_z());
                         glVertex3d((*(pos+3))->get_x(),(*(pos+3))->get_y(),(*(pos+3))->get_z());
     
                    }     
                    glEnd();
    My OpenGl Init:

    Code :
    void GL_MAILLAGE::InitGL() 
    {  
        ReinitGL();    
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }
    My OpenGL Reinit (when window is resized etc..)

    Code :
    void GL_MAILLAGE::ReinitGL(double dx, double dy) 
    {
        glViewport(0, 0, m_glCanvasSize.GetWidth(), m_glCanvasSize.GetHeight()); 
        glEnable (GL_DEPTH_TEST);
     
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
     
        // ...
        // other stuff for rotations/translations
     
        glOrtho(xmin,xmax,ymin,ymax,zmin,zmax);  
    }
    Can anyone see something I'm missing, I am in desperate need of help I don't know what to do anymore.

    Thank you very much for reading this.

  2. #2
    Guest

    Re: [solved] 3D Object visualisation problem

    I think your problem are discussed here:
    http://www.opengl.org/resources/faq/...ygonoffset.htm

    An example of the solution:
    http://www.opengl.org/resources/faq/technical/pgonoff.c


    Try to use this in the OpenGL initialization:
    glEnable (GL_POLYGON_OFFSET_FILL);
    glPolygonOffset (1., 1.);

    Best regards,
    Simone Betti.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2006
    Location
    QC,Canada
    Posts
    17

    Re: [solved] 3D Object visualisation problem

    Thank you very, very much. I was already playing with the polygonOffset but obviously not at the correct place

    Thank you!

Similar Threads

  1. [Solved] Object with single x,y (C++, XCode)
    By toothyXdip in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-28-2010, 09:13 PM
  2. Starfield Visualisation Problem
    By smoore_500 in forum OpenGL: General
    Replies: 1
    Last Post: 11-24-2005, 07:00 PM
  3. problem computing ... (solved)
    By fazekaim in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 07-12-2005, 01:24 AM
  4. This Problem Solved!!!!!
    By imported_TOMCAT in forum OpenGL: User Software
    Replies: 0
    Last Post: 01-05-2003, 07:21 AM
  5. Solved my installation problem
    By TurtlePower in forum OpenGL: General
    Replies: 0
    Last Post: 02-08-2002, 05:58 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