# 3D Model Display (Pt. 2)

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

## 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 &gt; 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 on other sites
Hi,

I am actually shooting in the dark, but is it possible it looks allright if you use a triangle strip ?

##### Share on other sites
actually, it's the same effect. i tried that first.

##### Share on other sites
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

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

##### 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.

• 10
• 17
• 9
• 13
• 41