Ogre::Overlay Class Reference
Core » Overlays

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

`#include <OgreOverlay.h>`

Inheritance diagram for Ogre::Overlay:
[legend]

## Public Types

typedef VectorIterator< OverlayContainerList > | Overlay2DElementsIterator
| Returns an iterator over all 2D elements in this manager. More...
typedef list< OverlayContainer * >::type | OverlayContainerList

## Public Member Functions

| Overlay (const String &name)
| Constructor: do not call direct, use OverlayManager::create. More...
virtual | ~Overlay ()
void | _findVisibleObjects (Camera *cam, RenderQueue *queue)
| Internal method to put the overlay contents onto the render queue. More...
void | _getWorldTransforms (Matrix4 *xform) const
| Used to transform the overlay when scrolling, scaling etc. More...
void | _notifyOrigin (const String &origin)
| Notify this overlay of it's origin. More...
void | add2D (OverlayContainer *cont)
| Adds a 2D 'container' to the overlay. More...
void | add3D (SceneNode *node)
| Adds a node capable of holding 3D objects to the overlay. More...
void | clear ()
| Clears the overlay of all attached items. More...
virtual OverlayElement * | findElementAt (Real x, Real y)
| This returns a OverlayElement at position x,y. More...
Overlay2DElementsIterator | get2DElementsIterator ()
OverlayContainer * | getChild (const String &name)
const String & | getName (void) const
| Gets the name of this overlay. More...
const String & | getOrigin (void) const
| Get the origin of this overlay, e.g. More...
const Radian & | getRotate (void) const
| Gets the rotation applied to this overlay, in degrees. More...
Real | getScaleX (void) const
| Gets the current X scale value. More...
Real | getScaleY (void) const
| Gets the current Y scale value. More...
Real | getScrollX (void) const
| Gets the current X scroll value. More...
Real | getScrollY (void) const
| Gets the current Y scroll value. More...
ushort | getZOrder (void) const
| Gets the Z-order of this overlay. More...
void | hide (void)
| Hides the overlay if it was visible. More...
bool | isInitialised (void) const
| Gets whether the overlay is initialised or not. More...
bool | isVisible (void) const
| Gets whether the overlay is displayed or not. More...
void | operator delete (void *ptr)
void | operator delete (void *ptr, void *)
void | operator delete (void *ptr, const char *, int, const char *)
void | operator delete[] (void *ptr)
void | operator delete[] (void *ptr, const char *, int, const char *)
void * | operator new (size_t sz, const char *file, int line, const char *func)
| operator new, with debug line info More...
void * | operator new (size_t sz)
void * | operator new (size_t sz, void *ptr)
| placement operator new More...
void * | operator new[] (size_t sz, const char *file, int line, const char *func)
| array operator new, with debug line info More...
void * | operator new[] (size_t sz)
void | remove2D (OverlayContainer *cont)
| Removes a 2D container from the overlay. More...
void | remove3D (SceneNode *node)
| Removes a 3D element from the overlay. More...
void | rotate (const Radian &angle)
| Adds the passed in angle to the rotation applied to this overlay. More...
void | scroll (Real xoff, Real yoff)
| Scrolls the overlay by the offsets provided. More...
void | setRotate (const Radian &angle)
| Sets the rotation applied to this overlay. More...
void | setScale (Real x, Real y)
| Sets the scaling factor of this overlay. More...
void | setScroll (Real x, Real y)
| Sets the scrolling factor of this overlay. More...
void | setZOrder (ushort zorder)
| Alters the Z-order of this overlay. More...
void | show (void)
| Shows the overlay if it was hidden. More...

## Protected Member Functions

void | assignZOrders (void)
| Internal method for updating container elements' Z-ordering. More...
void | initialise (void)
| Internal method for initialising an overlay. More...
void | updateTransform (void) const
| Internal lazy update method. More...

## Protected Attributes

OverlayContainerList | m2DElements
| 2D elements OverlayContainers, linked list for easy sorting by zorder later Not a map because sort can be saved since changes infrequent (unlike render queue) More...
bool | mInitialised
String | mName
String | mOrigin
SceneNode * | mRootNode
| Internal root node, used as parent for 3D objects. More...
Radian | mRotate
| Degrees of rotation around center. More...
Real | mScaleX
| Scale values. More...
Real | mScaleY
Real | mScrollX
| Scroll values, offsets. More...
Real | mScrollY
Matrix4 | mTransform
bool | mTransformOutOfDate
bool | mTransformUpdated
bool | mVisible
ulong | mZOrder

