Page 1 of 1

Wavefront files with Blender [SOLVED]

Posted: Mon Jan 06, 2014 4:53 pm
by Benjamin100
When I export a wavefront obj file with blender, I get the vertices, but it doesn't seem to be in triangles. When I use "GL_TRIANGLES" the cube looks all out of order. I check the box for "triangulate" also. What else should I do?

Re: Wavefront files with Blender

Posted: Mon Jan 06, 2014 6:27 pm
by dandymcgee
Are you sure you have the clockwise / counter-clockwise orientation correct?

Re: Wavefront files with Blender

Posted: Tue Jan 07, 2014 1:01 am
by Benjamin100
Well, I'm not really sure how to control the orientation. Is there something other than the z and "y is up" options that I should be paying attention too? I don't see very many options in Blender. Or do you mean that I need to program it a certain way?

Re: Wavefront files with Blender

Posted: Tue Jan 07, 2014 8:29 am
by dandymcgee
Benjamin100 wrote:Well, I'm not really sure how to control the orientation. Is there something other than the z and "y is up" options that I should be paying attention too? I don't see very many options in Blender. Or do you mean that I need to program it a certain way?
Well that depends what "looks all out of order" means exactly. Perhaps an image would be useful.

Re: Wavefront files with Blender

Posted: Tue Jan 07, 2014 2:44 pm
by Benjamin100
Well, when I do "GL_POINTS" I see the 8 vertices as I would expect, but when I use triangles or triangle strip, it is as if it connects in the wrong order, it looks all twisted and missing sides and a face going diagonally across the middle.

Re: Wavefront files with Blender

Posted: Wed Jan 08, 2014 10:12 am
by bbguimaraes
If the points are correct, my guess is the edges are being loaded incorrectly. Create a simple model and take a look at the data produced by the code that loads this information from the file.

Re: Wavefront files with Blender

Posted: Wed Jan 08, 2014 1:23 pm
by qpHalcy0n
Are you backface culling?

Not familiar with wavefront's format but if you have a poly list you should have a good solid object model. If your poly winding order is off, then if you have backface culling for either CW/CCW then you'll get exactly the anomalies you're seeing.

Either way, this should not happen with a good design because you should be able to cull back faces for solid object models.

Re: Wavefront files with Blender

Posted: Wed Jan 08, 2014 3:35 pm
by Benjamin100
Thanks for the advice.

I don't understand why I would need to load edges if I have the vertices.

Re: Wavefront files with Blender

Posted: Wed Jan 08, 2014 4:16 pm
by qpHalcy0n
You wouldn't need to at all unless that information was useful to you.

If there is no poly list, however, then you will require the edge list. You may have to build it yourself with correct winding order.

Re: Wavefront files with Blender

Posted: Thu Feb 27, 2014 1:51 pm
by Benjamin100
Well, I took a break from this for a while, and now I'm back to trying to understand my old code.
I'm mostly confused about the Obj file format.
What are the numbers associated with the faces for? What do they tell me?
I see three pairs of numbers for each face, each pair separated by two slashes.
What does this tell me and how does it help me draw the object?

Re: Wavefront files with Blender

Posted: Thu Feb 27, 2014 6:48 pm
by dandymcgee
Have you read the Wiki article? http://en.wikipedia.org/wiki/Wavefront_.obj_file

If you want more details about a particular section, just click the citation link and browse to the site where the information was sourced from.

Re: Wavefront files with Blender

Posted: Sat Mar 01, 2014 3:12 pm
by Benjamin100
Ok. I transitioned to using 3ds because the lib3ds library looked helpful, and I didn't want to deal with parsing the files myself anymore.

But I still have problems drawing. I don't understand why I need any more information than the vertices to draw the triangles. What is the purpose of the list of faces? What other information do I need? Are the vertices simply written out of order?

Re: Wavefront files with Blender

Posted: Sun Mar 02, 2014 2:31 pm
by Benjamin100
So I leave this for months out of frustration over this one problem.
No matter what I do I cannot load the file information correctly to draw to the screen.
I have it all, and yet many of the vertices look out of place, and almost random.
Then, it occurs to me, that such a thing would happen if it was taking the color array as the vertex array. So I change a number in the color array, and one of the polygons drastically changes size.
Well, that much should be easy to fix.

Re: Wavefront files with Blender [SOLVED]

Posted: Mon Mar 03, 2014 8:03 pm
by Benjamin100
Finally got an OBJ file model on the screen. No lighting yet, but I finally got the info. Found a tutorial that gave a good explanation of how to get the face information and use it to order the vertices. What a relief!