Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::Overlay Class Reference

Represents a layer which is rendered on top of the 'normal' scene contents. More...

#include <OgreOverlay.h>

Inheritance diagram for Ogre::Overlay:

Ogre::Resource List of all members.

Public Methods

 Overlay (const String &name)
 Constructor: do not call direct, use SceneManager::createOverlay. More...

virtual ~Overlay ()
virtual void load (void)
 Generic load - called by OverlayManager. More...

virtual void unload (void)
 Generic unload - called by OverlayManager. More...

GuiContainergetChild (const String &name)
const StringgetName (void) const
 Gets the name of this overlay. More...

void setZOrder (ushort zorder)
 Alters the ZOrder of this overlay. More...

ushort getZOrder (void) const
 Gets the ZOrder of this overlay. More...

bool isVisible (void)
 Gets whether the overlay is displayed or not. More...

void show (void)
 Shows the overlay if it was hidden. More...

void hide (void)
 Hides the overlay if it was visible. More...

void add2D (GuiContainer *cont)
 Adds a 2D 'container' to the overlay. More...

void remove2D (GuiContainer *cont)
 Removes a 2D container from the overlay. More...

void add3D (SceneNode *node)
 Adds a node capable of holding 3D objects to the overlay. More...

void remove3D (SceneNode *node)
 Removes a 3D element from the overlay. More...

void clear ()
 Clears the overlay of all attached items. More...

void setScroll (Real x, Real y)
 Sets the scrolling factor of this overlay. More...

Real getScrollX (void)
 Gets the current X scroll value. More...

Real getScrollY (void)
 Gets the current Y scroll value. More...

void scroll (Real xoff, Real yoff)
 Scrolls the overlay by the offsets provided. More...

void setRotate (Real degrees)
 Sets the rotation applied to this overlay, in degrees. More...

Real getRotate (void)
 Gets the rotation applied to this overlay, in degrees. More...

void rotate (Real degrees)
 Adds the passed in angle to the rotation applied to this overlay. More...

void setScale (Real x, Real y)
 Sets the scaling factor of this overlay. More...

Real getScaleX (void)
 Gets the current X scale value. More...

Real getScaleY (void)
 Gets the current Y scale value. More...

void _getWorldTransforms (Matrix4 *xform)
 Used to transform the overlay when scrolling, scaling etc. More...

void _findVisibleObjects (Camera *cam, RenderQueue *queue)
 Internal method to put the overlay contents onto the render queue. More...

virtual GuiElementfindElementAt (Real x, Real y)
 This returns a GuiElement at position x,y. More...

virtual size_t getSize (void)
 Retrieves info about the size of the resource. More...

void touch (void)
 'Touches' the resource to indicate it has been used. More...

time_t getLastAccess (void) const
 Gets the last time the resource was 'touched'. More...

bool isLoaded (void) const
 Returns true if the Resource has been loaded, false otherwise. More...

virtual void destroy ()
 A method to make the resource delete itself. More...


Protected Types

typedef std::list< GuiContainer * > GuiContainerList

Protected Methods

void updateTransform (void)
 Internal lazy update method. More...


Protected Attributes

ushort mZOrder
bool mVisible
SceneNodemRootNode
 Internal root node, used as parent for 3D objects. More...

GuiContainerList m2DElements
Real mRotate
Real mScrollX
Real mScrollY
Real mScaleX
Real mScaleY
Matrix4 mTransform
bool mTransformOutOfDate
String mName
bool mIsLoaded
time_t mLastAccess
size_t mSize

Detailed Description

Represents a layer which is rendered on top of the 'normal' scene contents.

Remarks:
An overlay is a container for visual components (2D and 3D) which will be rendered after the main scene in order to composite heads-up-displays, menus or other layers on top of the contents of the scene.

An overlay always takes up the entire size of the viewport, although the components attached to it do not have to. An overlay has no visual element in itself, it it merely a container for visual elements.

