Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ogre Overview.

Similar presentations


Presentation on theme: "Ogre Overview."— Presentation transcript:

1 Ogre Overview

2 What is it? Object-Oriented Graphics Rendering Engine
Not a game engine – we'll add that! Implements much of what your learned about in ETGG280x Shadows Hierarchical Transformations (with culling and material optimization) Optimized scene managers (tileable-terrain, BSP, etc). Plugin architecture allows many custom managers Billboards / overlays Shader support Skeletal (forward kinematics) animation particle systems C++ oriented It's large, but well-designed. Cross-platform (linux, iOS, OSX, …) using DirectX / OpenGL Easy to integrate other libraries Python (scripting) Bullet (physics) irrklang (3d sound) SDL (windowing, input) MIT license

3 First steps Create a window (SDL) – Lab01
Include rudimentary input support (keyboard) Initialize Ogre (and it's subsystems) – Lab02 Make Ogre render to the SDL window Render a simple scene Update the scene – Lab03 (we'll look at transformations here)

4 Part I: SDL To Lab1 !! Our goal: Create a window
Rudimentary input (escape key presses and close button) No drawing

5 PartII: Add a dash of Ogre…
Ogre can be a bit intimidating Turns a lot of people off I'll list here my top-6 "things" to know about in Ogre. Our goal (Lab2): Let Ogre create a window and make SDL capture the input for it. Initialize Ogre Load a mesh and a light source and display in 3d.

6 II.a The Root The only object you directly allocate in Ogre
Ogre::Root * mRoot = new Ogre::Root("plugins.cfg"); (Make sure you deallocate it when the program ends…) The root contains all of the top-level managers TextureManager, GPUProgramManager, … The render window (if any) The scene manager (if any) So…this is technically the only Ogre variable you need to store. Although, saving some convenience programs is usually desirable. Plugins.cfg [Look at it and describe it]

7 II.b Render Window In our apps, we'll have two window objects (but only one window) Ogre Window: an actual window SDL Window: attached to the ogre window (detects input) Steps Call mRoot->showConfigDialog() (sets render settings like screen size). Call the "initialise" method of the root (tell it to auto-create a window) Get the window handle from it #include <windows.h> // Maybe only if WIN_32 defined??? HWND hwnd; mRenderWindow->getCustomAttribute("WINDOW", &hwnd); Create an SDL "window" from hwnd SDL_CreateWindowFrom((void*)hwnd);

8 II.c The Scene Manager The scene manager organizes / optimizes all the renderables Lights, camera, meshes (entities) [including the materials attached], particle emitters, etc. Hierarchical Each (scene) node must be a child of the scene manager's root node You can also have children nodes of those scene nodes as well. If you transform one node, everything below it is transformed [Example scene] Optimizes GL/DX calls: material swaps, rendering, occlusion-culling, etc. Several different types: Octree, BSP, Terrain, etc. mSceneManager = mRoot->createSceneManager(Ogre::SceneType::ST_GENERIC);

9 II.d Viewports and Cameras
They are separate objects, but closely related Viewport: A rectangular portion of the window (with a z-value for layering) Created through the render window Camera: A 3d object created by the scene manager Must be attached to a viewport to render to it.

10 II.e Resources (e.g. Materials)
You specify where resources are located like this: Ogre::ResourceGroupManager::getSingleton().addResourceLocation("..\\media", "FileSystem"); You parse (and load?) all resource files like this: Ogre::ResourceGroupManager::getSingleton().intialiseAllResourceGroups(); Some important resources: [Each has its own manager] .material file. Contains settings and links to textures shader programs .mesh file. A binary (optimized for reading quickly) mesh file. Has a link to a .material file.

11 II.f Entities and Meshes
Ogre has a generic class called Moveable. A number of classes are derived from it: Camera, Entity, Light, ParticleEmitter, … You create pointers to each of these through the scene manager (and then attach to a scene node) Ogre is managing the memory. You can either call a method (of the scene manager) to destroy it or wait until shutdown. Every Moveable object must have a unique name (across that type or globally?) An Entity is an instance of a mesh. The actual mesh data is loaded once (into a vertex/index buffer) It can be referenced with multiple entities, each with their own material (optional) Each Entity also can have independent "activations" of skeletal animations.

12 II.g (Scene) Nodes As mentioned, the scene manager has a single root scene node. Access it with mSceneManager->getRootSceneNode(); Only things attached to a scene node which is a child of the root will be rendered. Each scene node has a transformation matrix (3x4) that contains: rotation scale translation You can modify the matrix directly, or more commonly through a helper function: setPosition setOrientation(Quaternion q); setScale You can attached any instance of a class derived from Moveable using the attachObject method.

13 To Lab2!!

14 Side-Topic: Singleton pattern

15 Side-Topic: Observer / Listener pattern

16 Transformations in Ogre.


Download ppt "Ogre Overview."

Similar presentations


Ads by Google