ogre tutorial three l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
OGRE Tutorial Three PowerPoint Presentation
Download Presentation
OGRE Tutorial Three

Loading in 2 Seconds...

play fullscreen
1 / 68

OGRE Tutorial Three - PowerPoint PPT Presentation


  • 254 Views
  • Uploaded on

OGRE Tutorial Three. Terrain Sky Fog The Root object. Choose a SceneManager. - To render terrain, set the SceneManager to the TerrainSceneManager In ExampleApplication::chooseSceneManager mSceneMgr = mRoot ->createSceneManager(ST_EXTERIOR_CLOSE);

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'OGRE Tutorial Three' - muncel


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
ogre tutorial three
OGRE Tutorial Three

Terrain

Sky

Fog

The Root object

slide2

Choose a SceneManager

- To render terrain, set the SceneManager to the TerrainSceneManager

In ExampleApplication::chooseSceneManager

mSceneMgr = mRoot

->createSceneManager(ST_EXTERIOR_CLOSE);

- The Root object (mRoot is an instance of Root) is the "core" Ogre object.

(To see UML diagram of the relationships between Ogre objects here.)

- After invoking the function, the Root object then queries the SceneManagerEnumerator to find the SceneManager of the requested type and returns it.

slide3

SceneManager

SceneManagers are not Singletons.

Allow multiple SceneManagers

Display multiple SceneManagers at the same time using multiple Viewports.

The OctreeSceneManager registers itself as ST_GENERIC and overrides the base SceneManager class if the OctreeSceneManager plugin is used.

