Binary object geometry (bog) file format

Status          : suggestion
Implementations : int CGeometry::readBOG( FILE * bog );
                  int CGeometry::writeBOG( FILE * bog );

This is a binary representation of 3D mesh object. This file can be printed in ascii using the geo file format

Logical file structure

bogFile= bogHead + Geometry list
bogHead= File identification + File version + Number of geometries
File identification= * String that identify this file format "BOG" *
File version= * file version number *
Geometry liste= {Geometry}
Geometry= Geometry head + Vertex list + Normal list + TexCoord list + Polygon list
Geometry head= Geometry id + Number of vertices + Number of normals + Number of TexCoords + Number of polygons
Vertex list= {Vertex}
Vertex= x-coord + y-coord + z-coord
Normal list= {Normal}
Normal= x-coord + y-coord + z-coord
TexCoord list= {TexCoord}
TexCoord= u-coord + v-coord
Polygon list= {Polygon}
Polygon= PolyHead + Vertex indexes + Normal indexes + TexCood indexes
PolyHead= Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
Type= [ Polygon | Triangles | Quads | Quad strip | Triangle strip | Triangle fan ]
Material id= * A string that identify the material. *
Vertex indexes= {index}
Normal indexes= {index}
TexCoord indexes= {index}
Index= * Pointer to element in a table. *

Example

The bog file is a binary format but in this example ascii text is used to demonstrate the file format.

BOG 1 1                         # File identification + File version + Number of geometries
1 8 6 4 6                       # Geometry id + Number of vertices + Number of normals +  Number of texCoords + Number of polygons
-1.000000 -1.000000 1.000000    # Vertex   0 = x-coord + y-coord + z-coord
1.000000 -1.000000 1.000000     # Vertex   1 = x-coord + y-coord + z-coord
1.000000 1.000000 1.000000      # Vertex   2 = x-coord + y-coord + z-coord
-1.000000 1.000000 1.000000     # Vertex   3 = x-coord + y-coord + z-coord
-1.000000 -1.000000 -1.000000   # Vertex   4 = x-coord + y-coord + z-coord
1.000000 -1.000000 -1.000000    # Vertex   5 = x-coord + y-coord + z-coord
1.000000 1.000000 -1.000000     # Vertex   6 = x-coord + y-coord + z-coord
-1.000000 1.000000 -1.000000    # Vertex   7 = x-coord + y-coord + z-coord
1.000000 0.000000 0.000000      # Normal   0 = x-coord + y-coord + z-coord
0.000000 1.000000 0.000000      # Normal   1 = x-coord + y-coord + z-coord
0.000000 0.000000 1.000000      # Normal   2 = x-coord + y-coord + z-coord
-1.000000 0.000000 0.000000     # Normal   3 = x-coord + y-coord + z-coord
0.000000 -1.000000 0.000000     # Normal   4 = x-coord + y-coord + z-coord
0.000000 0.000000 -1.000000     # Normal   5 = x-coord + y-coord + z-coord
0.000000 0.000000               # TexCoord 0 = u-coord + v-coord
1.000000 0.000000               # TexCoord 1 = u-coord + v-coord
1.000000 1.000000               # TexCoord 2 = u-coord + v-coord
0.000000 1.000000               # TexCoord 3 = u-coord + v-coord
2 0 4 1 4                       # Polygon 0 = Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
1 5 6 2                         # Vertex indexes
0                               # Normal indexes
0 1 2 3                         # TexCoord indexes
2 1 4 1 4                       # Polygon 1 = Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
2 6 7 3                         # Vertex indexes
1                               # Normal indexes
0 1 2 3                         # TexCoord indexes
2 2 4 1 4                       # Polygon 2 = Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
0 1 2 3                         # Vertex indexes
2                               # Normal indexes
0 1 2 3                         # TexCoord indexes
2 3 4 1 4                       # Polygon 3 = Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
3 7 4 0                         # Vertex indexes
3                               # Normal indexes
0 1 2 3                         # TexCoord indexes
2 4 4 1 4                       # Polygon 4 = Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
0 4 5 1                         # Vertex indexes
4                               # Normal indexes
0 1 2 3                         # TexCoord indexes
2 5 4 1 4                       # Polygon 5 = Type + Material id + Number of vertex indexes + Number of normal indexes + Number of TexCoord indexes
4 7 6 5                         # Vertex indexes
5                               # Normal indexes
0 1 2 3                         # TexCoord indexes