loading a cube from obj weird results

My vertex data is correctly loaded into a structure, same with vertex normal data and u,v co-ords, as well as faces data. BUT I believe the way im rendering / processing the faces is wrong. you can see that in the screenshots of a simple cube!.

some meshes gets loaded nicely BUT where they share vertices, it looks nasty, all messed up!.

Also, the normals, the shading its flat, this is because its per-vertex, right? (I just have 1 normal per vertex) how can I turn this into smooth normals? (although this second question has less priority in my opinion, I preffer to have my mesh correctly loaded before looking the normals trouble).

Also as a friend (I use his same account here) stated, it runs really slow with a couple of polygons on screen (4000+) But its not a hardware issue…

More screenshots:

Do you see how the mesh is fairly good rendered (the faces) but, on some part it screws up? (although on the cube… its more than half-screwed, so… I dont know!).

Hello there
From the figure i think the vertex ordering is not correct. By the way can you post the code snippet of how u are creating the faces from the vertex array?

Looks like z-fighting, either because you pick a low precision Z-buffer or you place your near and far clipping planes suboptimal.


z-fighting? (again?) But… If you see the mesh, its not correctly generated… And the cube, yes, you can see some z-fighting but thats because the faces overlap a lot… Look at the sphere, where less faces overlap and you’ll find out that the close and far values are fairly ok (although I admit they are not perfect, but thats a test scene).

I cant post code, not c++ and not even regular GL Commands as its all wrapped by me.

Well Im not using an array but a dynamic linked list for all the mesh data… (arround one per data type).

But I reset my lists and start a loop, and pass through every element of the vertex list and the normal list… using GL_QUADS for now, tryed polygons but it was messed up, and for triangles, I get the same result (if I load a triangulated mesh). as now with a quad mesh. THe problem must be at the face part its obvious if you watch the screenies, but… I’ve been fighting with this for some days with out luck so far.

Can someone tell me more about GL_POLYGON ? as Im getting a sort of “rose” when I load my sphere. Whats up with convex? etc… ?! thanks!

Just a thought: I’m wondering if there may be 1-based indices in the file as opposed to 0-based indices (since you seem to get errors with just a few vertices).

And, yes, it looks like there’s also some z-fighting going on.

elaborate please?
Im loading obj from many modellers, all seems to export mostly the same way.

lets see, the z-fighting is NOT the problem, its just a simple test for loading the obj meshes, thats the point. The problem is that some meshes are totally messed up, some others are nice but some parts are bad. I dont get why… so I was wondering if someone had the same problem or knows what could be causing this?. thanks

okey in wireframe you can see the actual mess:

Im looking forward the advice of some OpenGL wizard :slight_smile: (I dont know whats wrong with my loader!)

Originally posted by bansheeogl:
lets see, the z-fighting is NOT the problem
Well the cube certainly shows z-fighting artifacts, so you are actually dealing with two seperate problems.

When I look at the wireframe sphere it seems to consist of triangles and quads, does your rendering code take this into account?
Doesnt look like, it looks like you are rendering quads all the time eventhough you should only draw a triangle. Therefore you will incorrectly retrieve a 4th vertex and OpenGL will break this “quad that should be a triangle” into the “correct” triangle and one that is “incorrect” (that is the peak inside the sphere).
Same goes for the outside of the sphere where the two half spheres merge, I guess this is a “melt” of sort for easier texturecoordinate generation that also consist of triangles but is rendered as quads.

Anyhow I am sick of playing the guessing game with you, either you spill the beans and show some code, or act like a “good developer” (pun intended) and use the debugger to analyse your app. Its not that hard, really.

as if a debugger will tell this sort of things, you bean head.

Listen dickwad, yes debugging and single stepping thru your mesh loader would have told you that there are triangles and quads in that mesh. No magic involved.

On the other hand one must know how to use a debugger in the first place, right?