The LSM File Format
All LionSnake versions prior to 1.6 used a binary format that was not human-readable (unless the human in question is used to reading hex dumps). I decided to change that for versions 1.6 and following, because I wanted it to be easier for me to debug the file saving operations.
All LSM files are now simple text files. Each line contains an entry for a single object within the model.
Some entries refer to other entries. All of these references use zero-based indices; a value of -1 means that the field refers to a null object. All items are indexed by their position in the file, relative to other items of the same type.
All alphabetical data is type-sensitive.
String data is always contained in double quotes (so that the names of Bones, Layers, and Textures can have spaces in them).
As of version 1.7 there are eight different entry types, which can be distinguished by the start of the entry.
- The first line always starts with the string "LSM7". Note that the 7 will be incremented in future versions. The remainder of the line is ignored.
- b denotes a Bone object.
- The first field after the starting b is the index of the parent Bone. If there is no parent Bone, this value will be -1.
- The next field is a string representing the name of the Bone.
- The next three fields are the scaling factors (in x, y, and z) for the dependent vertices and the base points for the immediate child Bones (if any).
- The next field is the twist angle (the amount of rotation around the foreward-backward axis).
- The next field is the bend angle (the amount of rotation around the left-right axis).
- The next field is the turn angle (the amount of rotationa round the up-down axis).
- The next three fields are the translate value (in x, y, and z) for offsetting the Bone from its parent.
- u denotes a line containing a uv-mapping coordinate (also known as a UV point). The coordinate consists of two floating-point numbers. Because LionSnake was designed to support texture maps that go from minus infinity to plus infinity in both dimensions (u and v), the numbers are not restricted to the (0.0,1.0) range.
- t denotes a line containing a texture definition.
- The first field after the t is a string containing the texture's name.
- The next field is a string containing the file path for the texture bitmap.
- The next three fields are the color of the texture (with red, green, and blue values).
- v denotes a line containing a vertex definition.
- The three fields after the initial v are the coordinates (x, y, and z) for the vertex's location. This is its absolute location, and not relative to the Bone to which the vertex may be bound.
- The next field is the index of the Bone to which the vertex is bound. If the vertex is not bound, this value will be -1.
- The next field is a boolean denoting whether the vertex is locked (1) or not (0).
- e denotes a line containing an edge definition.
- The two fields after the initial e are the indexes of the starting and ending vertices of the edge.
- The next field indicates the sharpness of the edge. This is a floating point number. Since smooth edges are not written to file by LionSnake, this field is not supposed to be zero.
- pp denotes a face with no texture mapping.
- The first field is the number of vertices in the face.
- The next fields are the indices of the vertices.
- The last field is the index of the assigned texture, or -1 if no texture is assigned.
- pt denotes a face with texture mapping.
- The first field is the number of vertices in the face.
- The next fields are pairs of indices; the first index represents the vertex, and the second represents the texture-mapping point.
- The last field is the index of the assigned texture, or -1 if no texture is assigned.
Version 1.6
Version 1.6 was pretty much like v1.7.
- The first line started with the string "LSM6".
- l denotes a line containing a layer definiton. Layers were dropped for v1.7, and these entries are ignored.
- The first field after the initial l is a string containing the name of the layer.
- The next three fields represent the color (with red, green and blue values) for tinting the layer's objects.
- The next field is a boolean denoting whether the layer is hidden (1) or visible (0).
- fp denotes a face with no texture mapping.
- The four fields after the initial fp are the indices of the vertices of the face. For triangular faces, the fourth index will be -1.
- The next field is the index of the assigned texture, or -1 if no texture is assigned.
- The next field is the index of the assigned layer, or -1 if no layer is assigned.
- ft denotes a face with texture mapping.
- The four fields after the initial ft are the indices of the vertices of the face. For triangular faces, the fourth index will be -1.
- The next field is the index of the assigned texture, or -1 if no texture is assigned.
- The next four fields are the indices of the texture-mapping points. For triangular faces, the fourth index will be -1.
- The next field is the index of the assigned layer, or -1 if no layer is assigned.
Dependency caveat
If you plan to write or edit your own files in this format, ensure that all entries that are dependent on other entries follow after the entries upon which they are dependent. In other words, put root Bones before dependent Bones, Vertices before the Edges and Faces that use them, and so on. If you simply group them all together, and put them in the order Bones, UV points, Textures, Vertices, Edges, and Faces, there should be no problems.
The specifics of dependencies are as follows:
- UV pointsand Textures are not dependent on any other object. Other objects are dependent on them, so they should go at the start of the file.
- Bones can be dependent on other Bones. Make sure the parent Bones precede their children.
- Vertices that are assigned to a Bone are dependent on it.
- Edges are dependent on Vertices. Note that Edge entries are not needed for smooth edges. If the edge is sharp, the Edge will require an entry.
- Faces are dependent on Vertices (always), Textures (if assigned), and UV points (if the face is texture-mapped).