## 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 OverlayManager::create, 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.

Definition at line 70 of file OgreOverlay.h.

## Member Typedef Documentation

## Overlay2DElementsIterator

typedef VectorIterator<OverlayContainerList> Ogre::Overlay::Overlay2DElementsIterator

Returns an iterator over all 2D elements in this manager.

Remarks
  VectorIterator is actually a too generic name, since it also works for lists.

Definition at line 257 of file OgreOverlay.h.

## OverlayContainerList

typedef list<OverlayContainer*>::type Ogre::Overlay::OverlayContainerList

Definition at line 74 of file OgreOverlay.h.

## Constructor & Destructor Documentation

## Overlay()

Ogre::Overlay::Overlay | ( | const String & | name | ) |

Constructor: do not call direct, use OverlayManager::create.

## ~Overlay()

virtual Ogre::Overlay::~Overlay | ( |  | ) |

virtual

## Member Function Documentation

## _findVisibleObjects()

void Ogre::Overlay::_findVisibleObjects | ( | Camera * | cam,
|  | RenderQueue * | queue
| ) |  |

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

## _getWorldTransforms()

void Ogre::Overlay::_getWorldTransforms | ( | Matrix4 * | xform | ) | const

Used to transform the overlay when scrolling, scaling etc.

## _notifyOrigin()

void Ogre::Overlay::_notifyOrigin | ( | const String & | origin | ) |

Notify this overlay of it's origin.

Definition at line 270 of file OgreOverlay.h.

## add2D()

void Ogre::Overlay::add2D | ( | OverlayContainer * | cont | ) |

Adds a 2D 'container' to the overlay.

Remarks
  Containers are created and managed using the OverlayManager. 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 OverlayManager.

## add3D()

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 any number of 3D objects attached to it. SceneNodes are usually created using SceneManager::createSceneNode, but in this case you should create a standard SceneNode instance manually; this is because these scene nodes are not managed by the SceneManager and some custom SceneManager plugins will rely on specialist behaviour the overlay does not support. By attaching a SceneNode 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 should use materials 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. Alternatively, use a 2D element underneath them which will clear the depth buffer values underneath ready for the 3D element to be rendered correctly.

## assignZOrders()

void Ogre::Overlay::assignZOrders | ( | void |  | ) |

protected

Internal method for updating container elements' Z-ordering.

## clear()

void Ogre::Overlay::clear | ( |  | ) |

Clears the overlay of all attached items.

## findElementAt()

virtual OverlayElement* Ogre::Overlay::findElementAt | ( | Real | x,
|  | Real | y
| ) |  |

virtual

This returns a OverlayElement at position x,y.

## get2DElementsIterator()

Overlay2DElementsIterator Ogre::Overlay::get2DElementsIterator | ( |  | ) |

Definition at line 258 of file OgreOverlay.h.

## getChild()

OverlayContainer* Ogre::Overlay::getChild | ( | const String & | name | ) |

## getName()

const String& Ogre::Overlay::getName | ( | void |  | ) | const

Gets the name of this overlay.

## getOrigin()

const String& Ogre::Overlay::getOrigin | ( | void |  | ) | const

Get the origin of this overlay, e.g.

a script file name.

Remarks
  This property will only contain something if the creator of this overlay chose to populate it. Script loaders are advised to populate it.

Definition at line 268 of file OgreOverlay.h.

## getRotate()

const Radian& Ogre::Overlay::getRotate | ( | void |  | ) | const

Gets the rotation applied to this overlay, in degrees.

Definition at line 224 of file OgreOverlay.h.

## getScaleX()

Real Ogre::Overlay::getScaleX | ( | void |  | ) | const

Gets the current X scale value.

## getScaleY()

Real Ogre::Overlay::getScaleY | ( | void |  | ) | const

Gets the current Y scale value.

## getScrollX()

Real Ogre::Overlay::getScrollX | ( | void |  | ) | const

Gets the current X scroll value.

## getScrollY()

Real Ogre::Overlay::getScrollY | ( | void |  | ) | const

Gets the current Y scroll value.

## getZOrder()

