Skip to main content
gamedev.net
🔒 Locked

Polygon gap Problem

Started by killer_danish 1 reply 1k views
Original Post
killer_danish
killer_danish
Anyway I am having a problem with polygon gaps in my rotating Octahedron program. Everytime it rotates there is a certain gap between one of the polygons. Anyway here is the source code with the problem if anyone can help me out I would greatly appreciate it. NOTE: I think it has something to do with polygon orientation but I'm a bit confused on this area of openGL. void Diamond_Display() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); static GLfloat vertexes[6][3] = { {0.0, 1.0, 0.0},{ 1.0, 0.0, 0.0},{ 0.0, 0.0, 1.0}, {0.0,-1.0, 0.0},{-1.0, 0.0, 0.0},{ 0.0, 0.0,-1.0}}; static GLfloat vertexes2[6][3] = { {0.0, 1.0, 0.0},{ X1, 0.0, X1},{ X1, 0.0,-X1}, {0.0,-1.0, 0.0},{-X1, 0.0,-X1},{-X1, 0.0, X1}}; static GLuint tindices[8][3] = {{0, 5, 1},{0, 5, 4},{0, 4, 2},{0, 1, 2}, {3, 5, 1},{3, 5, 4},{3, 4, 2},{3, 1, 2}}; int triangle; glPushMatrix(); glRotatef(spin, 0.0, 1.0, 0.0); glBegin(GL_TRIANGLES); for(int i = 0; i < 8; ++i) { /*subdivide(&vertexes[tindices[0]][0], &vertexes[tindices[1]][0], &vertexes[tindices[2]][0]);*/ glColor3f(1.0, 0.0, 0.0); glVertex3fv(&vertexes[tindices[0]][0]); glColor3f(0.0, 1.0, 0.0); glVertex3fv(&vertexes[tindices[1]][0]); glColor3f(0.0, 0.0, 1.0); glVertex3fv(&vertexes[tindices[2]][0]); } glEnd(); glPopMatrix(); }
Lord_Evil
Lord_Evil
The winding of your polygons is indeed different (try enabling backface culling and cull either front or backbaces: glEnable(GL_CULL_FACE); glCullFace(GL_BACK/GL_FRONT);

Your triangle's winding:

1 -> CW (clockwise)
2 -> CCW (counter-clockwise)
3 -> CCW
4 -> CW
5 -> CCW
6 -> CW
7 -> CW
8 -> CCW

They should all have the same winding, e.g. CCW. Swap the second and third indices to change the winding, e.g.:
static GLuint tindices[8][3] = {{0, 1, 5},{0, 5, 4},{0, 4, 2},{0, 2, 1},
{3, 5, 1},{3, 4, 5},{3, 2, 4},{3, 1, 2}};

Hope that helps.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
killer_danish
killer_danish
Hey I readjusted the polygon orientation like you said and there was noticeable improvement thank you.

But there is still the problem of little pixel lines appearing out when the polygon model is rotating. At this rate I may have to write my own transformation which I really don't want to do.

So can anyone out there help me again. This is how the object looks like when it is in mid rotation shown below.

http://i605.photobucket.com/albums/tt132/bad_cow/A_Rotate_Octo.jpg

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.