KatsBits Community

[MD5] HOW TO... export animated MD5 from Blender

kat · 1 · 91747

0 Members and 1 Guest are viewing this topic.

Offline kat

  • Administrator
  • Hero Member
  • *
    • Posts: 3148
    • KatsBits
The following information is for generic MD5 production and works when exporting most types of content, be aware however that the individual particulars of a given project may result in failed or broken exports. Thorough testing is recommended before use to make sure output is fully compatible with needs.

Please Note: For MD5 script technical support, i.e. help with errors and problems relating to the export script when exporting MD5 files, please refer to the MD5 Export script support topic.



Basic MD5 preparation & export

Download
Installation & usage
IMPORTANT NOTE: Scripts need to be activated from "User Preferences" regardless as to how or where they are installed from. Be sure to use an official public release of Blender (available from Blender.org) before using any scripts, in-development sub-trees often break functionality so check your version before using.

To install the MD5 export script either;

1) With Blender open, click "File » User Preferences". In the open dialogue, click "Install AddOn...". In the file browser, select the script and click "Install AddOn..." It will then appear listed in User Preferences. Finally activate the script by selecting the checkbox to the right of the entry. Close User Preferences.

Or;

2) Drop the script into the "addons" folder then activate via "User Preferences".

For Windows Vista or Windows 7;
  • C:\Users\[User]\AppData\Roaming\Blender Foundation\Blender\scripts\addons\
Windows XP users should look in;
  • C:\Documents and Settings\[User]\Application Data\Blender Foundation\Blender\scripts\addons\
Linux and Mac installation will differ depending on OS version used.

If dropped into the 'addons' folder, open "File » User Preferences", click "Import-Export" and activate the script by selecting the checkbox to the right of "Quake Model 5 (.md5)". If correctly installed "Quake Model 5 (.md5)" should appear in the "File » Export" menu list on exporting.

Using the MD5 exporter
IMPORTANT NOTE: The following should be considered generic instructions for mesh and animation export from Blender to MD5 using any of the available scripts. There may be slight differences depending upon the script and Blender versions used so be sure to double check for compatibility issues before using in a production environment.

MESH PREP Parenting: Mesh Objects should have "Apply" transforms set to avoid scaling, origin mesh shifting and/or other association issues. To do "Clear Parent", select all objects to be fixed and press "Alt+P" to access the "Clear Parent" options popup, then preferentially select "Clear & Keep Transform (Clear Track)" - this unparents the object whilst keeping its current location (often clearing transform in the simple sense relocates meshes back to their original position which can cause subsequent issues). Alternatively unparent using menu: "Object » Clear » [apply option]".

Once all meshes are un-parented, to use "Apply...";

In Blender 2.45; select the mesh or meshes and press "Ctrl+A". In the "OK?" confirmation pop-up that appears, click "Apply Scale and Rotation". Alternatively use menu option "Object » Clear/Apply » Apply Scale/Rotation" or "Object » Clear/Apply » Apply Deformation".

In Blender 2.49; make a selection and press "Ctrl+A". From the "Apply Object" pop-up that appears, select "Scale and Rotation to ObData" or "Visual Transform to Object Loc/Scale/Rot". Alternatively use menu option "Object » Clear/Apply » Apply Scale/Rotation to ObData" or "Object » Clear/Apply » Apply Visual Transform".

In Blender 2.54+/-; make a selection and then press "Ctrl+A". From the "Apply" pop-up that appears click each "Location", "Rotation" and "Scale" or "Apply Transform". Alternatively use menu option "Object » Apply » Location/Rotation/Scale".
In Blender 2.6+ and newer; make a selection and press "Ctrl+A". From the "Apply" menu that appears click "Rotation & Scale" (preference - note also, "Location" is implied when using this option) or "Visual Transform". Alternatively use menu option "Object » Apply » Rotation & Scale" or "Object » Apply » Visual Transform".

Once done, re-parent the mesh or meshes back to the Armature. Make sure this is done properly and with respect to whichever version of Blender is being used; for Blender 2.49 or below select mesh first, Armature last then use "Ctrl+P" to Parent the two together (choosing to create, or not to create, Vertex Groups as desired).

For Blender 2.5+ (including latest versions); select a mesh then from "Object Modifiers" Properties click "Add Modifier". Select "Armature" from the "Deform" list. Once added, in the now available modifiers properties click the "Object:" input field and select the named Armature associated with the Object to create the 'parent' link or association. This is necessary for export. For WYSIWYG production purposes however,  meshes may still need to be parented to the Armature in which case simply select the Mesh and Armature in sequence, then press "Ctrl+P". In the pop-up that appears click "Object" or "Object (Keep Transform)" - note that absent an "Armature" Modifier assignment a number of 'vertex group' options may be display; if the object already has vertex groups assigned make sure to select "Object" or "Armature Deform » With Empty Groups" (this auto-assigns an "Armature" Modifier to the selected mesh absent associated vertex groups).

Note that for newer versions of Blender, mesh and Armature parenting is typically done for simple WYSIWYG animation sequence creation and editing so will likely already be assigned or reassigned at some point during production. Traditional mesh/armature Parenting is however, optional if an "Armature" modifier is properly assigned to a mesh.

MESH PREP Vertex Groups: Double-check vertex group assignments. Problems typically arise from this when group names don't match those of associated Armature bones, are either missing, or surplus to requirements, manifesting as the do through malformed meshes where vertices are attached to the 'root' bone of the armature (export defaults to assigning incorrectly named vertices to the 'root' bone of an Armature).

