The Simple Model Data format is designed to be an easy to parse basic model format. The data is a series of stanzas, each of which begins with a color and a polygon count, followed by the vertexes in a triangle strip.
Polygons are stored as a series of vertexes encoded with signed 16 bit values. There are always polygon count + 2 vertexes in each stanza. The vertexes compose a Triangle Strip, with a count of 1 simply being a single polygon. Easy!
A simple SMDA to SMD converter can be downloaded here.
An SMD file begins with an SMD header and then contains one or more stanzas until the end of file is reached.
Of course, all multi-byte values are in network byte order (big endian).
The header contains just enough to ensure that the reader has an unambiguous SMD file.
| bytes | field |
|---|---|
| 1 | Magic 0 = 's' |
| 1 | Magic 1 = 'm' |
| 1 | Magic 2 = 'd' |
| 1 | version = 0x01 |
| 22+ | 1+ stanzas go here |
The stanzas are very simple in format. They have three color bytes followed by a polygon count (max 127) specifying how large the triangle strip in the stanza is. The negative and zero values of the polygon count are reserved for future use in later versions of SMD.
In the degenerate form, an SMDv1 file contains a series of 22 byte fields with a single colored polygon in each one. Inefficient, but some (crappy) models may not be representable any other way.
| bytes | field |
|---|---|
| 1 | Red (0-255) |
| 1 | Green (0-255) |
| 1 | Blue (0-255) |
| 1 | Triangle Count (1-127) Signed! (-128-0 reserved) |
| 2 | x1 |
| 2 | y1 |
| 2 | z1 |
| 2 | x2 |
| 2 | y2 |
| 2 | z2 |
| Repeated count times | |
| 2 | xn |
| 2 | yn |
| 2 | zn |
When given a URL to an SMD format file, you can treat that as a URI and assume that the model at that location never changes.
That is to say, if you have a cached copy of the model
at http://www.technocage.com/~caskey/ferrari.smd, and you
find some entity specifying that same URL as its model, regardless of the version
information between the two entities (the one you have it cached from
and the one in question), you can consider the cached copy with the
same URL as being the current model at that URL and skip the re-download step.
It is the hope that SMD versions of models would only be used as temporary placeholders while more sophisticated models are downloaded from their own sources.