Any idea about ngon export for OBJ?

Hi there

BMesh brought us very good and much needed modeling additions. Does anybody know if there is a way to or at what point maybe the OBJ exporter can also write NGONs into an OBJ file?

Currently if you use NGONS in Blender it pretty much has to remain in Blender.

“Someone” has to extend the functionality of the .obj exporter/importer to handle it properly.
Per specification Wavefront .obj is capable of n-gons.

So the script hs only to be updated and Blender itself has the API for that build in?

Moved from “General Forums > Blender and CG Discussions” to “Support > Technical Support”

Yep…

ASCII .obj file has the following specification:

v x y z = geometric vertex, X-Coordinate, Y-Coordinate, Z-Coordinate
f 1 2 3 n = face, made up of vertices 1, 2, 3, … n


#Simple Triangle:
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
f 1 2 3


#Simple Quad:
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 1.0 1.0 0.0
v 0.0 1.0 0.0
f 1 2 3 4

hence:


#Simple n-gon, n=6:
v 0.0 0.0 0.0
v 1.0 0.0 0.0
v 2.0 1.5 0.0
v 1.0 2.0 0.0
v 0.5 1.0 0.0
v 0.0 1.0 0.0
f 1 2 3 4 5 6

This is ignroing vt (texture vertices) and vn (vertex normals), but that with grouping and materials, p (point) l (line) is the basic wavefront .obj specification.
Of course there are some more things, but that’s basically it.

All you need to do is to make sure to “catch” the geometry for tools unable to use n-gons, or offer both export/import methods.

Because you can save a face as n=8-gon, as 2 quads, or 8 triangles. There’s maybe even something within .obj to differntiate between n-gon, quad and triangle, so to say, store all 3 versions in one .obj and open the one supported. But I don’t know, I am not too familiar with .obj’s specifications.

The obj format doesn’t restrict the amount of vertices in a face, but it doesn’t specify how the resulting polygon is supposed to be triangulated.
I doubt that ngon formats of different applications are really compatible, since some of them are capable of different things than others. (e.g. blender cannot handle holes within a single polygon, which also isn’t expressible through OBJ)
Do you have experience with interchanging ngon from different applications? I’d be interested to know how that works out.

i thought id just mention that obj import/export now supports ngons. Campbell just updated the py exported/importer, so there might still be bugs, but it seems to be working fairly well.
I realize that this is an old thread, I just stumbled on it while researching this.

Awesome! What build has the ngon support? Do I just download a daily build?

the exporter is just a script. You can download that from here:
https://svn.blender.org/svnroot/bf-extensions/trunk/py/scripts/addons/io_scene_obj/

I talked to Campbell earlier today about this, and he fixed it a few minutes later. So any build after rev 54431’ish should have the new importer/exporter.
It’s funny that it only takes a developer a few minutes to fix something that people have literally been waiting months for :slight_smile: