howto draw a collada mesh using ASSIMP in OpenGL

39518721a0e1919ad3043852b35e456b
0
jordan____ 101 Jul 14, 2009 at 09:14

The assimp documentation is very short and there is just one incomplete pseudo code method. I tried the code below which result in black screen:

void RenderNode(const aiNode * node, aiMatrix4x4 accumulatedTransform)
{
    aiMatrix4x4 transform;

    if (node->mNumMeshes > 0)
    {       
        for (int m=0; m < node->mNumMeshes; m++)
        {
            aiMesh* mesh = scene->mMeshes[m];
            for (int f =0; f< mesh->mNumFaces; f++)
            {
                aiFace * face =  &mesh->mFaces[f];
                glBegin(GL_TRIANGLES);
                for (int v=0; v<3; v++)
                {
                    glVertex3f( mesh->mVertices[ face->mIndices[v]].x/100000,mesh->mVertices[ face->mIndices[v]].y/100000,mesh->mVertices[ face->mIndices[v]].z/100000);
                }
                glEnd();
            }
        }
    }
    else 
    {
        transform = node->mTransformation * accumulatedTransform;
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glMultMatrixf((const GLfloat *) &transform);
    }

    for (int i=0; i<node->mNumChildren; i++)
    {
        RenderNode(node->mChildren[i], transform);
    }
}

I call the method in this way:

aiMatrix4x4 identityMatrix;
RenderNode(scene->mRootNode, identityMatrix);

What am I doing wrong? Thank you very much in advance.

3 Replies

Please log in or register to post a reply.

46407cc1bdfbd2db4f6e8876d74f990a
0
Kenneth_Gorking 101 Jul 14, 2009 at 13:51

Since you are dividing the vertices with 100000, there is a good chance that the model is simply too small to see.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 168 Jul 14, 2009 at 17:09

BTW, you can use the …[/code[b][/b]] tags to post code. [code]…[/code**] tags to post code.

39518721a0e1919ad3043852b35e456b
0
jordan____ 101 Jul 14, 2009 at 19:55

Thank you for both replies. I added the division so that the object coordinates are in the field of view. I also found that if I remove the ModelView transformation from the code, some parts of the model are visible.