Overlays are created by calling SceneManager::createOverlay, or by defining them in special text scripts (.overlay files). As many overlays as you like can be defined; after creation an overlay is hidden i.e. not visible until you specifically enable it by calling 'show'. This allows you to have multiple overlays predefined (menus etc) which you make visible only when you want. It is possible to have multiple overlays enabled at once; in this case the relative 'zorder' parameter of the overlays determine which one is displayed on top.

By default overlays are rendered into all viewports. This is fine when you only have fullscreen viewports, but if you have picture-in-picture views, you probably don't want the overlay displayed in the smaller viewports. You turn this off for a specific viewport by calling the Viewport::setDisplayOverlays method.


Member Typedef Documentation

typedef std::list<GuiContainer*> Ogre::Overlay::GuiContainerList [protected]
 


Constructor & Destructor Documentation

Ogre::Overlay::Overlay const String   name
 

Constructor: do not call direct, use SceneManager::createOverlay.

Ogre::Overlay::~Overlay   [virtual]
 


Member Function Documentation

void Ogre::Overlay::_findVisibleObjects Camera   cam,
RenderQueue   queue
 

Internal method to put the overlay contents onto the render queue.

void Ogre::Overlay::_getWorldTransforms Matrix4   xform
 

Used to transform the overlay when scrolling, scaling etc.

void Ogre::Overlay::add2D GuiContainer   cont
 

Adds a 2D 'container' to the overlay.

Remarks:
Containers are created and managed using the GuiManager. A container could be as simple as a square panel, or something more complex like a grid or tree view. Containers group collections of other elements, giving them a relative coordinate space and a common z-order. If you want to attach a gui widget to an overlay, you have to do it via a container.
Parameters:
cont  Pointer to a container to add, created using GuiManager.

void Ogre::Overlay::add3D SceneNode   node
 

Adds a node capable of holding 3D objects to the overlay.

Remarks:
Although overlays are traditionally associated with 2D elements, there are reasons why you might want to attach 3D elements to the overlay too. For example, if you wanted to have a 3D cockpit, which was overlaid with a HUD, then you would create 2 overlays, one with a 3D object attached for the cockpit, and one with the HUD elements attached (the zorder of the HUD overlay would be higher than the cockpit to ensure it was always on top).

A SceneNode can have nay number of 3D objects attached to it. SceneNodes are created using SceneManager::createSceneNode, and are normally attached (directly or indirectly) to the root node of the scene. By attaching them to an overlay, you indicate that:

  1. You want the contents of this node to only appear when the overlay is active
  2. You want the node to inherit a coordinate space relative to the camera, rather than relative to the root scene node
  3. You want these objects to be rendered after the contents of the main scene to ensure they are rendered on top
One major consideration when using 3D objects in overlays is the behaviour of the depth buffer. Overlays are rendered with depth checking off, to ensure that their contents are always displayed on top of the main scene (to do otherwise would result in objects 'poking through' the overlay). The problem with using 3D objects is that if they are concave, or self-overlap, then you can get artefacts because of the lack of depth buffer checking. So you should ensure that any 3D objects you us in the overlay are convex, and don't overlap each other. If they must overlap, split them up and put them in 2 overlays.

void Ogre::Overlay::clear  
 

Clears the overlay of all attached items.

virtual void Ogre::Resource::destroy void    [inline, virtual, inherited]
 

A method to make the resource delete itself.

Note:
This exists because Resource objects could be created in other processes, and they need to be destroyed in the process that created them.

GuiElement * Ogre::Overlay::findElementAt Real    x,
Real    y
[virtual]
 

This returns a GuiElement at position x,y.

GuiContainer * Ogre::Overlay::getChild const String   name
 

time_t Ogre::Resource::getLastAccess void    const [inline, inherited]
 

Gets the last time the resource was 'touched'.

const String & Ogre::Overlay::getName void    const
 

Gets the name of this overlay.

Reimplemented from Ogre::Resource.

Real Ogre::Overlay::getRotate void   
 

Gets the rotation applied to this overlay, in degrees.

Real Ogre::Overlay::getScaleX void   
 

Gets the current X scale value.

Real Ogre::Overlay::getScaleY void   
 

