View page as slide show

Ogre Asset Management

Scene Manager

  • Handles the scene
  • Provides methods to create and handle most elements in the scene
    • Cameras
    • Lights
    • Scene nodes
    • Entities based on meshes
  • Links to managers to provide content

Specialized Scene Managers

  • Terrain-based
    • See Demo_Terrain
      • media/terrain.cfg
      • media/Materials/textures/terrain*
  • Indoor scenes
    • See Demo_BSP (uses Quake3 maps)

Resource Managers

  • Only one of each type - > “singleton” pattern.
  • Most used types
    • MaterialManager
    • TextureManager
    • MeshManager
  • Search for resources in predefined locations (specified by default in “resources.cfg”).
  • Search locations can be specified on a different file, or added in code

Elements on a scene

  • A Mesh is a collection of geometry, that can consist of a series of sub-meshes, each with a default material defined.
  • An Entity is an instance of a movable object in the scene, and is based on a Mesh.
    • If you want multiple copies of the same mesh, you must create multiple entities using the same mesh. The mesh is loaded only once.
  • An Entity will be divided in as many sub-entities as its base mesh is divided in sub-meshes

Elements on a scene

  • New materials can be assigned to sub-entities, to create individually-looking copies of the same geometry
  • Entities have to be attached to a SceneNode to be rendered. Geometric transforms are applied to the SceneNode
  • In the end:
    • SceneNode
      • Entity
        • Mesh
          • Skeleton
      • Material

Create a mesh

  • Convert existing meshes in other formats via the above tools
  • Create meshes in code (hard, useful for procedural modelling)

Results from DCC Tools

  • In the end you should have all or some of the following:
    • a .mesh file
    • a .material file
    • texture files (jpg, png, etc.)
    • .skeleton files (if skeletal/bone animation is included)

Entities and Materials

  • Create an Entity based on a Mesh (mesh is automatically loaded by the MeshManager)
    Entity * ent=mSceneMgr->
                  createEntity("MyEntity", "robot.mesh"); 
                     //entity internal name, mesh file name
  • Change the Material of an Entity
    ent->setMaterialName("DifferentMaterial");  
                          // material name

How to create a material?

  • Using Material scripts (.material) produced by an exporter/DCC tool
  • In code (more control, less practical, typically used for changing materials in runtime)

SceneNode's and Entities

  • There is a Root SceneNode created by default
  • Other SceneNodes should be created as a child of the Root SceneNode, or of another previously created SceneNode's
        mSceneNode = mSceneMgr->getRootSceneNode()
                          ->createChildSceneNode();
  • Attaching an Entity to a SceneNode
        mSceneNode->attachObject(ent);

SceneNode's transformations

  • Transforming SceneNode's
        mSceneNode->translate(...);
        mSceneNode->rotate(...);
  • Important note
    • Dynamics are not covered by this. For that, wrap/include the SceneNode/Entity/Mesh in a class (e.g. ApplicationObject) that describes physics/dynamics properties of the object

Overlays

  • Ogre provides Overlays for simple 2D geometry/content.
  • An overlay is composed of:
    • Containers - Panel, BorderPanel: rectangular areas that can be nested and have textures and borders, and include TextArea's
    • TextArea - A text element, that can be static or updated in code, and must be in a container
  • Overlays can be created in code or in .overlay scripts
  • Typically layed out in scripts, and contents updated in code (e.g. scoreboard)
  • For scripting details, check the manual and see the examples on your media folders:

Modifying in code

  • Overlay scripts in the resource paths are loaded by default
  • Accessing/changing elements:
    OverlayManager* omgr = OverlayManager::getSingletonPtr();
    Overlay *  mLoadingDescriptionElement = omgr->getOverlayElement("Load/Description");
    mLoadingDescriptionElement->setCaption("Parsing scripts...");

Brief note on GUI

  • Ogre includes CEGUI for the creation of GUI's
  • CEGUI is elaborate, and allows the creation of skins, but they are hard to create and there are very few available
  • Another interesting option is MyGUI, but is not included (you can add it to your project)