Jump to content
  • Advertisement
Sign in to follow this  
AAAP

3D Model Display (Pt. 2)

This topic is 4659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, Ive got a problem with this, ive been trying for a while and im not sure what is wrong. see, for some models, everything looks fine. particularly simpler ones, like boxes i guess. but every time i tried a sphere-shaped model, the faces dont seem to be attached properly. so i thought maybe the exporter to make OFF files was broken or something, but that seems unlikely to me. Yet, the simple shaped ones work fine. Also, whether the model has 3/4 sided faces doesnt seem to make a difference, this problem has only occured on shperic shapes (the 2 variets that you can make in blender).
	 glBegin(GL_TRIANGLES);
	 glNormal3f(vert[faces.a].x, vert[faces.a].y,vert[faces.a].z); 
     glVertex3d( vert[faces.a].x, vert[faces.a].y,vert[faces.a].z );
     
	 glNormal3f(vert[faces.b].x, vert[faces.b].y,vert[faces.b].z); 
     glVertex3d( vert[faces.b].x, vert[faces.b].y,vert[faces.b].z );

	 glNormal3f(vert[faces.c].x, vert[faces.c].y,vert[faces.c].z); 
     glVertex3d( vert[faces.c].x, vert[faces.c].y,vert[faces.c].z );

	 if( faces.n > 3 ){
	 glNormal3f(vert[faces.a].x, vert[faces.a].y,vert[faces.a].z); 
     glVertex3d( vert[faces.a].x, vert[faces.a].y,vert[faces.a].z );
	 
	 glNormal3f(vert[faces.c].x, vert[faces.c].y,vert[faces.c].z); 
     glVertex3d( vert[faces.c].x, vert[faces.c].y,vert[faces.c].z );

	 glNormal3f(vert[faces.d].x, vert[faces.d].y,vert[faces.d].z); 
     glVertex3d( vert[faces.d].x, vert[faces.d].y,vert[faces.d].z );
	 }
     glEnd();

thats my face drawing code, maybe itsa bit sloppy... its meant to compensate 3 and 4 sided shapes but i checked the files and theres nothing with 5 or more faces.. well anyway like I said, it seems to work properly with simpler shapes, but when I try to use a sphere for a model everything is in disorder. [Edited by - AAAP on January 20, 2006 8:17:45 AM]

Share this post


Link to post
Share on other sites
Advertisement
sorry for double posting.. needs bump a bit anyway.

Now, my render thing looks like this:



glBegin(GL_TRIANGLE_STRIP);

for( int f = 0; f < faces.n; f++ )
{
glNormal3d( vert[faces.vert[f]].x,
vert[faces.vert[f]].y,
vert[faces.vert[f]].z );

glVertex3d( vert[faces.vert[f]].x,
vert[faces.vert[f]].y,
vert[faces.vert[f]].z );
}

glEnd();










It's much, much better than the last one. But still, for faces that are quads, because its a triangle strip and the way the vertices are loaded from the file, you get the pacman-looking shape on quads that you get when you put the triangle strip vertices in the wrong order. that kinda

|¯¯/
|__

shape, if that shows up right.

If I can change the order that the vertexes are loaded, i think that would fix that.. but now im getting writers block and cant think of how i would even do that. cuz i load them in a for loop too now, so it would seem awkward to change the order of the for loop

Free Image Hosting at www.ImageShack.us

[Edited by - AAAP on January 20, 2006 12:22:49 PM]

Share this post


Link to post
Share on other sites

Doing this:


int temp_int;
temp_int = F.vert[0];
F.vert[0] = F.vert[1];
F.vert[1] = temp_int;



seems to make 4 sided faces display properly, but im worried it might break with "5 sided" faces and such, so if anybody can help me come up with a more reliable way, that would be sweet.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!