Advertisement

Display list/mesh reading probs.

Started by February 08, 2002 10:01 AM
-1 comments, last by Trosa_Henke 23 years ago
Hi everyone! Lately I''ve been trying to do a mesh reader from the GE2 format which Maya can output. I''m a newbie so I''ve had many problems which I''ve solved but this time I''m simply clueless. I''ve figured that display lists are the way to go so I''ve started out from the NeHe lesson number 12. The problem is that only two of the models from the GE2 file (*gof) are displayed, namely the first and the last one in the list. If the file contains 4 models only model 1 and 4 are displayed. Since I''m a newbie I hope I''ve made a simple mistake easily corrected by someone more knowledgeable. Code areas where i think the problem might be: From the global section in the main program: -------------------------------- int nrmodels = import.numModels; GLuint *model = new GLuint[nrmodels]; -------------------------------- The BuildList function: ------------------------------- GLvoid BuildLists() { GLfloat x_m, y_m, z_m, u_m, v_m; int numfaces; model[0]=glGenLists(nrmodels); for (int mainloop = 0; mainloop < nrmodels; mainloop++) { numfaces = import.sector[mainloop].numfaces; glNewList(model[mainloop],GL_COMPILE); glBindTexture(GL_TEXTURE_2D, texture[2]); // Select A Texture Based On filter for (int loop_m = 0; loop_m < numfaces; loop_m++) // Loop Through All The Triangles { glBegin(GL_TRIANGLES); glNormal3f( 0.0f, 0.0f, 1.0f); // Normal Pointing Forward x_m = import.sector[mainloop].nrface[loop_m].vertex[0].x; // X Vertex Of 1st Point y_m = import.sector[mainloop].nrface[loop_m].vertex[0].y; // Y Vertex Of 1st Point z_m = import.sector[mainloop].nrface[loop_m].vertex[0].z; // Z Vertex Of 1st Point u_m = import.sector[mainloop].nrface[loop_m].vertex[0].u; // U Texture Coord Of 1st Point v_m = import.sector[mainloop].nrface[loop_m].vertex[0].v; // V Texture Coord Of 1st Point glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); // Set The TexCoord And Vertice x_m = import.sector[mainloop].nrface[loop_m].vertex[1].x; // X Vertex Of 2nd Point y_m = import.sector[mainloop].nrface[loop_m].vertex[1].y; // Y Vertex Of 2nd Point z_m = import.sector[mainloop].nrface[loop_m].vertex[1].z; // Z Vertex Of 2nd Point u_m = import.sector[mainloop].nrface[loop_m].vertex[1].u; // U Texture Coord Of 2nd Point v_m = import.sector[mainloop].nrface[loop_m].vertex[1].v; // V Texture Coord Of 2nd Point glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); // Set The TexCoord And Vertice x_m = import.sector[mainloop].nrface[loop_m].vertex[2].x; // X Vertex Of 3rd Point y_m = import.sector[mainloop].nrface[loop_m].vertex[2].y; // Y Vertex Of 3rd Point z_m = import.sector[mainloop].nrface[loop_m].vertex[2].z; // Z Vertex Of 3rd Point u_m = import.sector[mainloop].nrface[loop_m].vertex[2].u; // U Texture Coord Of 3rd Point v_m = import.sector[mainloop].nrface[loop_m].vertex[2].v; // V Texture Coord Of 3rd Point glTexCoord2f(u_m,v_m); glVertex3f(x_m,y_m,z_m); // Set The TexCoord And Vertice glEnd(); // Done Drawing Triangles } glEndList(); } } --------------------------------- The DrawScene function: --------------------------------- int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); GLfloat xtrans = -xpos; GLfloat ztrans = -zpos; GLfloat ytrans = -walkbias-0.25f; GLfloat sceneroty = 360.0f - yrot; glRotatef(lookupdown,1.0f,0,0); glRotatef(sceneroty,0,1.0f,0); glTranslatef(xtrans, ytrans, ztrans); for (int i = 0; i < nrmodels; i++) { glCallList(model); } return TRUE; } ---------------------------------- Full source code and necessary files can be found here: http://hem.passagen.se/sarvell/mesh_reading.zip Best regards, Henrik.

This topic is closed to new replies.

Advertisement