ushort Ogre::Overlay::getZOrder | ( | void |  | ) | const

Gets the Z-order of this overlay.

## hide()

void Ogre::Overlay::hide | ( | void |  | ) |

Hides the overlay if it was visible.

## initialise()

void Ogre::Overlay::initialise | ( | void |  | ) |

protected

Internal method for initialising an overlay.

## isInitialised()

bool Ogre::Overlay::isInitialised | ( | void |  | ) | const

Gets whether the overlay is initialised or not.

Definition at line 128 of file OgreOverlay.h.

## isVisible()

bool Ogre::Overlay::isVisible | ( | void |  | ) | const

Gets whether the overlay is displayed or not.

## operator delete() [1/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) |

inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

## operator delete() [2/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  |

inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

## operator delete() [3/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [1/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) |

inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [2/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

## operator new() [1/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

## operator new() [2/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) |

inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

## operator new() [3/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | void * | ptr
| ) |  |

inherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

## operator new[]() [1/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

## operator new[]() [2/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) |

inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

## remove2D()

void Ogre::Overlay::remove2D | ( | OverlayContainer * | cont | ) |

Removes a 2D container from the overlay.

Remarks
  NOT FAST. Consider OverlayElement::hide.

## remove3D()

void Ogre::Overlay::remove3D | ( | SceneNode * | node | ) |

Removes a 3D element from the overlay.

## rotate()

void Ogre::Overlay::rotate | ( | const Radian & | angle | ) |

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

## scroll()

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.

## setRotate()

void Ogre::Overlay::setRotate | ( | const Radian & | angle | ) |

Sets the rotation applied to this overlay.

## setScale()

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

## setScroll()

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.

## setZOrder()

void Ogre::Overlay::setZOrder | ( | ushort | zorder | ) |

Alters the Z-order of this overlay.

Remarks
  Values between 0 and 650 are valid here.

## show()

void Ogre::Overlay::show | ( | void |  | ) |

Shows the overlay if it was hidden.

## updateTransform()

void Ogre::Overlay::updateTransform | ( | void |  | ) | const

protected

Internal lazy update method.

## Member Data Documentation

## m2DElements

OverlayContainerList Ogre::Overlay::m2DElements

protected

2D elements OverlayContainers, linked list for easy sorting by zorder later Not a map because sort can be saved since changes infrequent (unlike render queue)

Definition at line 82 of file OgreOverlay.h.

## mInitialised

bool Ogre::Overlay::mInitialised

protected

Definition at line 96 of file OgreOverlay.h.

## mName

String Ogre::Overlay::mName

protected

Definition at line 76 of file OgreOverlay.h.

## mOrigin

String Ogre::Overlay::mOrigin

protected

Definition at line 97 of file OgreOverlay.h.

## mRootNode

SceneNode* Ogre::Overlay::mRootNode

protected

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

Definition at line 78 of file OgreOverlay.h.

## mRotate

Radian Ogre::Overlay::mRotate

protected

Degrees of rotation around center.

Definition at line 85 of file OgreOverlay.h.

## mScaleX

Real Ogre::Overlay::mScaleX

protected

Scale values.

Definition at line 89 of file OgreOverlay.h.

## mScaleY

Real Ogre::Overlay::mScaleY

protected

Definition at line 89 of file OgreOverlay.h.

## mScrollX

Real Ogre::Overlay::mScrollX

protected

Scroll values, offsets.

Definition at line 87 of file OgreOverlay.h.

## mScrollY

Real Ogre::Overlay::mScrollY

protected

Definition at line 87 of file OgreOverlay.h.

## mTransform

Matrix4 Ogre::Overlay::mTransform

mutable protected

Definition at line 91 of file OgreOverlay.h.

## mTransformOutOfDate

bool Ogre::Overlay::mTransformOutOfDate

mutable protected

Definition at line 92 of file OgreOverlay.h.

## mTransformUpdated

bool Ogre::Overlay::mTransformUpdated

protected

Definition at line 93 of file OgreOverlay.h.

## mVisible

bool Ogre::Overlay::mVisible

protected

Definition at line 95 of file OgreOverlay.h.

## mZOrder

ulong Ogre::Overlay::mZOrder

protected

Definition at line 94 of file OgreOverlay.h.

The documentation for this class was generated from the following file:

- OgreOverlay.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.