Professional Documents
Culture Documents
html
THE AC3D FILE FORMAT (This document last updated 27th March 2003)
The AC3D file format is ascii text and is very simple to parse. It's also very easy to generate AC3D files from your own data. This document describes the structure of AC3D files. Some simple examples are included at the end.
AC3D filenames usually have a '.ac' suffix. For more information about AC3D, see http://www.ac3d.org.
(HEADER)
(Materials - the palette)
(objects)
AC3Db
The first four characters are always 'AC3D' the next hex number following
immediately defines the internal version of the file (0xb == 11).
If the version is later than the program knows about then it will probably
may refuse to load it. As new versions of the AC3D file format evolve, this number
is used to make the loading code backwards compatible.
OBJECT %s
Specifies the start of an object. The end of the object section must
be a 'kids' line which indicates how many children objects (may be zero)
follow. The parameter is the object type - one of: world, poly,
group.
*name %s
*data %d
*texture %s
Optional - default is no texture. the path of the texture bitmap file for the texture of the current object.
*texrep %f %f
Optional - default 1.0,1.0 . The texture repeat values for the tiling of a texture
on an object's surfaces.
*rot %f %f %f %f %f %f %f %f %f
The 3x3 rotation matrix for this objects vertices. Note that the rotation is relative
to the object's parent i.e. it is not a global rotation matrix. If this token
is not specified then the default rotation matrix is 1 0 0, 0 1 0, 0 0 1
*loc %f %f %f
The translation of the object. Effectively the definition of the centre of the object. This is
relative to the parent - i.e. not a global position. If this is not found then
the default centre of the object will be 0, 0, 0.
*url %s
*numvert %d
numvert lines of %f %f %f
*numsurf %d
The number of surfaces that this object contains. The parameter specifies
the number of subsections that follow - each one being a different surface
SURF %d
The start of a surface. The parameter specifies the surface type and flags.
The first 4 bits (flags & 0xF) is the type (0 = polygon, 1 = closedline,
2 = line). The next four bits (flags >> 4) specify the shading and
backface. bit1 = shaded surface bit2 = twosided.
*mat %d
The index to the material that this surface has.
refs %d
refs lines of %d %f %f
The number of vertices in the surface. This number indicates the number of lines
following. Each line contains an index to the vertex and the texture coordinates
for this surface vertex.
kids %d
This is the final token of an object section and it must exist. If the parameter
is a number > 0 then more objects are recursively loaded as children of the
current object.
AC3Db
MATERIAL "" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10 trans 0
OBJECT world
kids 1
OBJECT poly
name "rect"
loc 1 0.5 0
numvert 4
-1 0.5 0
1 0.5 0
1 -0.5 0
-1 -0.5 0
numsurf 1
SURF 0x20
mat 0
refs 4
3 0 0
2 1 0
1 of 2 5/2/17, 10:57 PM
https://www.inivis.com/ac3d/man/ac3dfileformat.html
1 1 1
0 0 1
kids 0
Another example - an object with 7 vertices (no surfaces, no materials defined) This is a good way of getting point data into AC3D. The Vertex->create convex-surface/object can be used on these vertices to 'wrap' a 3d shape around them
AC3Db
OBJECT poly
numvert 7
-0.83 -0.235 -0.04
-0.63 0.185 -0.04
-0.55 0.235 -0.25
-0.33 0.235 0.29
0.09 0.235 -0.29
0.33 -0.195 -0.04
0.83 0.005 -0.04
kids 0
If you write a loader then you least you need is code to handle the object
token, and the objects numvert/vertice and numsurf/sufaces - esentially
the geometry of the model.
You can ignore any line that starts with a token other than these e,g textures,
rotation, location etc.
2 of 2 5/2/17, 10:57 PM