David's Model Format *.dmf
ANSI encoding is used because it is simple, fast and compact enough to remove the need of a binary model format. ANSI is an encoding with only one byte per character and no byte order mark. Trying to load a model using another encoding is not allowed by the engine.
Open model files in notepad to see examples of the syntax. It is recomended to associate the file format with a text editor since it is a very stable way to edit low detailed models.
Properties that have default values are usually not stored to save memory and improve both forward and backward version compability. If you for example only have white vertex color, it will to take any space in the file.
Bones:
ParentIndex is the index of the parent bone.
Not defining a parent will make it defined directly in object space.
Object space position is the default position.
Parent space position is relative to the end node of the parent bone.
Z axis is pointing from the start node to the end node.
Y axis is used to rotate the bone and generate the X axis that is not saved.
The user data in the bones is used to store anything you need per bone.
The axis system combined should make a normalized orthogonal 3x3 matrix
Length is the distance between the start node and the end node.
Syntax definition:
// Version independent
Start → "DMF1" ¤ ModelPropertyList ¤ ContentList ¤
PartContent → PartPropertyList TriangleList
PartPropertyList → PartProperty*
TriangleList → (¤ "<Triangle>" ¤ TriangleContent)*
TriangleContent → VertexPropertyList
VertexPropertyList → VertexProperty*
VertexProperty → ¤ VertexPropertyName ¤ "[" TriangleIndex "]" ¤ "(" Float ")" ¤
TriangleIndex → "0" | "1" | "2"
PointProperty → ¤ PointPropertyName ¤ "(" Float ")" ¤
PointPropertyName → "X" | "Y" | "Z" | "DX" | "DY" | "DZ"
ModelPropertyList → ModelProperty*
// Version depending
ContentList → "" | ¤ "<Part>" ¤ PartContent ContentList | ¤ "<Bone>" ¤ BoneProperty* ContentList | ¤ "<Shape>" ¤ ShapeProperty* ContentList | ...
FilterTypeName → "None" | "Alpha" | ...
CullingTypeName → "None" | "AABB" | "Radius" | ...
ModelProperty → ¤ "FilterType" ¤ "(" FilterTypeName ")" ¤ | ¤ "CullingType" ¤ "(" CullingTypeName ")" ¤ | ¤ "BoundMultiplier" ¤ "(" Float ")" ¤ | ...
PartProperty → ¤ "Name" ¤ "(" SimpleString ")" ¤ | ¤ "Texture" ¤ "[" TextureChannel "]" ¤ "(" FileName ")" ¤ | ¤ "TextureOverride" ¤ "[" TextureChannel "]" ¤ "(" TextureOverrideChannel ")" ¤ | ¤ "Shader" ¤ "[" ShaderChannel "]" ¤ "(" FileName ")" ¤ | ¤ "MinDetailLevel" ¤ "(" DetailLevel ")" ¤ | ¤ "MaxDetailLevel" ¤ "(" DetailLevel ")" ¤ | ...
BoneProperty → ¤ "Name" ¤ "(" SimpleString ")" ¤ | ¤ BoneFloatPropertyName ¤ "(" Float ")" ¤ | ...
ShapeProperty → ¤ "Name" ¤ "(" SimpleString ")" ¤ | ¤ ShapeFloatPropertyName ¤ "(" Float ")" ¤ | ¤ ShapeIntPropertyName ¤ "(" Integer ")" ¤ | ¤ "<Point>" ¤ PointProperty* ¤ | ...
VertexPropertyName → "X" | "Y" | "Z" | "NX" | "NY" | "NZ" | "U1" | "V1" | "U2" | "V2" | "CR" | "CG" | "CB" | "CA" | "AX" | "AY" | "AZ" | "AW" | "BX" | "BY" | "BZ" | "BW" | "BDX" | "BDY" | "BDZ" | "BDW" | ...
BoneFloatPropertyName → "ObjectSpaceX" | "ObjectSpaceY" | "ObjectSpaceZ" | "ParentSpaceX" | "ParentSpaceY" | "ParentSpaceZ" | "YAxisX" | "YAxisY" | "YAxisZ" | "ZAxisX" | "ZAxisY" | "ZAxisZ" | "Length" | "UserDataX" | "UserDataY" | "UserDataZ" | ...
BoneIntPropertyName → "ParentIndex" | ...
ShapeFloatPropertyName → "Radius" | "HalfWidth" | "HalfHeight" | "HalfDepth" | "PosX" | "PosY" | "PosZ" | "XAxisX" | "XAxisY" | "XAxisZ" | "YAxisX" | "YAxisY" | "YAxisZ" | "ZAxisX" | "ZAxisY" | "ZAxisZ" | ...
ShapeIntPropertyName → "ShapeType" | "CollisionType" | ...
TextureChannel → 0..15
ShaderChannel → 0..15
TextureOverrideChannel → -1..15
DetailLevel → 0..2
// Datatypes
Float → UFloat | -UFloat
UFloat → Integer | Integer "." Integer | Integer "," Integer
Integer → UInteger | -UInteger
UInteger → digit | digit UInteger
digit → 0..9
SimpleCharacter → Not any of these forbidden characters that could cause ambiguity < > ( ) [ ] { } * ? " |
SimpleString → SimpleCharacter*
FileName → SimpleString
// Indentation
Redundancy → " " | indent | linebreak
¤ → Redundancy*
Explanation of vertex property names:
X means position.x
Y means position.y
Z means position.z
NX means normal.x
NY means normal.y
NZ means normal.z
CR means color.red
CG means color.green
CB means color.blue
CA means color.alpha
U1 means texture coordinate U1
V1 means texture coordinate V1
U2 means texture coordinate U2
V2 means texture coordinate V2
AX means userdefined vector A.x
AY means userdefined vector A.y
AZ means userdefined vector A.z
AW means userdefined vector A.w
BX means userdefined vector B.x
BY means userdefined vector B.y
BZ means userdefined vector B.z
BW means userdefined vector B.w
BDX means bone space X
BDY means bone space Y
BDZ means bone space Z
BDW means bone index