(The OctreeSceneManager uses a system of culling objects that are not visible and thus it's generally faster than the default SceneManager.)

Remove OctreeSceneManager plugin from plugins.cfg ?

slide4

SceneManager

  • - Use a Root object to create SceneManagers.
  • -OGRE is flexible?
  • install a plugin for creating SceneManagers called “MySceneManager".
  • To create a SceneManager of the type, call:
  • mSceneMgr = mRoot->createSceneManager(
  • “MySceneManager“,
  • SCENE_MANAGER_NAME);
  • - Root::destroySceneManager : clean up a SceneManager
terrain
Terrain
  • SceneManager::setWorldGeometry : create scene

- By using the TerrainSceneManager, it is able to load a terrain configuration which is stored in a file.

Code:

Derive a new class DemoApp from ExampleApplication.

In DemoApp::createScene

mSceneMgr->setWorldGeometry("terrain.cfg");

  • Problems :

(1) Standard lighting not work properly in terrain

(2) Not easy to get Shadows to work

slide6

Options for Terrain Generation

  • The TerrainSceneManager uses Heightmaps to generate terrain.
  • - Specify the heightmap (gray level image)
  • Heightmap.image=imageName
  • Set the texture
    • WorldTexture=imageName
  • Set detail Texture (which is interlaced with the
  • WorldTexture to make the terrain look more realistic.
      • DetailTexture=imageName
  • A more detailed explanation of the terrain config file can be found here.
slide7

Terrain texture

Height Map

Detail texture

slide9

Terrain

With detail texture

Without detail texture

slide10

About TerrainSceneManager

- Designed with paging functionality.

Paging terrain system :

(1) the terrain is broken into chunks

(2) display the portion which can be seen

Advantages:

-> (1) Be able to use a huge world

(2) Maintain framerate

For details, read Paging Scene Manager.

10

slide11

Sky

Three types of sky:

(1) SkyBoxes

(2) SkyDomes

(3) SkyPlanes

To use the Example/* textures for sky,

add the following line to the ExampleApplication::chooseSceneManager:

ResourceGroupManager

::getSingleton()

.initialiseAllResourceGroups();

slide12

SkyBoxes

- A giant cube that surrounds all of the objects in the scene

In createScene():

mSceneMgr->setSkyBox(

true,

"Examples/SpaceSkyBox");

12

slide13

SkyDomes

  • A giant cube is created around the Camera and rendered onto
  • the texture is "projected" onto the SkyBox in a spherical manner.
  • It looks as if the texture is wrapped around the surface of a sphere.
  • Drawback : the bottom of the cube will be untextured
    • >have some type of terrain that hides the base.
  • In ExampleApplication::createScene:
  • mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8);

13

13

slide14

SkyPlanes

- A single plane.

- Best position: be somewhere towards the middle of the terrain and close to the ground.

In ExampleApplication::createScene.

Plane plane;

plane.d = 1000;

plane.normal = Vector3::NEGATIVE_UNIT_Y;

mSceneMgr->setSkyPlane(

true, plane,

"Examples/SpaceSkyPlane", 1500, 75);

14

slide15

Fog

  • When use the TerrainSceneManager
  • - call the setFog function before the setWorldGeometry function
  • - depending on which is called first, a different vertex program will be chosen to create the fog and terrain.
  • When creating fog, it doesn't create a fog entity in empty space.
  • Fog is a filter applied to whatever objects are rendered
  • When nothing is seen -> no fog; only see the background color.
  • To have fog look correct, set the background to the fog color.
slide16

setFog

1st parameter: set the type of fog

2nd parameter: set the color of the fog

3rd parameter: fog density (not used in linear fog)

4th , 5th parameters: specify the range where the fog gets thicker.

16

slide17

Steps to create fog

  • set the background color
  • (2) create the fog
  • (3) If necessary, use the getNumViewports member function to get the number of viewports and iterate through them
  • ColourValue fadeColour(0.9, 0.9, 0.9);
  • mWindow
  • ->getViewport(0)
  • ->setBackgroundColour(fadeColour);
slide18

Types of fog

Two types of fog

(1) Linear fog

(2) Exponential fog

To create a linear fog:

mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 50, 500);

(Remember, this code must appear before the setWorldGeometry call)

18

slide19

Exponential Fog

  • Two types of exponential fog:
  • (1) FOG_EXP
  • (2) FOG_EXP2: IE fog gets much thicker each unit compared to FOG_EXP
  • - set a density for the fog
  • mSceneMgr->setFog(FOG_EXP, fadeColour, 0.0005);
  • mSceneMgr->setFog(FOG_EXP2, fadeColour, 0.0005);
  • Using DirectX Renderer, it completely fogged out
    • calling setFog after setWorldGeometry fixes this.
  • The OpenGL Renderer behaves as documented.

19

19

slide20

OpenGL

Fog

mSceneMgr->setFog(

FOG_LINEAR, fadeColour, 0.0, 50, 500);

mSceneMgr->setFog(

FOG_EXP, fadeColour, 0.0005);

mSceneMgr->setFog(

FOG_LINEAR, fadeColour, 0.0, 50, 5000);

mSceneMgr->setFog(

FOG_EXP2, fadeColour, 0.0005);

Any problems?

There is no fog when there’s no object. (see at the back)

slide21

Problem when Using SkyBox and SkyDome with Fog

  • - The problem: unnatural fog
  • - SkyDomes and SkyBoxes are cubes
  • fog works in a spherical manner
  • Let’s try this:.
  • -Problem one: if the skybox’s setting too small.
  • ColourValue fadeColour(0.9, 0.9, 0.9);
  • mSceneMgr->setFog(FOG_LINEAR, fadeColour, 0.0, 50, 5000);
  • mWindow->getViewport(0)->setBackgroundColour(fadeColour);
  • mSceneMgr->setWorldGeometry("terrain.cfg");
  • mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8, 1000);
  • -Problem two: move the camera aroundnotice the blue coming through on the sides, but not in the middle)
  • Question: How to solve the problem ?
slide24

Fog as Darkness

- Not use sky at all when you set fog, - set the fog to be thick enough so that the sky cannot be seen.

- Set the fog to be very dark

ColourValue fadeColour(0.1, 0.1, 0.1);

mWindow->getViewport(0)

->setBackgroundColour(

fadeColour

);

mSceneMgr->setFog(

FOG_LINEAR,

fadeColour, 0.0, 10, 2000);

mSceneMgr->setWorldGeometry(

"terrain.cfg“

);

tutorial four frame listeners and unbuffered input
Tutorial FourFrame Listeners and Unbuffered Input
  • Use FrameListeners to do things that require updates every frame
  • Use Ogre's unbuffered input system
slide26

FrameLiseners

  • - Use FrameListeners to receive notification before and after a frame is rendered to the screen.
  • Two functions:
  • bool frameStarted(const FrameEvent& evt)
  • bool frameEnded(const FrameEvent& evt)
slide27

Major part of call graph

GameApplication::go()

GameApplication::setup()

Root::startRendering()

Root::renderOneFrame()

Root::_fireFrameStarted()

Root::_fireFrameEnded();

FrameListener::frameStarted(evt)

FrameListener::frameEnded(evt)

Root::_updateAllRenderTargets();

27

27

slide28

FrameLiseners

  • An Application may have two or more FrameListeners.
  • - Cannot determine which FrameListener is called first, second, third...and so on.
  • To ensure that FrameListeners are called in a certain order
  • -> register only one FrameListener and have it call all of the objects in the proper order.
slide29

Example for Constructing a FrameLisener

Derive a new framelistener from ExampleFrameListerner:

Class DemoFrameListener : public ExampleFrameListener {

public:

DemoFrameListener(

RenderWindow* win,

Camera* cam,

SceneManager *sceneMgr)  : ExampleFrameListener(win, cam, false, false) { }

bool frameStarted(const FrameEvent &evt) {

return ExampleFrameListener::frameStarted(evt);

}

……

}

slide30

Registering a FrameListener

  • Create an instance of our DemoFrameListener and register it with the Root object:
  • In ExampleApplication::createFrameListener method, and add this code to it:
  • mFrameListener = new DemoFrameListener(
  • mWindow, mCamera, mSceneMgr);
  • mRoot->addFrameListener(mFrameListener);
  • - The mRoot and mFrameListener variables are defined in the ExampleApplication class.
slide31

FrameLiseners

Root::addFrameListener: add a FrameListener,

Root:: removeFrameListener : remove a FrameListener

Note: add|removeFrameListener methods only take in a pointer to a FrameListener

- FrameListeners do not have names

->Need to hold a pointer to each FrameListener

slide33

“Unbuffered" mouse and key input: call methods in frame listener to query the state of the keyboard and mouse.

  • A problem:
  • If a key is down, action can be taken on this information. However, what happens in the next frame?
  • Is the same key down and do the same thing again?
  • (1) Keep track of whether or not the mouse was also
  • down the previous frame
      • (2) Define a variable mToggle for indicating the state of
      • an action
      • (3) Allow actions to happen after a certain amount of time
      • has elapsed

Unbuffered input

slide34

Specifying unbuffered input mode

Class DemoFrameListener : public ExampleFrameListener {

public:

DemoFrameListener(

RenderWindow* win,

Camera* cam,

SceneManager *sceneMgr)  : ExampleFrameListener(win, cam, false, false) { }

…..

}

ExampleFrameListener's constructor:

 : ExampleFrameListener(win, cam, false, false)

-3rd variable: specify whether using buffered key input

-4th variable: specify whether using buffered mouse input

slide35

Specifying unbuffered input mode

mKeyboard = static_cast<OIS::Keyboard*>

(mInputManager->createInputObject(

OIS::OISKeyboard, false ));

mMouse = static_cast<OIS::Mouse*>

(mInputManager->createInputObject(

OIS::OISMouse, false ));

slide36

Open Input System (OSI)

  • - OSI povides three primary classes to retrieve input:
    • Keyboard, (2) Mouse, and (3) Joystick.
  • - OSI key codes: OSI::KC_* (More details: read KeyCode)
  • - To use the Keyboard and Mouse objects.
  • Steps:
  • (1) Capture the current state of the keyboard and mouse.
  •  In DemoFrameListener::frameStarted:
  • mMouse->capture();
  • mKeyboard->capture();
    • Implement methods to handle key and mouse events.
  • For example,
  • if(mKeyboard->isKeyDown(OIS::KC_ESCAPE)) return false;

36

slide37

An Example:

Control the movement of a camera

Code:

mCamNode->translate(

transVector * evt.timeSinceLastFrame, Node::TS_LOCAL);

Note: the magnitude of the translation should be depended on the amount of time since the last frame.

Otherwise, how fast the movement of the camera would be dependent on the framerate of the application.

37

37

37

37

slide38

Control the rotation of the camera

  • use Quaternions for all rotation operations.
  • use a Quaternion to rotate a vector
  • apply all of the rotations done to the SceneNode to the translation vector.
slide39

Transformation Space

  • Specify which Transformation Space to use to move the object.
  • TS_PARENT : In parent node
  • TS_LOCAL : In object node
  • TS_WORLD: In world coordinate system
  • mCamNode->translate(
  • transVector * evt.timeSinceLastFrame, Node::TS_LOCAL);
slide40

Transformation Space

To move a SceneNode along the direction specified by the orientation

Method one:

mCamNode->translate(

mCamNode->getOrientation()

* transVector * evt.timeSinceLastFrame, Node::TS_WORLD);

Method Two:

mCamNode->translate(

transVector * evt.timeSinceLastFrame, Node::TS_LOCAL);

slide41

Tutorial Five:

Buffered input

  • Use OIS's buffered input
  • Handle keyboard and mouse events
  • by using Listeners.
  • For more information about OSI, read Using OIS article.
slide42

Buffered input

  • - Unbuffered input : every frame the state of OIS::Keyboard and OIS::Mouse instances is queried to see what keys and mouse buttons were being held down.
  • Buffered input: use listener interfaces to inform the program that events have occurred.
  • When a key is pressed, a KeyListener::keyPressed event is fired.
  • When the button is released (no longer being pressed) a KeyListener::keyReleased event is fired to all registered KeyListener classes.
slide43

OSI

  • OIS's listener system : allow one listener per Keyboard, Mouse, or Joystick object.
  • call the setEventCallback function (which we will cover later) multiple times will result in only the last registered listener getting events.
  • If two or more objects have to get Key, Mouse, or Joystick events, write a message dispatch yourself.
  • call the Keyboard::capture and Mouse::capture in the frameStarted method.
  • (OIS does not use threads (or magic) to determine the keyboard and mouse states.)
slide44

The KeyListener Interface

OIS's KeyListener interface provides two pure virtual functions.

(1) keyPressed function (which is called every time a key is pressed)

(2) keyReleased (which is called every time a key is released).

The parameter passed to these functions is a KeyEvent, which contains the key code of what is being pressed/released.

slide45

The MouseListener Interface

  • MouseListener::mousePressed
  • MouseListener::mouseReleased
  • MouseListener::mouseMoved
  • Each receives a MouseEvent object: the current state of the mouse
  • The MouseState (const OIS::MouseEvent &arg) object contains
    • (1) the relative X and Y coordinates of the mouse move,
    • i.e. ( arg.state.X.rel, arg.state.Y.rel )
    • (2) the absolute X and Y coordinates (that is, where exactly on the screen they are).
    • i.e. ( arg.state.X.abs, arg.state.Y.abs )
slide46

Registering keyboard callback and mouse callback

  • The OIS mMouse and mKeyboard objects are already obtained in the ExampleFrameListener constructor.
  • To register the DemoFrameListener as the listener by calling the setEventCallback method on these input objects:
  • mMouse->setEventCallback(this);
  • mKeyboard->setEventCallback(this);
slide47

FrameListener for buffered input

class DemoFrameListener : public ExampleFrameListener,

public OIS::MouseListener,

public OIS::KeyListener

{

public:

DemoFrameListener(

RenderWindow* win,

Camera* cam,

SceneManager *sceneMgr)  : ExampleFrameListener(win, cam, true, true) {

……

……

}

……

bool frameStarted(const FrameEvent &evt) {

if(mMouse) mMouse->capture();

if(mKeyboard) mKeyboard->capture();

return mContinue;

}

} ;

in ExampleFrameListener::ExampleFrameListener

{

mKeyboard->setEventCallback(this);

mMouse->setEventCallback(this);

}

47

slide48

Example for Key Bindings

In DemoFrameListener::keyPressed : It is called with a KeyEvent object when a button of the keyboard is pressed.

bool keyPressed(const OIS::KeyEvent &e) {

switch (e.key) {

case OIS::KC_ESCAPE: mContinue = false;

break;

default:

break;

}

return mContinue;

}

48

slide49

Example for Mouse Bindings

  • Find the mousePressed function
  • - Access to both a MouseEvent and a MouseButtonID.
  • Switch on the MouseButtonID to determine the button that was pressed in mousePressed
  • Mouse key code: OIS::MB_*
slide50

Other Input System:

SDL

  • Cross platform windowing/input systems
  • Support joystick/gamepad input
slide52

CEGUI

  • - Use CEGUI (an embedded GUI system) with Ogre.
  • - Add basic CEGUI functionality
  • Require two libraries: (1) CEGUIBase_d.lib
  • (2) OgreGUIRenderer_d.lib
  • - add them to the input of the linker (debug_mode)
  • - for release mode, remove the _d on them
  • See CEGUI home page for more information.
slide53

Introduction to CEGUI

  • A fully featured GUI library
  • Can be embedded in 3D applications such as Ogre (it also supports pure DirectX and OpenGL as well).
  • Highly customizable -> allow to define the look and feel of the application by changing its skin.
  • Only a GUI library -> not do its own rendering nor do it hook into any mouse or keyboard events.
    • (1) To render the content of CEGUI
      • provide a renderer for it (which is the OgreGUIRenderer library included in the SDK),
    • (2) To let it receive mouse and keyboard events
      • manually inject the events into the CEGUI system.
  • (3) Advantage:
      • have full control over the rendering and the input
slide54

Initializing CEGUI

  • To initialize CEGUI, (1) get a renderer and (2) create a CEGUI system.
  • In createScene:
  • mRenderer = new CEGUI::OgreCEGUIRenderer(
  • mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
  • mSystem = new CEGUI::System(mRenderer);
  • - Select the skin (to download CEGUI skin from their website):
  • CEGUI::SchemeManager::getSingleton()
  • .loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");
  • Set the default mouse cursor image and the default font:
  • mSystem->setDefaultMouseCursor(
  • (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  • mSystem->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");
slide55

Mouse Cursor

Two ways to display a mouse cursor:

(1) use CEGUI to display the mouse cursor

(2) create the mouse cursor using Ogre directly

To set the default mouse cursor,

call MouseCursor::setImage

slide56

Injecting Key Events

  • - CEGUI does not handle input in any way.
  • It does not read mouse movements or keyboard input.
  • -> the user should inject key and mouse events into the
  • system
  • -> both the keyPressed and keyReleased functions should be modified.
  • Work with CEGUI,
    • set the mouse and keyboard as buffered mode
    • -> receive the events directly and inject them as they happen.
  • Both OIS and CEGUI use the same key codes for keyboard input -> not necessary to convert the key
slide57

keyPressed

  • In keyPressed :
  • CEGUI::System *sys = CEGUI::System::getSingletonPtr();
  • sys->injectKeyDown(arg.key); // (1): inject down event
  • sys->injectChar(arg.text); // (2): actual character
  • After getting the system object,
  • Do two things
  • Inject the key down event into CEGUI.
  • Inject the actual character that was pressed.
    • Injecting the key down will not always bring about the desired result when using a non-English keyboard.
    • The injectChar was designed with Unicode support.
slide58

keyReleased

  • Inject the key up event into the system.
  • In keyReleased:
  • CEGUI::System::getSingleton().injectKeyUp(arg.key);
  • Note : do not need to inject a character up event, only the key up event is required.
slide59

Converting and Injecting Mouse Events

  • Different mouse button codes between OIS and CEGUI.
  • Three steps: - (1) convert OIS button IDs into CEGUI button IDs
  • - (2) inject mouse button presses into CEGUI
  • - (3) inject mouse movement into CEGUI
  • (1) Convertion function:
    • CEGUI::MouseButton convertButton(OIS::MouseButtonID buttonID) {
      • switch (buttonID) {
      • case OIS::MB_Left: return CEGUI::LeftButton;
      • case OIS::MB_Right: return CEGUI::RightButton;
      • case OIS::MB_Middle: return CEGUI::MiddleButton;
      • default: return CEGUI::LeftButton;
      • }
    • }
  • (2) Injecting inject mouse events. In mousePressed:
  • CEGUI::System::getSingleton().
  • injectMouseButtonDown(convertButton(id));
slide60

Injecting Mouse Movement Events

  • (3) injecting mouse motion into CEGUI.
  • In mouseMoved:
    • CEGUI::System::getSingleton()
    • .injectMouseMove(arg.state.X.rel, arg.state.Y.rel);
  • The OIS::mouseMoved handler gives those relative movements in the state.X.rel variable and the state.Y.rel variables.
  • After the three steps: CEGUI is fully setup and receiving mouse and keyboard events.
slide61

Windows, Sheets, and Widgets

(1) In CEGUI, everything that is displayed is a subclass of the CEGUI::Window class

(2) A window can have any number of children windows.

->This means that when you create a frame to contain multiple buttons, that frame is a Window.

-> Can place a button inside another button,

(3) Not necessary to create each individual object through code.

(4) Create a GUI layout for the application in an editor such as the CEGUI Layout Editor.

After placing all of the windows, buttons, and other widgets onto the screen, the editor saves the layout into a text file.

- Load the layout into what CEGUI calls a GUI sheet (which is a subclass of CEGUI::Window).

Remark: read CEGUI website for more information.

slide62

Loading a Sheet

  • The WindowManager::loadWindowLayout:
    • load the sheet and puts it into a CEGUI::Window object.
  • (2) call CEGUI::System::setGUISheet to display it.
    • CEGUI::Window* sheet = CEGUI::WindowManager::
    • getSingleton()
    • .loadWindowLayout((CEGUI::utf8*)"ogregui.layout");
    • mSystem->setGUISheet(sheet);
  • - To retrieve this sheet, call System::getGUISheet.
  • To swap the GUI sheet, call System::setGUISheet
    • Have to maintain the sheet pointer(s)
slide63

Mannually Creating an Object

  • Example, adding a Quit button
  • (1) Create a default CEGUI::Window containing all of the widgets.
  • (2) Add code to createScene:
  • CEGUI::WindowManager *win =
  • CEGUI::WindowManager::getSingletonPtr();
  • CEGUI::Window *sheet = win->createWindow(
  • "DefaultGUISheet", "CEGUIDemo/Sheet");
  • - Create a "DefaultGUISheet" called "CEGUIDemo/Sheet".
  • - Common (and encouraged) to name the widget in a hierarchical manner such as "SomeApp/MainMenu/Submenu3/CancelButton".
    • (3) Create the Quit button and set its size:
  • CEGUI::Window *quit = win->createWindow(
  • "TaharezLook/Button", "CEGUIDemo/QuitButton");
  • quit->setText("Quit");
  • quit->setSize(CEGUI::UVector2(
  • CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
slide64

Mannually Creating an Object

  • CEGUI uses a "unified dimension" system for its sizes and positions.
  • Create a UDim object to tell it what size it should be.
  • 1st parameter : the relative size of the object in relation to its parent.
  • 2nd parameter: the absolute size of the object (in pixels).
  • - only supposed to set one of the two parameters to UDim.
  • - The other parameter must be 0.
  • - Attach the Quit button to the sheet we have created
  • Set the current GUI sheet for the system to be that sheet:
  • sheet->addChildWindow(quit);
  • mSystem->setGUISheet(sheet);

15%

5%

slide65

Handling Events

  • - CEGUI uses a callback mechanism which binds any public function to be the event handler.
  • For example: register Quit button's click event to exit the program when it is pressed.
  • (1) need a pointer to the Quit button
  • (2) subscribe to the clicked event
  • CEGUI::WindowManager *wmgr = CEGUI::WindowManager::getSingletonPtr();
  • CEGUI::Window *quit = wmgr->getWindow(
  • (CEGUI::utf8*)"CEGUIDemo/QuitButton");
    • quit->subscribeEvent(
    • CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&DemoListener::quit, this));
slide66

Handling Events

  • - Every widget in CEGUI has a set of events that it supports, and they all begin with "Event".
  • To subscribe to the event:
    • quit->subscribeEvent(
    • CEGUI::PushButton::EventClicked, // (1) CEGUI::Event::Subscriber(&DemoListener::quit, this)); // (2)
  • 1st parameter: the event itself.
  • 2nd parameter: an Event::Subscriber object.
  • Remark: Which event and which handler to handle the event?
  • The subsriber answer these two questions.

66

slide67

Render to Texture

  • Purpose: Create a render to texture window.
  • Allow to create a second Viewport which can be rendered directly into a CEGUI widget.
  • Eight Steps:
  • (1) Setup a scene for us to look at.
  • (2) Create the RenderTexture. The RenderSystem object provides the functionality to render to a texture.
  • (3) Create a texture with the RenderSystem::createRenderTexture function.
  • (4) create camera
  • (5) create a viewport using RenderTexture::addViewport
  • (6) Use renderSystem::createTexture to render the scene onto a texture
  • (7) Setup CEGUI image set to store the texture in CEGUI system
  • (8) create StaticImage widget for rendering the texture stored in the image set
  • See http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_7 for more information.
slide68

References:

Terrain, Sky, Fog

http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_3

FrameListener and Unbuffered Input

http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_4

Buffered Input

http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_5

CEGUI

http://www.ogre3d.org/wiki/index.php/Basic_Tutorial_7