User Tools

Site Tools


public:t-gede-12-1:lab_2

Lab 2: Getting Meshes and Materials into Ogre 3D

Required Tools

  • Blender 3D modeling and rendering environment, use the latest version
  • Blender2Ogre Plug-in for Blender 2.5 and above
    • Download the file blender2ogre-0.5.5.zip
    • Run Blender and from File→User Preferences… choose the Addons panel and click the Install Add-On button. Navigate to and select your downloaded ZIP archive.
    • Once Blender has processed the ZIP file you should see the exporter listed, but grayed out. Check the check-box next to it to activate it.
    • Now you can run the exporter from the Blender File→Export menu (pick the Ogre 3D export) and make sure that the object you want to export has been selected in the 3D scene.
  • Make sure that the OgreXMLConverter.exe (or OgreXMLConverter_d.exe) is in your executable system path, you will find this tool inside your built Ogre system in a folder called bin\Release (or bin\Debug)

What to Do in this Lab

The Procedure

  1. Go to your personal Ogre application folder (where the executable for your own Ogre application sits) and do the following:
    • Create a new sub-folder called Models
    • Add the line FileSystem=Models in the Popular section of your application's resources.cfg (This tells your application that it should search for named resources in this folder)
  2. Create a model in Blender (even just use the default cube you get when you start up Blender)
    • There is a lot of good resources on Blender modeling, including the Official Getting Started tutorials
    • It is a good idea to save your model in the Blender file format early and often
    • Pay attention to what you name your geometry, this becomes the name of the exported mesh
  3. Export the model using the Blender2Ogre exporter and save it in your Models folder
    • Make sure that any texture imported, baked or generated is saved as a file in the same folder
  4. Run the OgreXMLConverter command line tool on the exported XML mesh file to turn it into a binary Ogre mesh file
  5. Create an Entity in your Ogre application from the mesh you just exported
    • In C++ it would look like this:
        Ogre::Entity* mycube = mSceneMgr->createEntity("MyCube", "MyCubeMesh.mesh");
        Ogre::SceneNode* cubeNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
        cubeNode->attachObject(mycube);
	cubeNode->setScale(50,10,50); // You may have to scale your object to see it well
  1. Make sure you see your object when you run your application!

What to Try

Here are things you should now play with:

  • Open up your exported mesh XML file and make sure you understand its structure
  • Try changing values inside the exported mesh XML file and observe the changes in your Ogre application, but remember to run the OgreXMLConverter again!
  • Notice that inside the XML file the submesh refers to a Material by name, find the corresponding *.material file in your model folder (it got exported along with the mesh XML file) and read through it. This is the material that Ogre reads in along with the mesh.
  • Try changing values of the material (e.g. the diffuse values) inside the exported material file and observe the changes in your Ogre application (you do not have to run the OgreXMLConverter again for this, the material is already in the right format)
  • Create a new material inside the same material file, by copy-pasting the material definition and changing its name (e.g. into BlueMaterial) and give it different values (e.g. making the diffuse color blue).
  • To test this new material, you can simply assign it to any entity in your Ogre application with the setMaterialName method like this:
    myCube->setMaterialName("BlueMaterial");
  • See if you can create several entities from your original mesh, but assign different materials to each of them
/var/www/ailab/WWW/wiki/data/pages/public/t-gede-12-1/lab_2.txt · Last modified: 2012/02/02 14:08 by hannes