1
votes

I started learning about reading the data packed in a Collada file (.dae). I'm to the point where I have the vertices of a specific mesh. Right now, I'm just looping through them between calls to glBegin and glEnd, and I noticed that not all of the faces were being rendered. I think it might be because the vertices aren't in the correct order to form a valid triangle strip. I realized that maybe this question should be aimed at the blender .dae exporter, since that's what I'm using.

This is the exact code I'm using:

//Vertices is a vector of vertices that I pulled from the collada file.

glBegin(GL_TRIANGLE_STRIP);
for(int i = 0; i != Vertices.size(); i++)
{
    glVertex3f(Vertices[i]->x, Vertices[i]->y, Vertices[i]->z);
}
glEnd();

The model I'm trying to load is a simple plane. Here's the contents of Vertices:

1: 1, 1, 0
2: 1, -1, 0
3: -1, -1, 0
4: -1, 1, 0
1
Are you trying to render tristrips Geometry? Please give more context.Stringer
Also is there no indice array?Stringer
Ah, an indice array would definitely help me. Using the position of each vertex, do you think I could come up with one at load-time that could draw the triangles in the correct order? I mean, it seems like it wouldn't be impossible since the points of the triangle lie on the same plane.Jeff

1 Answers

0
votes

You're right this is not a valid triangle strip if you want to draw a simple plane.

You should draw your vertices in that orders:

1: 1, 1, 0
2: 1, -1, 0
4: -1, 1, 0
3: -1, -1, 0

What you are drawing is that:

    4      1 
    |\    /|
    | \  / |
    |  \/  |
    |  /\  |
    | /  \ |
    |/____\|
    3      2

Looks like a problem in the exporter..