A comprehensive look at creating, exporting, and rendering dotScene using blender and yake 0.5.0 beta 1
Organizing multiple mesh's, lamps, and cameras into scenes has been made relativly simple with the creation of the dotScene format. This tutorial is geared toward providing insight into creating these scenes using blender and then rendering them graphically using yake. Some prior knowledge of yake and blender is recommended.
The blender file used in this tutorial can be found here.
Open blender. Unless you have configured the workspace, a default mesh cube should be present.
Press 'X' to delete this object while in object mode, and select yes.
Press the spacebar and select Add → Mesh → Plane. If you are not in object mode, you will only see Add → Plane, if so, hit the Tab key to switch from edit mode back to object mode.
Press 'Ctrl + W' to save.
You will notice that blender automatically switched you to edit mode. Press 'S' to scale the plane to roughly 10 times it's size. Try holding 'Ctrl' while scaling. Click the mouse to complete the scaling.
Press the Tab key to return to object mode, and add a cube. (Spacebar - Add → Mesh → Cube) It is important that you are in object mode when you do this, because this will create a new object, rather then adding to the pre-existing object.
Press '1' on the NumPad to enter front view, and press 'G' to grab the object so we can move it. While moving an object, you can press either 'X', 'Y', or 'Z' to constrict movement to a certain axis. In this case we want to constrict movement to the Z axis, so press 'Z' and hold 'Ctrl' as well while moving the object to snap it to the grid. Move the cube up so that the cube is above the plane.
You should be in edit mode with the cube selected. Hit 'F5' to view the shading buttons below the 3d view.
Click 'Add New' under 'Links and Pipeline' to add a material to our cube. This tutorial will not go into detail on materials and textures.
Press '7' on the NumPad to enter top view and press the Tab key to switch to object mode. Right click the plane to select it and switch back to edit mode.
Repeat step 9 to add a material to our plane.
Press '0' on the NumPad to get a rough idea what our scene will look like from the camera.
Press 'F12' to render our scene with blender.
Save the scene (Ctrl + W)
An archive of the files exported can be found here.
Note: If you don't already have them, download the
BlenderExport and
BlenderSceneExporter scripts and add them to the scripts directory. Default path of this directory in Linux is blender/.blender/.scripts. To automatically convert the xml files on export, set the OGRE_
XML_CONVERTER script variable to a command line that executes the OgreXMLConverter tool, for example:
# OGRE_XML_CONVERTER
# the command line used to run the OgreXMLConverter tool.
# Set to to disable automatical conversion of XML files.
OGRE_XML_CONVERTER = 'OgreXMLConverter'
Press 'A' to deselect all objects, and then 'A' again to select all objects in object mode. You should have the camera, lamp, plane, and cube highlighted.
Select File → Export → Ogre3D Scene in the top left corner of your workspace. You should now see the scripts window.
Make sure all the objects are selected, and edit the save path if necessary. Click Export.
Click Ok and then Quit to return to 3d view.
In object mode, right click the plane. While holding 'Shift' right click the cube.
Select File → Export → Ogre
XML opening the scripts window again.
Set the RotX to -90.
Click Export, Ok, Quit.
Rename the scene file from Scene.xml to Scene.scene, and convert the OgreXML files to mesh's if blender doesn't automatically. You should have a Scene.scene file, a Scene.material file, a Cube.mesh file, and a Plane.mesh file.
An archive of the source files can be found here.
If there are any problems with the below code feel free to modify it or contact me(capture on the forum).
It is very simple to render a dotscene once you have set up an application. You can find out how to set up an application elsewhere, so this tutorial will not go into it. Instead it will give the littlest code required to render a dotscene.
//create model manager and a model
model::ModelManager mModelMgr;
model::Model* mModel;
//set up the model manager
mModelMgr.setCreationContext_GraphicalWorld( getGraphicalWorld() );
//Now load the .scene and render it !
mModel = mModelMgr.createModel( "modelname", "graphics/dotScene:name=graphicalWorld;file=filename withlocation.scene" );
YAKE_ASSERT( mModel );