views:

806

answers:

5

I'm looking for a simple file format to use for wireframe models. I am aware of VRML, u3D, etc, but these seem heavyweight for my needs. My criterea are:

  • Must have a clear spec. Either open or very well established/documented.
  • I only need (want) simple models - vertices and edges. I don't want to handle faces or objects. If the format supports more, that's fine so long as I can ignore them.
  • End-user tools are not a requirement, but would be great. If not, it must be human readable (and editable for simple models).
  • It would be nice (but not necessary) to be able to annotate or at least label nodes.
  • It shouldn't matter what language I'm using, but probable options are Java/C++ & OpenGL

Or am I just better writing vertices/edge lists to a text file and be done with it?

+1  A: 

Might just be easier to do those lists in a text file. That's the first thing that came to mind for me!

Chris Charabaruk
+7  A: 

Wavefront OBJ is a very simple text file format for storing 3d models and it's supported by all 3d modeling applications (eg. maya, 3dsmax, lightwave) so you can export and import your models very easily.

You can read more and the specs here:

http://www.fileformat.info/format/wavefrontobj/

I would recommend against making your own file format. The Wavefront OBJ is as simple as it gets and well specified.

Here's an example of a 2x2 plane. v is for vertex coordinates, f for description of faces (which vertices are connected):

v -0.500000 -0.000000 0.500000
v 0.000000 -0.000000 0.500000
v 0.500000 -0.000000 0.500000
v -0.500000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v -0.500000 0.000000 -0.500000
v 0.000000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
v -0.500000 -0.000000 0.500000
v 0.000000 -0.000000 0.500000
v 0.500000 -0.000000 0.500000
v -0.500000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v -0.500000 0.000000 -0.500000
v 0.000000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
f 1/1 2/2 5/5 4/4
f 2/2 3/3 6/6 5/5
f 4/4 5/5 8/8 7/7
f 5/5 6/6 9/9 8/8
f 10/10 11/11 14/14 13/13
f 11/11 12/12 15/15 14/14
f 13/13 14/14 17/17 16/16
f 14/14 15/15 18/18 17/17
lajos
If thats for a 2x2 plane then I really can't see how it is "simple"! There is 18 vertexes defined and 8 faces for something that is suppose to have 4 vertexes and 1 face...
freespace
@freespace: Obviously that's 2x2 faces, not 2x2 verts. Also, he's created two of them (presumably by accident).
Thanks for the example - that does look very complex for a 2x2 plane. The link you provided has a simpler 2x2 plane example.
Draemon
+3  A: 

I don't know of any formats that actively target wireframe views. (Edge/vertex only) You'll almost always have to deal with faces at the very least. The fortunate part there is that unless you have a very specific need for nothing but an edge list wireframe rendering can be done with just about any API from a face list.

As for the format, OBJ is good and simple, if a little outdated. It's also likely the easiest format to find documentation for. Microsoft's X files are great for quick and dirty rendering, but I've always been somewhat partial to the Quake formats. They tend to be very game-oriented, though, and as such include a lot of info you probably don't want.

If none of those meet your needs, maybe look into COLLADA. It probably won't work for you by itself, but you could write a quick exporter into your own format that only contains edge/vertex info, and at that point you essentially have support for every modeling package on the planet :)

Toji
The only reason for wanting edges but not faces was that I'm dealing with very simple models and I thought it might be easier.
Draemon
+1  A: 

POV-Ray's RAW triangle format is what I consider to be the simplest. You really can't get any simpler in my opinion. I implemented a load for this in a matter of minutes - it is a really really simple format.

freespace
A: 

OBJ is the most widespread and simplest, but it breaks down if you need more than vertex position, normal, and a single texture coordinate. It's not extensible at all. It's also text based so it has trouble with large meshes.

GTO has been emerging as a new interchange format. It's simple, fast, and extensible, and there is a production-proven open source code to read and write them:

Gto File Format

This has been used in production in several VFX and game studios, and yet it's about the same amount of work to write a loader as an OBJ file (and one of the samples is an OBJ to GTO converter).

Check it out, and help stop the spread of the Collada bloat-virus.

Sounds interesting - but all three doc pages 404. I'll try again later.
Draemon