LWOB follows Electronic Arts’ IFF 85 standard. All numbers are big-endian: a short is a 16-bit signed integer, a long a 32-bit integer, and a float a 4-byte IEEE number. A chunk whose length is odd is followed by one pad byte, not counted in the length.
FORM
| Offset | Size | Type | Meaning |
|---|---|---|---|
| 0 | 4 | ID | FORM |
| 4 | 4 | long | Length of the rest of the file (file size − 8) |
| 8 | 4 | ID | LWOB, the form type |
| 12 | … | chunks | Each a 4-byte ID, a 4-byte length and the data |
Required: one PNTS, one SRFS and one POLS.
Optional: any number of SURF, anywhere, and at most one
CRVS. POLS and CRVS come after both
PNTS and SRFS.
PNTS – Points
The x, y and z coordinates of every point, as floats, 12 bytes per point; the number of points is the chunk length ÷ 12. Points are numbered from 0. By convention +X is right (east), +Y up and +Z forward (north), the unit is one metre for real-world models, and coordinates are relative to the object’s pivot point.
SRFS – Surface names
The name of every surface used by the object, each ending in a zero byte, with one more zero added when the name and its zero together are an odd number of bytes. Names are read until the chunk ends. Surfaces are numbered from 1, in this order.
POLS – Polygons
Polygons follow one another to the end of the chunk. Each is:
| Type | Meaning |
|---|---|
| short | Number of vertices, 1 to 200 |
| short × count | The vertices, as point numbers |
| short | Surface number, from 1; negative when detail polygons follow |
| short | Only when the surface number is negative: the number of detail polygons |
| polygons | Only then: the detail polygons, in this same form, but with no details of their own |
Detail polygons are drawn on top of their main polygon and may lie in the same plane. A polygon with a negative surface number uses the surface with the absolute value of that number. The vertex list starts at a convex vertex and runs clockwise as seen from the visible side; polygons are one-sided unless their surface is marked double-sided.
CRVS – Curves
Spline curves follow one another to the end of the chunk. Each is:
| Type | Meaning |
|---|---|
| short | Number of vertices |
| short × count | The vertices in order, as point numbers |
| short | Surface number |
| short | Flags: bit 0 set, the first point is a continuity control point; bit 1 set, the last point is |
Curves cannot have detail curves.
Example
The start of the example file from the format’s description: a square with a triangle as a detail polygon, 420 bytes in all.
00000000 46 4F 52 4D 00 00 01 9C 4C 57 4F 42 50 4E 54 53 FORM....LWOBPNTS
00000010 00 00 00 54 3F 80 00 00 3F 80 00 00 00 00 00 00 ...T?...?.......
00000020 BF 80 00 00 3F 80 00 00 00 00 00 00 3F 80 00 00 ....?.......?...
00000030 BF 80 00 00 00 00 00 00 BF 80 00 00 BF 80 00 00 ................
00000040 00 00 00 00 3F 00 00 00 BF 00 00 00 00 00 00 00 ....?...........
00000050 00 00 00 00 3F 00 00 00 00 00 00 00 BF 00 00 00 ....?...........
00000060 BF 00 00 00 00 00 00 00 53 52 46 53 00 00 00 12 ........SRFS....
00000070 53 71 75 61 72 65 00 00 54 72 69 61 6E 67 6C 65 Square..Triangle
00000080 00 00 50 4F 4C 53 00 00 00 18 00 04 00 01 00 00 ..POLS..........
00000090 00 02 00 03 FF FF 00 01 00 03 00 05 00 04 00 06 ................
000000A0 00 02 53 55 52 46 00 00 00 AE 53 71 75 61 72 65 ..SURF....Square
| Offset | Bytes | Meaning |
|---|---|---|
| 4 | 00 00 01 9C | FORM length 412, so the file is 420 bytes |
| 16 | 00 00 00 54 | PNTS length 84: seven points |
| 20 | 3F 80 00 00 … | Point 0 is (1.0, 1.0, 0.0); the others are (−1, 1, 0), (1, −1, 0), (−1, −1, 0), (0.5, −0.5, 0), (0, 0.5, 0) and (−0.5, −0.5, 0) |
| 108 | 00 00 00 12 | SRFS length 18 |
| 112 | 53 71 75 61 72 65 00 00 | Square with two zero bytes, since “Square” and one zero would be 7 bytes |
| 120 | 54 72 69 61 6E 67 6C 65 00 00 | Triangle, likewise |
| 134 | 00 00 00 18 | POLS length 24 |
| 138 | 00 04, 00 01 00 00 00 02 00 03 | A polygon of four vertices: points 1, 0, 2 and 3 |
| 148 | FF FF, 00 01 | Surface −1: surface 1, “Square”, with one detail polygon |
| 152 | 00 03, 00 05 00 04 00 06, 00 02 | The detail: three vertices, points 5, 4 and 6, surface 2, “Triangle” |
| 162 | 53 55 52 46 00 00 00 AE | The first SURF chunk, 174 bytes, for “Square”; see Surfaces |