Prerequisites


This tutorial assumes that you can handle Blender with basic modelling and animeting (also with skeletons). This tutorial is really more about exporting successfully animations, meshes and ((-Material|materials) to Ogre.

Tools


First things first. So, before you can export anything from Blender you need proper exporters for them. Current exporters works only with Blender 2.49b.

I'm using two exporters with Blender:

1. Meshes and materials

This exporter basicly turns meshes to XML and then optionally run through OgreXMLConverter, which converts XML to ogre's binary .mesh-format.

You find the exporter on page Blender Exporter.

2. Scene

Usually exporting meshes just isn't enough. Scene describes where objects are locating. More importantly it describes also cameras and lights, so there is no need to worry about them in code.

I decided to use DotScene, because it's very simple XML-format and well supported by community.

Blender's DotScene exporter can be downloaded here.

Let's rock!


First of all, you need something to export. This tutorial uses simple robot mesh, which you can download here (Feel free to mirror it).

To say a word about animating object for Ogre:

I create all actions to start from frame 1 and end where ever it ends. Then I can choose 'current' action by enabling that action in NLA Editor.

nla_actions.png

Also you need to check that armature and animated object are without translations, scaling or rotating (You can check that by pressing N and then select armature and after that object). If they have something wierd rotations and scalings as I had then blender shows animation just fine, but after exporting it acts very wierdly.

If you have object translations or other, you can apply them to object by pressing Ctrl A, 1.

robot.jpg

Above image demonstrates problem with different object properties in armature and model.

Export Everything


If you have many meshes in scene, You need to export them all at once, because otherwise you can loose some materials and existing meshes can't find their material.

mesh_export.png

Open Export dialog File->Export->OGRE Meshes and then select PlayerMesh if not selected, then select Skeleton and press Add for adding animation. Then choose predefined Action Run.
Also you could rename the filename Scene.material in the exporter GUI. The materials will be saved there. Using a scene specific name is good, because it avoids problems, when you have different scenes and each has the filename Scene.material. (So by export the materials of other scenes could be overwritten.)

After that you need information about lenght of animation. You can see it with NLA Editor and buttons window, by moving current frame to end of action in NLA Editor, and check accured frame number in buttons window.

Because action beging at frame 1, there is no need to modify Start-value. After that there is name for animation in Ogre. You can leave it to 'Run'. Other buttons are self-explanatory. But you want to check OgreXMLConverter and set path for that in Preferences.

After that you can just hit Export and wait for rolling all meshes and animations.

Export Scene


scene_export.png

Exporting scene is even easier. Just select all and hit Export button. Just make sure that you have correct Path. You can leave Filename-field empty and it will get that from scene name.

Using scene in Ogre

Now you have successfully created .mesh and dotScene-formated .xml file. Now you just need to import them to Ogre. Meshes works right away, just use them as you would normally do, but dotScene requires specific reader.

I use for dotScene parser a New DotScene Loader.

I did some changes, because it New DotScene Loader wasn't reading my scene file correctly:

Todo: Add the whole modified file as attachement to this wiki page (see buttons on page bottom). This is more easy to use.

Removed diff for dotSceneLoader