Exporting Meshes From Blender 2.49b (Old Guide)
WARNING: This is an old article for an outdated version of Blender! Please refer to the new article instead.
Exporting a model properly for OpenClonk can be a tricky process, but we've compiled a step-by-step guide on how to do so.
Firstly, you'll need the proper tools. For Blender 2.49b, you'll need the OGRE Exporter. Randrian has created an improved version of the OGRE Exporter which adds critical features necessary for animation blending. Download Link
- Extract the OGRE Exporter into your .blender/scripts/ folder.
- Install Python 2.6.2
- Obtain the OGRE XML Converter software, bundled inside the OGRE Command Line Tools package (look in 'See Also' box for download).
- Extract the OGRE Command Line Tools somewhere easily accessible (ie: C:\OgreCommandLineTools).
- Load up blender, and create a new window and set the window type to 'Scripts Window'. Then click File>Export>OGRE Meshes to load the exporter GUI into that window.
- Hit the 'Preferences' button in the OGRE GUI. Set the location of the OGRE XML Exporter to Manual, and link to the location of the OgreXmlConverter.exe.
- In the directory of your .blend file, create an empty Actions.txt file. More on this later.
By following these steps, you should be able to properly export models for OpenClonk. If you run into any problems, leave a post on the forum addressing the issue.
Guidelines for Modelling
- Model on the Y/Z view-plane. Models in OpenClonk appear as they do on the Y/Z plane in blender. The X-Axis goes 'into' the screen. Make sure you model with regard to these axes (The Y/Z plane is the default side view in Blender).
- Do not use Mesh Transformations. Mesh transformations are not handled properly by the OGRE exporter, and will cause deformation in game. If you have transformations applied to an existing model, you can remove them (select the model and press alt+g, alt+s, alt+r). Caution: Avoid animating before removing transformations!
- 3D Model must be Three-Dimensional. The 3D mesh must have length on all axes. Making a perfectly flat object on only two axes will cause it to not appear in-game. To fix this, move a vertex so the mesh has length on all axes.
- Avoid edges with more than two faces connected to them. Edges with more than two faces will cause shading errors in game. An easy way to circumvent this is to separate the third face from the edge, so it is close to the original edge, but not connected.
- What features work with the OGRE format? Not all of the features listed in Blender will affect an exported 3D OGRE mesh. For a full list of compatible features, visit: http://www.cs.ucr.edu/~macchiea/cs134/lab1/ogrehelp/ogremeshesexporter.html
Exporting the Model
To export the model, you'll need to have a window for the OGRE exporter in Blender. Make a new pane for scripts, and click 'File/Export/OGRE Meshes'. Models used for OpenClonk must be exported with specific options.
- “Fix Up Axis to Y” should not be enabled.
- If you have the XML converter, make sure “OgreXMLConverter” is enabled.
- If you have already made manual modifications to the Scene.material file and are re-exporting the mesh and/or skeleton, make sure 'Export Materials' is not enabled.
- 'Path:' will be where the OGRE files are exported to. You can use a temporary directory and then copy them into your OpenClonk object definition, or you can export the OGRE files directly into the object definition.
Using the Exported Files
Once you have exported the mesh, some files will be created in the chosen directory. Follow these steps:
- Make sure the “ .mesh” file is named “Graphics.mesh”.
- If you exported the OGRE files to a temporary directory, copy 'Graphics.mesh', the ' .skeleton' file, the 'Scene.material' file, and any textures used by the mesh to your object definition.
- If you have exported the OGRE files directly to your object definition, you can delete all .xml files and the .log file.
Scene.material
Scene.material is the file which defines which materials to apply to meshes. Manually modifying Scene.material is crucial to the mesh appearing properly in game. When you export (assuming you are using a texture) your Scene.material file will look more or less like this (don't worry if it looks somewhat different):
material MyCube { receive_shadows on technique { pass { cull_hardware none scene_blend alpha_blend ambient 1.0 1.0 1.0 1.0 diffuse 1.0 1.0 1.0 1.0 specular 0.0 0.0 0.0 0.0 12.5 emissive 0.0 0.0 0.0 0.0 texture_unit { texture MyCube.png tex_address_mode wrap filtering trilinear } } } }
- If 'depth_write off' exists, delete that line.
- If you are using alpha, make sure 'scene_blend alpha_blend' exists (as shown above).
- If your mesh has visible backface(s), make sure to add 'cull_hardware none' (as shown above).
- Depending on the method you used to define alpha in blender, the 'pass' section in Scene.Material may look like this:
pass { ambient 0.500000 0.500000 0.500000 0.000000 diffuse 0.640000 0.640000 0.640000 0.000000 specular 0.500000 0.500000 0.500000 0.000000 12.500000 emissive 0.000000 0.000000 0.000000 0.000000 ...
If so, make sure the fourth parameter on ambient, diffuse, specular, and emissive is '1.00000', not '0.000000' (as shown in the 'material MyCube' example).
Actions.txt
This file controls what animations are exported, which frames of said animations, and which bones will be affected by the exported animations. Most often than not you will not need to use this functionality; your Actions.txt file could simply resemble this:
[Action] Name=Open [Action] Name=Close [End]
Other tags available for an [Action] include 'Start=', 'End=', 'ExportName=', and 'Group='.
Start and End will define the frames (in blender) that will be exported. ExportName will simply change the name of the Action on export (Useful if you have multiple versions of an animation but only need one exported).
A group is a special filter used to stop bones from affecting the exported animation. For example, if we want an aiming animation to only affect the upper body, or a blinking animation to only affect the character's eyelids. Groups can either use the 'Include=' tag or 'Exclude=' tag.
As an example, a group which only affects the eyelids of the Clonk:
[Group] Name=Eyelids Include=eye_lid.R Include=eye_lid.L
This would make the exported animation only control the eye_lid.* bones and nothing else. Conversely, using the 'Exclude=' tag makes the animation use every bone excluding those defined. As an example:
[Group] Name=UpperBody Exclude=skeleton_leg* Exclude=skeleton_foot*
Defining the group in an Action entry is fairly simple; just add the tag 'Group=' and enter the group's name. For example:
[Action] Name=CloseEyes Group=Eyelids
For an example of a finished Actions.txt file, this is the Catapult's.