# Blender to Ogre Exporter

Blender is an open source 3D content creation suite for modeling, animation, rendering and video post production. The Blender to Ogre Exporter is a python script to run directly within Blender. Currently it supports the export of

- mesh objects with vertex colours, multiple materials, uv textures and blend modes,
- armature keyframe animations.

## Installation

The script needs access to standard Python modules not shipped with Blender. Consult the Blender documentation at www.blender.org how to incorporate Python with Blender.

- Copy the script either into ".blender/scripts" or the user defined scripts directory.
- In the "Scripts Window" run "Scripts -> Update Menus".

## Basic Usage

- In the "3D View" select the objects you want to export.
- In the "Scripts Window" run "Scripts -> Export -> Ogre XML".
- Choose your export options.
- Press the "Export" button.

You will get a detailed log of the export process. Use the OgreXmlConverter to convert the generated XML files to binary .mesh and .skeleton files.

Screenshot of the exporter interface.

### Options

Export Textures
  Export uv texture coordinates and texture names.
Export Armature
  Export armatures and armature animations.
Export Armature as Mesh
  Generate an animated extra mesh in the form of the skeleton.
Material File
  The name of the material script file that will be generated.
Mesh Scale Factor
  All meshs and bones are scaled on export by this factor.
RotX
  Angle of an additional rotation around the x-axis of all objects on export. This rotation is applied first. The default value is -90 degrees. This maps Blender's default up-vector (z-direction) to Ogre's default up-vector (y-direction).
RotY
  Angle of an additional rotation around the y-axis. This rotation is applied second, after RotX.
RotZ
  Angle of an additional rotation around the z-axis. This rotation is applied third, after RotY.
Animation settings of
  Choose an object from the list of all objects selected for export. The animations that will be exported for that object are then displayed in the scroll area below. Each animation correspond to one line.

Action name
  The name of the Blender action.
Start frame (Sta:)
  Start frame of the animation.
End frame (End:)
  End frame of the animation.
Animation export name
  The animation name in the exported Ogre file.
Delete
  Removes the animation from export.
Add
  Add another animation to be exported.

Update
  Updates the list of all objects selected for export from the currently selected objects in the "3D View". Also updates the list of possible actions, deletes animations for removed actions and sets default animations for new actions.
Path
  All generated files of the exporter are written into this directory. Mesh files are named after the mesh object name in Blender with suffix ".mesh.xml". Skeleton files are named after the armature object name in Blender with suffix ".skeleton.xml".
Export
  Export all objects in the list of objects selected for export.
Quit
  Exit from the export script.

The script loads and saves its options to a text buffer "ogreexport.cfg" inside the current .blend file. You can disable this behaviour by changing the script variable KEEP_SETTINGS to 0.

## Specifics

### Mesh

The script supports sticky and per face vertex uv coordinates, smoothed and non-smoothed normals, vertex colours. Each rectangle face is automatically converted into two triangle faces in the exported mesh.

The script does not support subdivision surface (SubSurf) options. To export a SubSurf object, you have to convert it into a Mesh object, "Object -> Convert Object Type... -> Mesh (keep original)".

The script does not support double sided faces (Double Sided/Two Sided). To make a face double sided, select the face in the "Edit Mode", duplicate it ("Mesh -> Duplicate", RMB) and flip the normals ("Mesh -> Normals -> Flip").

### Material

In contrast to Ogre, Blender treats material, uv texture and blend mode separately. Therefore, the name of the exported material consists of Blender's material name (if any), the blend mode and the name of the texture file (if any). The parts of the name are separated with slashs. Only textures assigned in the "UV/Image Editor" will be exported. You don't need to assign a material to a mesh in order to export uv textures. The following mapping is done on export:

#### Material Specific

Blender | Ogre
--- | ---
Amb*AmbR Amb*AmbG Amb*AmbB | ambient R G B
Col | diffuse R G B
Spec*Spe, Hard | specular R G B, Shininess
Emit*Col | emissive R G B
VCol Paint | vertex colours
TexFace | disable ambient, diffuse, specular and emissive
Shadeless | lighting off
ZInvert | depth_func greater_equal
Shadow | receive_shadows on/off
No Mist | fog_override true
Env | depth_func always_fail

Blender's world settings that affect the exported Ogre material are marked green.

Blender's material settings that affect the exported Ogre material are marked green.

#### Face Specific

Blender | Ogre
--- | ---
Textured | texture_unit { texture (image filename without path) }
Invisible | no export
Opaque Blend Mode | scene_blend one zero (Ogre default)
Additive Blend Mode | scene_blend add
Alpha Blend Mode | scene_blend alpha_blend

Blender's face settings that affect the exported Ogre material are marked green.

### Armature

You must have no more than four weighted bone assignments per mesh vertex. If you have more, the script will eliminate the lowest weighted assignments and renormalise the other weights. All vertices must be assigned to at least one bone.

Armature animations are exported based upon keyframe ranges and action names. You can choose any frame as start and end frame of an animation. The script will automatically insert keyframes at the start and end of the exported animation and reverse the exported animation if the end frame is lesser than the start frame. In order to export armature animations of a mesh you don't have to select the armature separately.

The script does not evaluate action constraints. To export an action with constraints you have to convert the constraint effects into ipo keys ("Action Editor -> Bake") and choose the baked action in the animation settings.

Ogre does not support nonuniform keyframe scaling. Ogre does not inherit parent bone scaling by default.

The animation speed in the export in terms of frames per second is taken from the corresponding scene render button.

Blender's format setting that affect the exported Ogre animation is marked green.