New file exporter

Hello,

So, I’ve written a python plugin to export blender objects that have been mapped with UV mapping into a nice file format. Its basic output format is:

number of verticies
verticies and normals
texture table
number of faces
face descriptions
number of “clusters”
cluster descriptions

Clusters are groups of faces that all share the same texture so you can more easily shove polygons to the video card without having to rebind textures too often.

You can find it here:
http://www.upl.cs.wisc.edu/~psilord/pof.py

I was going to eventually have my script coalesce the polygons in each cluster into groups of open gl triangle strips, but, in the interest of time(I’m working on a larger project) I didn’t do it yet.

Anyway, what should I do with this script? Is there some library I can put it into with maybe some docs on what the file format looks like?

Thanks.

-pete

P.S. I apologize for the interesting python. It is my first use of the language…

To what specifically this script is for?
I will try it to see your script, since it may be a way to export correctly a uv-mapped model for nebula device (I can’t find a script that do it correctly at now from Blender and need to uv-map outside of Blender). May the file format be easily converted to .obj or .n3d or this cluster information is much diferent?
Well, need to see!

:o

Well, this script outputs objects into a format I designed that is supposed to be easily readable into memory. The script also cuts up quads into triangles, so every face in the
file format represents a triangle. Effectively, the .obj format is already represented in my format as my format is a super set of .obj (Well, from what I could find out about that file format anyway, I could be wrong). I have no idea what a .n3d file is, sorry.

I call the format “Portable Object Format”, hence POF in the output file.

The specific file output looks like this(an example from a single texture mapped quad).
The -1 at the end of the clusters represents all faces which are not texture mapped, hence it being zero.

###########################
POF 1.0

Number of verticies

4

x, y, z, nx, ny, nz

1.000000 1.000000 0.000000 0.000000 0.000000 1.000000
1.000000 -1.000000 0.000000 0.000000 0.000000 1.000000
-1.000000 -1.000000 0.000000 0.000000 0.000000 1.000000
-1.000000 1.000000 0.000000 0.000000 0.000000 1.000000

Number of textures

1

The texture table

fire1.png

Number of faces

2

Face Description

Vertex indicies

0 3 2

Normal

0.000000 0.000000 1.000000

Textured?

1

U V coords

1.000000 1.000000
0.000000 1.000000
0.000000 0.000000

texture id

0

Face Description

Vertex indicies

2 1 0

Normal

0.000000 0.000000 1.000000

Textured?

1

U V coords

0.000000 0.000000
1.000000 0.000000
1.000000 1.000000

texture id

0

Number of texture clusters

2

Cluster description

Texid for these faces

0

Number of faces in this cluster

2

List of face indexes

0
1

Cluster description

Texid for these faces

-1

Number of faces in this cluster

0

List of face indexes

I don’t want to be a stick in the mud but I would have a good look around before making a new format.

See if there are any formats that fit your need.

There are already too many half supported formats.

You may well have made a good choice in writing a new format.
At least its simple and easy to impliment.

Yeah, I know what you mean, but I’m mainly interested in skinned objects for games I’m writing. If I write my own file format, then I have full control over what goes in it and what doesn’t because I can directly dig it out of Blender. I looked around a little for other file formats, and there are some ok ones, but eventually mine is going to have pretty special features in it. The python plugin I wrote is going to convert the polygon clusters into a triangle strip representation that I can directly feed to opengl. Later, the file format will support binary space partition trees that the python script(or a third party program I write) will cut the object into. BSP and clustering don’t go together, and the file format will reflect that. Basically it will tell you if it is a BSP form of an object or a regular form with clusters.

In effect, my stuff starts becomming special purpose enough that I’m sorta forced to have my own file format. Oh well.

-pete

hi psilord, id like to have a look at your exporter,cause i am considering writing a sort of exporter to java3d… im at the beginning with python,blender, java3d ecc. :expressionless: … so your source would be a good starting point hehe

the problem is … link is missing

could you please point me to the actual link ?

thanx very much :slight_smile: