This page covers the Inivis description of the format (2003) and the later guide that expands it, and notes what two widely used loaders, OpenSceneGraph’s and Assimp’s, do with it.
Lines, tokens and values
The file is ASCII text read a line at a time. The first word of a line is its token and
the rest are the values; some tokens are followed by further lines of data. Tokens are
case-sensitive. A string must be in double quotes if it contains spaces. Real files are
not indented. Numbers are written as decimal integers or decimal fractions; the surface
flags are usually hexadecimal with a 0x prefix.
The overall order is: header line, materials, objects.
Header
| Characters | Meaning |
|---|---|
AC3D | Fixed |
| One hexadecimal digit | Internal format version: b is 11, c is 12. A program may refuse a version later than it knows |
AC3Db files write each material on one MATERIAL line;
AC3Dc files write each as a MAT block.
Materials
Materials form the palette that surfaces refer to. The first material in the file is number 0, the next 1, and so on. They are normally all given directly after the header.
Version b: one line
MATERIAL name rgb %f %f %f amb %f %f %f emis %f %f %f spec %f %f %f shi %d trans %f
Version c: a block
MAT name
rgb %f %f %f
amb %f %f %f
emis %f %f %f
spec %f %f %f
shi %d
trans %f
data %d
characters of data
ENDMAT
| Field | Values | Meaning |
|---|---|---|
| name | String, quoted; may be "" | Material name |
rgb | Three floats, 0–1 | Diffuse colour |
amb | Three floats, 0–1 | Ambient colour |
emis | Three floats, 0–1 | Emissive colour |
spec | Three floats, 0–1 | Colour of the specular highlight |
shi | Integer, 0–128 | Shininess: a higher number gives a smaller highlight |
trans | Float, 0–1 | Transparency; 0 is opaque (loaders use 1 − trans as opacity) |
data | Integer, then text | Version c only, optional: a note about the material. The integer counts the characters that follow from the next line on; they may include line breaks |
Objects
An object starts with OBJECT type and must end with a
kids n line. When n is above 0, that many child
objects follow, read the same way, so the file is a tree.
| Type | Meaning |
|---|---|
world | The usual root object |
poly | An object with its own vertices and surfaces |
group | A grouping node; it may have no vertices |
light | A point light. The file gives it no lighting parameters |
The lines between OBJECT and kids are all optional. They are
normally written in the order below.
| Line | Default | Meaning |
|---|---|---|
name string | none | Object name |
data n | none | Object data string: n characters start on the next line and may include line breaks |
texture path | none | Texture image file used by this object’s surfaces |
texrep u v | 1 1 | Texture repeat factors |
texoff u v | 0 0 | Texture coordinate offset |
subdiv level | 0 | Subdivision level; subdividing also smooths the mesh |
crease angle | — | Angle in degrees between normals below which smooth surfaces are smoothed |
rot r1 … r9 | 1 0 0 0 1 0 0 0 1 | 3 × 3 rotation and scale matrix, relative to the parent; see below |
loc x y z | 0 0 0 | Position of the object’s centre, relative to the parent |
url string | blank | A URL attached to the object |
hidden | off | The object is hidden |
locked | off | The object cannot be edited while locked |
folded | off | The object is shown collapsed in the editor’s hierarchy list |
numvert n | — | Followed by n lines x y z, the vertices in the object’s own coordinates, numbered from 0. All n must be read |
numsurf n | — | Followed by n surfaces |
kids n | required | Last line of the object; number of child objects |
An object with vertices but no surfaces is valid: it is a way of bringing point data into AC3D, which can then wrap a surface round the points.
Surfaces
Each surface is a short block:
SURF flags
mat material
refs n
vertex u v (n such lines)
| Bits of flags | Value | Meaning |
|---|---|---|
0–3 (flags & 0x0F): type | 0 | Polygon |
| 1 | Closed line (the last corner joins the first) | |
| 2 | Open line | |
| 4 | Triangle strip. Not part of AC3D’s format: it is the .acc extension of TORCS and Speed Dreams, which Assimp reads | |
4 (0x10) | 1 | Smooth shading; clear means flat |
5 (0x20) | 1 | Two-sided; clear means single-sided |
So 0x00 is a flat single-sided polygon, 0x10 smooth
single-sided, 0x20 flat two-sided, 0x30 smooth two-sided, and
0x12 a smooth single-sided open line.
mat is the number of a material in the palette. Each
refs line names a vertex of the same object, counted from 0, and gives the
texture coordinate of that corner. A vertex may be used with different coordinates in
different surfaces.
Texture coordinates and corner order
The coordinate used for drawing is the corner’s value multiplied by
texrep plus texoff, separately for u and
v. In the format description’s rectangle, the bottom left corner has
0 0 and the top right 1 1, so v increases upwards
as the model is seen with +Y up. The same example lists its corners anticlockwise as
seen from +Z; OpenSceneGraph computes each face normal from that corner order by the
right-hand rule.
Position and rotation
Both rot and loc are relative to the parent object, so a
vertex is placed by applying the object’s matrix, then its translation, then the same
for each parent up to the root. The nine numbers of rot fill the matrix
column by column:
rot 1 2 3 4 5 6 7 8 9 matrix: 1 4 7
2 5 8
3 6 9
The matrix may include scale as well as rotation.
Reading advice from the description
The least a loader needs is OBJECT, numvert with its vertex
lines, numsurf with its surfaces, and kids to follow the tree.
Lines with other tokens may be ignored; a skipped data line must still skip
its counted characters, which could otherwise look like tokens.
Divergence from the specification
| Program | Behaviour |
|---|---|
| OpenSceneGraph | Reads only MATERIAL lines; it has no handling of MAT blocks |
| OpenSceneGraph | Uses a crease angle of 61 degrees when there is no crease line, and gives a light object light colours of its own choosing |
| OpenSceneGraph | Writes AC3Db with a world object at the root |
| Assimp | Reads only MATERIAL lines among materials, not MAT blocks |
| Assimp | Takes the nine rot numbers as the rows of its column-vector matrix, which is the transpose of the layout shown above |
| Assimp | Replaces a texrep with a zero factor by 1 1, keeps several texture lines per object (up to four are used by .acc), and accepts files from Quick3D that leave out SURF lines |