SMD file format: Difference between revisions
(markup) |
(→Vertex Animation block: adding prall's inputs) |
||
Line 69: | Line 69: | ||
===Vertex Animation block=== | ===Vertex Animation block=== | ||
This block contains the position and normal data for every vertex in the model. In a .VTA file there will be a "time" block for every frame in the vertex animation. | This block contains the position and normal data for every vertex in the model. In a .VTA file there will be a "time" block for every frame in the vertex animation. | ||
For each frame of vertex animation, you need a time entry in skeleton block. | |||
The vertex animation is begun by the <code>vertexanimation</code> tag and ended by an <code>end</code> tag. Time block begin with <code>time ''<frame>''</code> and end when a new "time" tag is encountered. | The vertex animation is begun by the <code>vertexanimation</code> tag and ended by an <code>end</code> tag. Time block begin with <code>time ''<frame>''</code> and end when a new "time" tag is encountered. | ||
Line 76: | Line 78: | ||
:Begins the vertex animation block | :Begins the vertex animation block | ||
*<code>Time 0</code> | *<code>Time 0</code> | ||
:Begins this time block | :Begins this time block. Time 0 serves as vertex index, so it should have all verts of the model giving a index number for each. | ||
*<code>''<ID>'' ''<PosX>'' ''<PosY>'' ''<PosZ>'' ''<NormX>'' ''<NormY>'' ''<NormZ>''</code> | *<code>''<ID>'' ''<PosX>'' ''<PosY>'' ''<PosZ>'' ''<NormX>'' ''<NormY>'' ''<NormZ>''</code> | ||
:<code>''<ID>''</code> is the vertex ID. <code>''<PosX>'' ''<PosY>'' ''<PosZ>''</code> is the position in world units (good to 6 significant digits). <code>''<NormX>'' ''<NormY>'' ''<NormZ>''</code> are the components of the vertex's normal vector (normals may be interpolated if triangle is part of one or more smoothing groups). | :<code>''<ID>''</code> is the vertex ID. <code>''<PosX>'' ''<PosY>'' ''<PosZ>''</code> is the position in world units (good to 6 significant digits). <code>''<NormX>'' ''<NormY>'' ''<NormZ>''</code> are the components of the vertex's normal vector (normals may be interpolated if triangle is part of one or more smoothing groups). | ||
*<code>Time 1</code> | *<code>Time 1</code> | ||
:Begins next time block. | :Begins next time block. | ||
*<code>end</code> | *<code>end</code> | ||
:Ends vertex animation block | :Ends vertex animation block |
Revision as of 05:52, 31 October 2005
The SMD file format is a simple text file, easily edited in any text editor. SMD files are carriage return sensitive — each line must end with a carriage return. The file should also include at least one carriage return after the final end statement. White space is the only delimiter; any combination of tabs and spaces can be used to separate values, and for this reason multiword names should be enclosed in quotation marks ("
).
Three versions of SMD and VTA
SMD files come in three versions, Reference, Physbox, and Animation files.
The Reference SMD file is a complete snapshot of the model, including its geometry, its skeletal structure, its texture, and the links between its mesh vertices and its skeleton. Reference SMDs do not contain any animation data — they produce only a static image of the complete model at one point in time.
The Physbox SMD defines the volumes that the physics engine uses to calculate collisions, and any links between its vertices and the skeleton.
Animation SMDs, on the other hand, ommit the triangle and texture map data. They contain only animation data and enough skeletal information for the StudioMdl program to be sure that the animation data matches the skeleton of the reference model.
In addition, .VTA files (facial animation) use the same SMD format. They contain vertex animation data for each frame.
SMD file sections
Here are the sections of an SMD file, considered in order:
Header data
The only header data required is the tag version 1
in the first line of the file. This is compatible with both HL1 and HL2.
Node tree data
Builds a list of all the bones in the skeleton. Each bone has a unique ID number, a unique text name and a pointer to the ID number of its parent. Children of the world use –1
as their parent ID. ID numbers are integers (starting from 0). Names are text, enclosed in quotes. Names may contain spaces.
nodes
- Starts the node tree data block.
<ID> "Bone Name" <parent ID>
<ID>
is a the ID number for this bone."Bone Name"
is a text name for the bone, enclosed in quotes.<parent ID>
is the ID number of the bone’s parent. Children of the world (unparented objects) have a parent ID of-1
.
end
- Ends the node tree data block.
Skeleton Pose data
This block contains the position and rotation data for every bone in the skeleton. In an animation SMD there will be a "time" block for every frame in the animation. In reference SMDs there will only be one time block.
The skeleton block is begun by the skeleton
tag and ended by an end
tag. A time block begins with time <frame>
and end when a new "time" tag is encountered.
Each frame is defined by a line telling the frame number, eg time 0
, followed by the bone's new position and rotations. The frames doesn't have to start at 0 (it can also be negative), but they have to increase in numbers.
Skeleton
- Begins the skeleton pose block.
Time 0
- Begins this time block
<ID> <PosX> <PosY> <PosZ> <RotX> <RotY> <RotZ>
<ID>
is the bone ID.<PosX> <PosY> <PosZ>
is the position in world units (good to 6 significant digits).<RotX> <RotY> <RotZ>
are local Euler rotations in radians. Bones which are not children of the world report their position and rotations in their parent's local space.
Time 1
- Begins the next time block. Every bone has a pose entry for every frame. Reference SMD export has only one frame.
end
- Ends skeleton pose block.
Triangle block
The triangle block contains a list of triangles. Each triangle is preceded by a texture file name (filename only — path data is supplied in the QC file as $cdmaterials
). Each vertex of the triangle then reports its parent bone’s ID, the vertex's position, the vertex's texture coordinates, its normals, and bone weights.
The Triangle block is begun with the triangles
tag and ends with the end
tag.
Triangles
- Begins the triangle block
"texturename.tga"
- Name of the texture file for the texture assigned to this face. Includes file suffix like ".tga". Enclose in quotes.
<Parent> <PosX> <PosY> <PosZ> <NormX> <NormY> <NormZ> <TexU> <TexV> <# of links> <bone ID> <weight> [...]
<Parent>
is the ID number of the vertex's parent bone.<PosX> <PosY> <PosZ>
is the position of the vertex in world space.<NormX> <NormY> <NormZ>
are the components of the vertex's normal vector (normals may be interpolated if the triangle is part of one or more smoothing groups).<TexU>
and<TexV>
are the texture coordinates for this vertex.<bone ID> <weight>
will be looped at the end of each vertex <# of links> times.- If the weights don't add up to 1.0 the rest will be assigned to the <Parent> bone. Same if no <# of links> is defined or if it is 0.
- Each triangle contains 3 vertex records.
"nextTextureName.tga"
- new texture file begins a new triangle listing
end
- ends triangle block.
Vertex Animation block
This block contains the position and normal data for every vertex in the model. In a .VTA file there will be a "time" block for every frame in the vertex animation.
For each frame of vertex animation, you need a time entry in skeleton block.
The vertex animation is begun by the vertexanimation
tag and ended by an end
tag. Time block begin with time <frame>
and end when a new "time" tag is encountered.
vertexanimation
- Begins the vertex animation block
Time 0
- Begins this time block. Time 0 serves as vertex index, so it should have all verts of the model giving a index number for each.
<ID> <PosX> <PosY> <PosZ> <NormX> <NormY> <NormZ>
<ID>
is the vertex ID.<PosX> <PosY> <PosZ>
is the position in world units (good to 6 significant digits).<NormX> <NormY> <NormZ>
are the components of the vertex's normal vector (normals may be interpolated if triangle is part of one or more smoothing groups).
Time 1
- Begins next time block.
end
- Ends vertex animation block