Back to ppModeler.
3do File format
As all part of ppGui and ppGame library, 3do file are based on chunks.
A chunk is a piece of file that contains data, with a known length, and
an identifier for . The main advantage of this kind of format is it can
be easily extended. When a reader program don't know a chunk, it simply
ignores it, and jumps to next one. So a program can read newly created
files with an old reader. One draw back of this kind of file is saving
with chunk leads to a more complicated code. But, nevertheless, the advantage
is worth the programing effort. A 3do file contains all the information
of the object, included textures.
Every number is writed in big endian mode (Most Significant Bit first).
chunk
A chunk is composed of two parts :
an header
data
The header is composed of two parts :
an identifier string, always 8 chars.
a DWORD for the lenngth, without the header.
The chunk header is defined by :
typedef struct
{
char id[9]; /* with the trailling '\'0' */
DWORD size;
}chunkDef;
3do chunk
chunk id = "object3d"
It can be composed of the following sub-chunks :
vertices chunk
faces chunk
normals chunk
edges chunk
textures chunk
bounding spheres chunk
vertices chunk
chunk id = "vertLst "
The data are :
a DWORD for the number of vertices,
for each vertex, three float for x, y, z coordinates.
faces chunk
chunk id = "faceLst "
This chunk is composed of :
the number (DWORD) of faces,
a face chunk for each face.
face chunk
chunk id = "face3d "
A face, is a 3d polygon, which is planar and convex. This chunk
is composed of :
an identifier (DWORD) of the drawing mode of this face :
0 : draw3dFaceFlat,
1 : draw3dFacePhong,
2 : draw3dFaceTexture,
3 : draw3dFacePoint,
4 : draw3dFaceEdge,
5 : draw3dFaceTransparentTexture,
6 : draw3dFaceBump.
the number (DWORD) of points of the face,
for each point, the index (DWORD) in the vertex array of the object,
a face plane chunk
a face material chunk
possibly some of the following sub-chunks :
face normals chunk
face uv chunk
face material
chunk
chunk id = "material"
The data are :
a DWORD ambient (0 -> 255),
a DWORD diffuse (0 -> 255),
a DWORD specular (0 -> 255),
a DWORD red (0 -> 255),
a DWORD green (0 -> 255),
a DWORD blue (0 -> 255),
face plane chunk
chunk id = "plane3d "
A plane is defined by is equation : nx.x + ny.y + nz.z = D. This
chunk defines the plane of a face. The data are :
a float for the x composant of the normal
a float for the y composant of the normal
a float for the z composant of the normal
a float for D
face normals
chunk
chunk id = "normIdx "
The number of normal indexes is the same than the number of points
in the face. The data are :
for each point, the index (DWORD) in the normal array of the object,
face uv chunk
chunk id = "textuPos"
The number of uv coordinates is the same than the number of points
in the face. The data are :
a DWORD for the texture index in the texture array of the object,
for each point, two DWORD for u, v coordinates in the texture. u must be
greater or equal than 0, and lower or equal than texture->width-1. v must
be greater or equal than 0, and lower or equal than texture->height-1;
mormals chunk
chunk id = "normLst "
The data are :
a DWORD for the number of normals (not necessarely the same that the number
of vertices),
for each normal, three float for x, y, z coordinates. The normal must be
of length one.
edges chunk
chunk id = "edgeLst "
The data are :
a DWORD for the number of edges,
for each edge :
the index (DWORD) of the first vertex,
the index (DWORD) of the first face,
the index (DWORD) of the second vertex,
the index (DWORD) of the second face.
bounding spheres
chunk
chunk id = "bound3d "
The data are :
a DWORD for the number of bounding spheres,
for each bounding sphere :
a float for the x coordinate of the center,
a float for the y coordinate of the center,
a float for the z coordinate of the center,
a float for the radius of the sphere,
Acknowledgement
IJG code for the jpeg import/export library,
Brian Mirtich (http://www.cs.berkeley.edu/~mirtich) for his volume integration
program,
Back to ppModeler.