PDA

View Full Version : loading a cube from obj weird results



bansheeogl
04-28-2005, 11:38 PM
http://img.photobucket.com/albums/v214/gushh/a9a83b10.jpg
http://img.photobucket.com/albums/v214/gushh/bba9308e.jpg

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:

http://img.photobucket.com/albums/v214/gushh/3e3ddfde.jpg
http://img.photobucket.com/albums/v214/gushh/23bf65ce.jpg
http://img.photobucket.com/albums/v214/gushh/e5c2f125.jpg

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!).

MMMovania
04-28-2005, 11:48 PM
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?
Thanx
MMM

04-28-2005, 11:49 PM
Looks like z-fighting, either because you pick a low precision Z-buffer or you place your near and far clipping planes suboptimal.

http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

bansheeogl
04-28-2005, 11:56 PM
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!

T101
04-29-2005, 05:45 AM
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.

bansheeogl
04-29-2005, 08:41 AM
elaborate please?
Im loading obj from many modellers, all seems to export mostly the same way.

bansheeogl
04-29-2005, 12:00 PM
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

bansheeogl
04-29-2005, 05:54 PM
okey in wireframe you can see the actual mess:
http://img.photobucket.com/albums/v214/gushh/8e8aa27c.jpg
http://img.photobucket.com/albums/v214/gushh/6a4abb6e.jpg
Im looking forward the advice of some OpenGL wizard :) (I dont know whats wrong with my loader!)

04-30-2005, 12:38 AM
Originally posted by bansheeogl:
lets see, the z-fighting is NOT the problemWell 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.

bansheeogl
04-30-2005, 11:03 AM
as if a debugger will tell this sort of things, you bean head.

05-01-2005, 06:33 AM
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?

Right!