BMF file format

Designed by David Farrell
Implemented as export from "view3ds" and used in 'openuniverse"


A BMF file defines facet based models including their texture file names. The facets may be either individual faces described through a vertex list (SparceMesh) or mesh strips (StrpMesh). The vertices have both texture coordinates, normals, and positions.

Header

The first two unsigned short ints give the number of materials and the mesh type. The mesh is either a 0 for "sparce" or it is a "strip" mesh.

Texture name

A StripMesh and SparceMesh have much in common, they start with the length of the texture (unsigned short int) followed by the texture name. The texture name is a '\0' terminated C string so the texture name length is at least 1. The textures are saved as JPEG images external to the BMF file. Since this has been designed as a Windows format the case sensitivity of the texture names has not be specified.

Surface properties

Then follows the ambient, diffuse and specular values (RGBA). A RGBA is defined as follows, note that floats are 32 bits wide. These and ints are all little endian.

typedef struct {
   float r,g,b,a;
} RGBA;
Vertex list

Then follows the number of vertices (unsigned short int) and the vertices themselves (VERTEX). u,v are the texture coordinates, i,j,k the normals, x,y,z the vertex positions. A VERTEX is defined as

typedef struct {
   float u,v;
   float i,j,k;
   float x,y,z;
} VERTEX;
After this the two mesh types differ.

SparceMesh

A SparceMesh consists of an indexed list of triangular polygons (TRILIST) where p0,p1,p2 index into the vertex list. The vertex indices start at 0.

typedef struct {
   unsigned short int p0,p1,p2;
} TRILIST;
StripMesh

A StripMesh consists of an array containing the length of the strips and another array with all the strip indices into the vertex list. The sum of all the strip lengths should be the same as the number of strip indices.

Further reading

For more details see the header file and BMF load software by David Farrell, these are part of the openuniverse distribution. Two example models are given here, they are the two moons of Mars: phobos.bmf and deimos.bmf. My rough code that converts Sparce BMF files is given here: readbmf.c.