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 4 of 4

Thread: Drawing Faces from 3DS file

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    7

    Drawing Faces from 3DS file

    So I just implemented the ability to load vertices and faces from a 3DS file, and it mostly works, with one aspect that has me scratching my head. I am using the following loop to draw the faces after loading a model. The issue is that the model seems to display numerous extra edges when viewing in a wireframe mode. I have checked multiple models and have seen this throughout, I am wondering if anyone has any suggestions on how to fix my problem.

    Code :
    	glBegin(GL_TRIANGLES);
    	for(int x = 1; x < 4*numberOfTriangles+1; x++)
    	{
    		//Face bit modifiers not needed, skip em.
    		if(tLoop == 4)
    		{
    			tLoop = 0;
    			continue;
    		}
    		else
    		{
    			glVertex3f(Vertices[Triangles[x]*3],Vertices[(Triangles[x]*3)+1],Vertices[(Triangles[x]*3)+2]);
    			tLoop++;
    		}
    	}
    	glEnd();


    And the following is an example of what I am asking about.

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171

    Re: Drawing Faces from 3DS file

    I don't think your loop looks right. Doesn't x have to increase by 3 on each iteration?

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    7

    Re: Drawing Faces from 3DS file

    If I was drawing 3 vertices per loop it would, but I'm only drawing a single vertex per loop.

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    7

    Re: Drawing Faces from 3DS file

    Figured out my own problem. Notice how the begin and end blocks appear outside of the loop. The program was trying to draw triangles using every vertex in the mesh, one after another. Thus it kinda created one giant mess. I changed to placing three vertices at a time(one face), and I placed the begin/end blocks inside the loop, and changed the loop to increment by 4 each time, allowing me to skip the face data.

    Just in case anyone was curious.

Posting Permissions

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