Do models need lighting?

Started by
13 comments, last by Mage2k 20 years, 11 months ago
Here''s why I ask: I am writing my first model loader (md2) and want to render the model without the skin (wireframe). I am just trying to view the first frame and have glPolygonMode set as such: glPolygonMode(GL_FRONT, GL_LINE). I have all of the vertices loaded into a display list (i''ve verified that I have valid vertices in my vertex array that I use to generate the display list) and use the same color for all when rendering but I am not seeing anything. Do I need lighting or is it something else? peace and (trance) out Mage
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
Advertisement
You DO NOT need lighting, somethign must have went wrong loading.
Well, no, I know that I''ve loaded all of the vertex and command data correctly (as I have outputted the arrays to a text file after loading). The problem must be where I''m building the display lists for the frames or how I''ve set up the camera and/or perspective transforms... I''ll post again if I can''t get it figured out. Thanx.

peace and (trance) out

Mage
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
Are you sure you are rendering the model inside the viewing frustum?

You may have something like this:

gluPerspective( 45, width/height/ 10.0, 100.0 );

but you have done

glTranslatef( 0.0, 0.0, -2.0 );

Look, it is before the near plane! Did you get what I mean?

Check those vertex coodinates, mate!
"Steel and Fire,Spreading the Holy Word,Dirty Liars,The truth has never been told" - Primal Fear
Just another little something... turn off glCullFace... when loading model formats (such as md3), it''s very easy to end up with HUGE models, and it''s quite possible that your camera is inside it!

Just turn off culling to test... that way even if you are inside it, you''ll see something (the inside of it).
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
You should read the Red Book 1.1 or a good book on OpenGL.

You CAN''T use vertex arrays in a display list, becouse of the client-server model of the OpenGL. (Yes, that''s why it''s called glEnableClientState()).

You have to decide between using a display list or an array. As far as I''ve seen, the vertex array is slightly faster than the display list, and if you use a boostin'' aproach (like using vertex pools instead of simple vertex arrays), you can get an 40-70% speed boost when rendering big amounts of data. But that''s up to you.
I thought quake series models were backwards - cull out front facing.
Game Core
OK: I am working all this weekend so I really don''t have time to work on this (although I do have time to browse the gamedev forums...:->) but, I am already reading the redbook and I am not using vertex arrays for rendering, I am using arrays to store the vertexes and then using the indices from the glcommands in the md2 file to build the display list in a loop... anywayz, thanks for all of the suggestions guyz...

peace and (trance) out

Mage
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage
Just use this function


    void Wire()  {    glColor4f(0.5f, 0.5f, 0.5f, 1.0f);    glDisable(GL_BLEND);    glDisable(GL_LINE_SMOOTH);    glDisable(GL_TEXTURE_2D);    glPolygonMode(GL_FRONT, GL_LINE);    glPolygonMode(GL_BACK, GL_LINE);  }  
--------------------------Nukemmsn: nukem996@hotmail.comaim: nukem996open source open mind
Ok, I'm stumped. The problem must be somewhere in how I'm building/using the display lists as I've checked out my camera and projection stuff by drawing some basic objects and I can see them just fine. So, here's the code where I build the display lists:


      //read in the glcommandsint *commands = new int[header.num_glcmds];file.seekg(header.ofs_glcmds, ios::beg);file.read((char*) commands, header.num_glcmds * sizeof(int));		//build the display listsnumFrames = header.num_frames;firstFrame = glGenLists(numFrames);int *temp2, count;for(i = 0; i < numFrames; ++i){        temp2 = commands;	count = 4; //need to set to 3 for first iteration of inner for loop	glNewList(firstFrame + i, GL_COMPILE);	while(count < header.num_glcmds){		int j = *(temp2++);		if(j < 0){			glBegin(GL_TRIANGLE_FAN);			j = -j; 		}		else			glBegin(GL_TRIANGLE_STRIP);		for(; j > 0; --j, temp2 += 3, count +=3){			glVertex3fv(&verts[temp2[2] + i*header.num_xyz]);		}		++count;		glEnd();	}	glEndList();}      
verts is an array of 3*numFrames*header.num_xyz floats and as I noted earlier I have verified that I am loading them and the commands from the .md2 file correctly and successfully. However, when I call glCallList(firstFrame) I am not seeing anything... See any problems?

peace and (trance) out

Mage

[edited by - Mage2k on May 5, 2003 4:10:36 PM]

[edited by - Mage2k on May 5, 2003 4:11:18 PM]
---------------------------------------------------There are 10 kinds of people in the world:Those that understand binary, and those that dont...Mage

This topic is closed to new replies.

Advertisement