MESH PREP Triangulation: Depending on the MD5 script version and Blender iteration combination, meshes may need to be "Triangulated" before export. This can be done at any point during the production process but it best done prior to mesh parenting and animation. For later versions of both the MD5 script and Blender, export can remain in "Quad" form as the process is able to automatically process the mesh, tessellating it for use. An important point to note in being able to do this; newer versions of Blender allow the creation of "nGons", surfaces with more than four vertices or edges, which typically halt the export process with an 'uv' or 'texture' surface error. If this happens ensure there are no multi-sided surfaces present in the mesh beforehand.

MESH PREP Materials, Textures & UVW Maps: depending on the MD5 script versions meshes should have a single Material with a single Texture slot assigned to a single UVW Map. In instances where multiple-materials or multi-materials are assigned/required the mesh will need to be broken down into a series of individualised mesh sections corresponding to the material assignments, e.g. assigning a "Head" and "Body" material would result in the mesh needing to be split into corresponding "Head" and "Body" mesh sections. In such instances ensure each section is 'closed', i.e. there should be no holes or gaps in the mesh (check vertex weighting and mesh deformation in doing so).

MESH PREP Material, Texture, UVW names/ID's: the 'names' given to a dataBlock is relatively important; all Objects or Properties have to have an associated unique identifier (an "ID" in Blender) which ideally needs to make sense relative to the game world. For example. When a model contains two or more Materials, each must be identified uniquely via their respective dataBlock 'name' ("ID") and, be valid. What does this mean?. Naming the aforementioned Materials "floorWood" and "floorTrim" is considered valid, whereas "floorWood.001", "floorTrim.001" or any ID displaying Blenders auto-appending numeration - this is where Blender appends a numerical value to a duplicate dataBlocks making them 'unique' - is not and will likely cause issues after export.

In addition to the above general requirement, because the resulting MD5 material/texture slot information is typically pulled from Blender's Material slots, names can also be single words, "floorWood", or a 'path', usually to a shader or game material reference, "textures/castle/floorWood" (subject to alpha-numerical character limits in Blender), both of which can be referenced with or without a 'file-type' append, ".tga" for example - "floorWood.tga" or "textures/castle/floorWood.tga".

Beforehand then, make sure dataBlock information is properly prepped relative to this guideline; the use of multiple materials, multiple textures and/or multiple UVW maps (where supported), requires each to be identified uniquely, without any auto-appended numeration, and as a single word of 'path' as required.

ARMATURE: check bone names, parenting relationships and IK or Constraint modifier properties. Note also that even though objects can be animated using IK etc., the additional bones often used to facilitate this may cause export or usage issues in game (bones not explicitly associated with articulation may cause issues).

EXPORT: export is selection based so both the Mesh Object (or 'Objects' in instances where multiple meshes need to be exported) and Armatureto be saved need to be selected; it is preferable for the mesh to be selected last (it highlights a brighter orange) - note however, that either/or may work depending on the script version.

To export a selection to MD5; from the "File" menu, select "File » Export » Quake Model 5 (.md5)" (or latterly "File » Export » idtech4 MD5 (.md5mesh & .md5anim)"), a "File Browser" view will open. Change the file name (it may not be necessary to include the *.md5mesh/*.md5anim file extension [check script version]), set the "Scale:" value as needed (or preferentially leave at default "Scale: 1.0000" to export actual size/1:1). And finally select whether to export either individual "*.md5mesh" or "*.md5anim" files, or both together before then clicking "Export" top-right. Once done Blender will return back to the previous View/Editor.

Extended Usage
The correct animation set up inside Blender depends on the game engine or development environment being used or worked on as that will determine how multiple animation sequences are referenced. There are basically two ways to export;
  • 1) As a series of individual animation
  • 2) As a grouped or inclusive animations
1) When a series of individual animation sequences are required, each 'Action' will need to be exported as a separate *.md5anim file. For example, exporting a character with a "run", "walk" and "jump" cycle would result in four separate files - three *.md5anim files, one for each 'Action', and one *.md5mesh.

2) When animation sequences are to be included in a single track, care must be taken to properly delineate the 'start' and 'end' point of each 'action' in Blender as well as the development environment (1-99 = 'walk', 100-199 = 'run' and so on). Exporting this type of data results in a single *md5anim. Exporting a character with "run", "walk" and "jump" cycle would result in two files -  one *.md5anim file containing all the necessary delineated sequences, and one *.md5mesh.

Exporting animations
The MD5 script only exports the currently active action. Before export ensure the correct Action sequence datablock is assigned to the Armature (or active in the "Action Editor" timeline - see below). Ensure the "Start:" and "End:" points of an Action are set in the "Frame Range:" sub-section of "Render Properties" (panel to the right of the screen).

The "Action" editor is now a sub-editor of the "Dopesheet" editor. The DopeSheet first needs to be set as the active Editor view, then within this select "Action Editor" from the "Editing Context" drop-down menu in the Header. Once done, edit/delete/create new functions as required.

Selecting the "Action Editor" as a "Mode" of the main "DopeSheet"

Selecting a specific "Action" animation in the "Action Editor"

Limitations
Scripts may have limitations and/or compatibility issues when used incorrectly (in the wrong version of Blender), or where features are not available or present in others version. Check that;
  • the correct script is being used per Blender version
  • animation is correctly set-up relative to single or multiple files (see above)
  • models correctly prepped - smoothing, materials, UVW maps should be present
If unsure as to what animation sequences are available, switch a window/view to display the "Outliner" Editor. In the Header, click the "Type of Data to display" drop-down menu (defaults to show "All Scenes") and select "Datablocks" from the list. Find "Actions" and click the "+" to its left, expanding the block to reveal all sequence data saved in the file.


Misc
Archived MD5 import and export scripts are available on the Tools page.

MD5 Models, Multiple Textures/Materials

MD5 & Multiple Meshes (Blender)