Assimp Mesh Drawing OpenGL

This is the code I am using to draw my meshes, but for some reason nothing is displayed? The values of x, y, and z look correct.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
                for(int k = 0; k < model->mMeshes[meshnum]->mNumFaces; k++)
                {
                    const struct aiFace* face = &model->mMeshes[meshnum]->mFaces[k];


                    //glPushMatrix();

                    glBegin(GL_TRIANGLES);
                    for(int j = 0; j < face->mNumIndices; j++)
                    {

                        //model->mMeshes[meshnum]->
                        //cout << face->mIndices[j] << endl;

                        //cout << model->mMeshes[meshnum]->mVertices[ face->mIndices[j] ].x << endl;
                        float x = model->mMeshes[meshnum]->mVertices[ face->mIndices[j] ].x;
                        float y = model->mMeshes[meshnum]->mVertices[ face->mIndices[j] ].y;
                        float z = model->mMeshes[meshnum]->mVertices[ face->mIndices[j] ].x;

                        //cout << x << "," << y << "," << z << endl;
                        glVertex3f(x,y,z);


                    }
                    glEnd();

                    //glPopMatrix();


                }
Last edited on
closed account (o1vk4iN6)
The fixed pipeline has been removed since opengl 3 (not sure which version exactly), might want to consider learning glsl. It might be something wrong with your view matrix.
That's Interesting, I don't think it is my view matrix because I can draw normal quads and things just fine, for some reason my program returns 3 when I have the "glVertex3f(x,y,z);" not commented out. When it is commented out the program runs fine, even though the model is of course not there. Are the values returned by assimp a issue? Assimp is causing me a lot of trouble, I can't figure out there stupid node data structure for the life of me!
I think you should draw 3 vertex for a face
Be clear about your model struct

n faces,
1 face -> 3 vertex
1 vertex -> x, y, z
Topic archived. No new replies allowed.