Gets the current Y scale value.

Real Ogre::Overlay::getScrollX void   
 

Gets the current X scroll value.

Real Ogre::Overlay::getScrollY void   
 

Gets the current Y scroll value.

virtual size_t Ogre::Resource::getSize void    [inline, virtual, inherited]
 

Retrieves info about the size of the resource.

ushort Ogre::Overlay::getZOrder void    const
 

Gets the ZOrder of this overlay.

void Ogre::Overlay::hide void   
 

Hides the overlay if it was visible.

bool Ogre::Resource::isLoaded void    const [inline, inherited]
 

Returns true if the Resource has been loaded, false otherwise.

bool Ogre::Overlay::isVisible void   
 

Gets whether the overlay is displayed or not.

void Ogre::Overlay::load void    [virtual]
 

Generic load - called by OverlayManager.

Implements Ogre::Resource.

void Ogre::Overlay::remove2D GuiContainer   cont
 

Removes a 2D container from the overlay.

Remarks:
NOT FAST. Consider GuiElement::hide.

void Ogre::Overlay::remove3D SceneNode   node
 

Removes a 3D element from the overlay.

void Ogre::Overlay::rotate Real    degrees
 

Adds the passed in angle to the rotation applied to this overlay.

void Ogre::Overlay::scroll Real    xoff,
Real    yoff
 

Scrolls the overlay by the offsets provided.

Remarks:
This method moves the overlay by the amounts provided. As with other methods on this object, a full screen width / height is represented by the value 1.0.

void Ogre::Overlay::setRotate Real    degrees
 

Sets the rotation applied to this overlay, in degrees.

void Ogre::Overlay::setScale Real    x,
Real    y
 

Sets the scaling factor of this overlay.

Remarks:
You can use this to set an scale factor to be used to zoom an overlay.
Parameters:
x  Horizontal scale value, where 1.0 = normal, 0.5 = half size etc
y  Vertical scale value, where 1.0 = normal, 0.5 = half size etc

void Ogre::Overlay::setScroll Real    x,
Real    y
 

Sets the scrolling factor of this overlay.

Remarks:
You can use this to set an offset to be used to scroll an overlay around the screen.
Parameters:
x  Horizontal scroll value, where 0 = normal, -0.5 = scroll so that only the right half the screen is visible etc
y  Vertical scroll value, where 0 = normal, 0.5 = scroll down by half a screen etc.

void Ogre::Overlay::setZOrder ushort    zorder
 

Alters the ZOrder of this overlay.

Remarks:
Values between 0 and 600 are valid here.

void Ogre::Overlay::show void   
 

Shows the overlay if it was hidden.

void Ogre::Resource::touch void    [inline, inherited]
 

'Touches' the resource to indicate it has been used.

void Ogre::Overlay::unload void    [virtual]
 

Generic unload - called by OverlayManager.

Reimplemented from Ogre::Resource.

void Ogre::Overlay::updateTransform void    [protected]
 

Internal lazy update method.


Member Data Documentation

GuiContainerList Ogre::Overlay::m2DElements [protected]
 

bool Ogre::Resource::mIsLoaded [protected, inherited]
 

time_t Ogre::Resource::mLastAccess [protected, inherited]
 

String Ogre::Resource::mName [protected, inherited]
 

SceneNode* Ogre::Overlay::mRootNode [protected]
 

Internal root node, used as parent for 3D objects.

Real Ogre::Overlay::mRotate [protected]
 

Real Ogre::Overlay::mScaleX [protected]
 

Real Ogre::Overlay::mScaleY [protected]
 

Real Ogre::Overlay::mScrollX [protected]
 

Real Ogre::Overlay::mScrollY [protected]
 

size_t Ogre::Resource::mSize [protected, inherited]
 

Matrix4 Ogre::Overlay::mTransform [protected]
 

bool Ogre::Overlay::mTransformOutOfDate [protected]
 

bool Ogre::Overlay::mVisible [protected]
 

ushort Ogre::Overlay::mZOrder [protected]
 

Copyright © 2002 by The OGRE Team