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:

Inheritance graph
[legend]
Collaboration diagram for Ogre::Overlay:

Collaboration graph
[legend]
List of all members.

Public Methods

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

const QuaterniongetWorldOrientation (void) const
 @copydoc Renderable::getWorldOrientation

const Vector3getWorldPosition (void) const
 @copydoc Renderable::getWorldPosition

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

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

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

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

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

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

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


Protected Types

typedef std::list< GuiContainer * > GuiContainerList

Protected Methods

void updateTransform (void) const
 Internal lazy update method.


Protected Attributes

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

GuiContainerList m2DElements
Real mRotate
Real mScrollX
Real mScrollY
Real mScaleX
Real mScaleY
Matrix4 mTransform
bool mTransformOutOfDate
String mName
ResourceHandle mHandle
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.

Definition at line 62 of file OgreOverlay.h.


Member Typedef Documentation

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

Definition at line 73 of file OgreOverlay.h.


Constructor & Destructor Documentation

Ogre::Overlay::Overlay const String   name
 

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

Definition at line 39 of file OgreOverlay.cpp.

References Ogre::Resource::mName, mRootNode, mRotate, mScaleX, mScaleY, mScrollX, mScrollY, mTransformOutOfDate, mVisible, mZOrder, and Ogre::ST_GENERIC.

Ogre::Overlay::~Overlay   [virtual]
 

Definition at line 54 of file OgreOverlay.cpp.


Member Function Documentation

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

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

Definition at line 225 of file OgreOverlay.cpp.

References Ogre::SceneNode::_findVisibleObjects(), Ogre::SceneNode::_update(), Ogre::RenderQueue::getDefaultQueueGroup(), Ogre::Camera::getDerivedOrientation(), Ogre::Camera::getDerivedPosition(), m2DElements, mRootNode, mVisible, Ogre::RENDER_QUEUE_OVERLAY, Ogre::RenderQueueGroupID, Ogre::RenderQueue::setDefaultQueueGroup(), Ogre::Node::setOrientation(), and Ogre::Node::setPosition().

Referenced by Ogre::OverlayManager::_queueOverlaysForRendering().

void Ogre::Overlay::_getWorldTransforms Matrix4   xform const
 

Used to transform the overlay when scrolling, scaling etc.

Definition at line 203 of file OgreOverlay.cpp.

References mTransform, and updateTransform().

Referenced by Ogre::GuiElement::getWorldTransforms().

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.

Definition at line 98 of file OgreOverlay.cpp.

References Ogre::GuiContainer::_notifyParent(), Ogre::GuiContainer::_notifyZOrder(), m2DElements, and mZOrder.

Referenced by Ogre::OverlayManager::createCursorOverlay(), Ogre::Profiler::initialize(), and Ogre::OverlayManager::parseNewElement().

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.

Definition at line 113 of file OgreOverlay.cpp.

References Ogre::Node::addChild(), and mRootNode.

Referenced by Ogre::OverlayManager::parseNewMesh().

void Ogre::Overlay::clear  
 

Clears the overlay of all attached items.

Definition at line 123 of file OgreOverlay.cpp.

References m2DElements, mRootNode, and Ogre::Node::removeAllChildren().

virtual void Ogre::Resource::destroy void    [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.

Definition at line 137 of file OgreResource.h.

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

This returns a GuiElement at position x,y.

Definition at line 286 of file OgreOverlay.cpp.

References Ogre::GuiElement::getZOrder(), m2DElements, and Ogre::Real.

Referenced by Ogre::OverlayManager::getPositionTargetAt().

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

Definition at line 147 of file OgreOverlay.cpp.

References m2DElements.

ResourceHandle Ogre::Resource::getHandle void    const [inherited]
 

Definition at line 120 of file OgreResource.h.

References Ogre::ResourceHandle.

Referenced by Ogre::Material::clone(), Ogre::BspLevel::loadQuake3Level(), and Ogre::ResourceManager::unload().

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

Gets the last time the resource was 'touched'.

Definition at line 108 of file OgreResource.h.

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

Gets the name of this overlay.

Reimplemented from Ogre::Resource.

Definition at line 59 of file OgreOverlay.cpp.

References Ogre::Resource::mName.

Referenced by Ogre::OverlayManager::parseAttrib(), Ogre::OverlayManager::parseElementAttrib(), Ogre::OverlayManager::parseNewMesh(), and Ogre::OverlayManager::parseOverlayFile().

Real Ogre::Overlay::getRotate void    const
 

Gets the rotation applied to this overlay, in degrees.

Definition at line 176 of file OgreOverlay.cpp.

References mRotate, and Ogre::Real.

Real Ogre::Overlay::getScaleX void    const
 

Gets the current X scale value.

Definition at line 193 of file OgreOverlay.cpp.

References mScaleX, and Ogre::Real.

Real Ogre::Overlay::getScaleY void    const
 

Gets the current Y scale value.

Definition at line 198 of file OgreOverlay.cpp.

References mScaleY, and Ogre::Real.

Real Ogre::Overlay::getScrollX void    const
 

Gets the current X scroll value.

Definition at line 137 of file OgreOverlay.cpp.

References mScrollX, and Ogre::Real.

Real Ogre::Overlay::getScrollY void    const
 

Gets the current Y scroll value.

Definition at line 142 of file OgreOverlay.cpp.

References mScrollY, and Ogre::Real.

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

Retrieves info about the size of the resource.

Definition at line 93 of file OgreResource.h.

Referenced by Ogre::ResourceManager::unload().

const Quaternion & Ogre::Overlay::getWorldOrientation void    const
 

@copydoc Renderable::getWorldOrientation

Definition at line 213 of file OgreOverlay.cpp.

Referenced by Ogre::GuiElement::getWorldOrientation().

const Vector3 & Ogre::Overlay::getWorldPosition void    const
 

@copydoc Renderable::getWorldPosition

Definition at line 219 of file OgreOverlay.cpp.

Referenced by Ogre::GuiElement::getWorldPosition().

ushort Ogre::Overlay::getZOrder void    const
 

Gets the ZOrder of this overlay.

Definition at line 78 of file OgreOverlay.cpp.

References mZOrder, and Ogre::ushort.

Referenced by Ogre::OverlayManager::getPositionTargetAt().

void Ogre::Overlay::hide void   
 

Hides the overlay if it was visible.

Definition at line 93 of file OgreOverlay.cpp.

References mVisible.

Referenced by Ogre::Profiler::changeEnableState().

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

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

Definition at line 127 of file OgreResource.h.

Referenced by Ogre::GpuProgramUsage::_load(), Ogre::Technique::isLoaded(), Ogre::D3D9Texture::load(), Ogre::D3D9Texture::unload(), and Ogre::D3D9Texture::~D3D9Texture().

bool Ogre::Overlay::isVisible void    const
 

Gets whether the overlay is displayed or not.

Definition at line 83 of file OgreOverlay.cpp.

References mVisible.

Referenced by Ogre::OverlayManager::getPositionTargetAt().

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

Generic load - called by OverlayManager.

Implements Ogre::Resource.

Definition at line 276 of file OgreOverlay.cpp.

void Ogre::Overlay::remove2D GuiContainer   cont
 

Removes a 2D container from the overlay.

Remarks:
NOT FAST. Consider GuiElement::hide.

Definition at line 108 of file OgreOverlay.cpp.

References m2DElements.

void Ogre::Overlay::remove3D SceneNode   node
 

Removes a 3D element from the overlay.

Definition at line 118 of file OgreOverlay.cpp.

References Ogre::Node::getName(), mRootNode, and Ogre::Node::removeChild().

void Ogre::Overlay::rotate Real    degrees
 

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

Definition at line 181 of file OgreOverlay.cpp.

References mRotate, Ogre::Real, and setRotate().

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.

Definition at line 163 of file OgreOverlay.cpp.

References mScrollX, mScrollY, mTransformOutOfDate, and Ogre::Real.

void Ogre::Overlay::setRotate Real    degrees
 

Sets the rotation applied to this overlay, in degrees.

Definition at line 170 of file OgreOverlay.cpp.

References mRotate, mTransformOutOfDate, and Ogre::Real.

Referenced by rotate().

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

Definition at line 186 of file OgreOverlay.cpp.

References mScaleX, mScaleY, mTransformOutOfDate, and Ogre::Real.

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.

Definition at line 130 of file OgreOverlay.cpp.

References mScrollX, mScrollY, mTransformOutOfDate, and Ogre::Real.

void Ogre::Overlay::setZOrder ushort    zorder
 

Alters the ZOrder of this overlay.

Remarks:
Values between 0 and 600 are valid here.

Definition at line 64 of file OgreOverlay.cpp.

References m2DElements, mZOrder, and Ogre::ushort.

Referenced by Ogre::OverlayManager::createCursorOverlay(), Ogre::SceneManager::createOverlay(), Ogre::Profiler::initialize(), and Ogre::OverlayManager::parseAttrib().

void Ogre::Overlay::show void   
 

Shows the overlay if it was hidden.

Definition at line 88 of file OgreOverlay.cpp.

References mVisible.

Referenced by Ogre::Profiler::changeEnableState(), Ogre::OverlayManager::createCursorOverlay(), and Ogre::Profiler::initialize().

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

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

Reimplemented in Ogre::Material.

Definition at line 100 of file OgreResource.h.

Referenced by Ogre::ResourceManager::load().

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

Generic unload - called by OverlayManager.

Reimplemented from Ogre::Resource.

Definition at line 281 of file OgreOverlay.cpp.

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

Internal lazy update method.

Definition at line 254 of file OgreOverlay.cpp.

References Ogre::Matrix3::FromEulerAnglesXYZ(), mRotate, mScaleX, mScaleY, mScrollX, mScrollY, mTransform, mTransformOutOfDate, and Ogre::Matrix4::setTrans().

Referenced by _getWorldTransforms().


Member Data Documentation

GuiContainerList Ogre::Overlay::m2DElements [protected]
 

Definition at line 74 of file OgreOverlay.h.

Referenced by _findVisibleObjects(), add2D(), clear(), findElementAt(), getChild(), remove2D(), and setZOrder().

ResourceHandle Ogre::Resource::mHandle [protected, inherited]
 

Definition at line 57 of file OgreResource.h.

Referenced by Ogre::ResourceManager::add(), Ogre::Material::clone(), Ogre::Material::copyDetailsTo(), and Ogre::Material::operator=().

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

Definition at line 58 of file OgreResource.h.

Referenced by Ogre::D3D9Texture::_initMembers(), Ogre::D3D9Texture::_loadCubeTex(), Ogre::D3D9Texture::_loadNormTex(), Ogre::D3D9Texture::_loadVolumeTex(), Ogre::Material::_notifyNeedsRecompile(), Ogre::Material::clone(), Ogre::D3DTexture::createSurface2D(), Ogre::D3DTexture::createSurface3D(), Ogre::D3D9Texture::D3D9Texture(), Ogre::D3DTexture::D3DTexture(), Ogre::DynLib::DynLib(), Ogre::Zip::load(), Ogre::Skeleton::load(), Ogre::PatchMesh::load(), Ogre::Mesh::load(), Ogre::Material::load(), Ogre::HighLevelGpuProgram::load(), Ogre::GpuProgram::load(), Ogre::GLTexture::load(), Ogre::Font::load(), Ogre::DynLib::load(), Ogre::D3D9Texture::load(), Ogre::D3D9GpuProgram::load(), Ogre::D3DTexture::load(), Ogre::BspLevel::load(), Ogre::D3D9Texture::loadImage(), Ogre::D3DTexture::loadImage(), Ogre::D3DTexture::loadImage3D(), Ogre::GLTexture::loadImages(), Ogre::Material::Material(), Ogre::Material::operator=(), Ogre::Skeleton::unload(), Ogre::Mesh::unload(), Ogre::Material::unload(), Ogre::HighLevelGpuProgram::unload(), Ogre::GLTexture::unload(), Ogre::Font::unload(), Ogre::DynLib::unload(), Ogre::D3D9Texture::unload(), Ogre::D3DTexture::unload(), and Ogre::BspLevel::~BspLevel().

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

Definition at line 59 of file OgreResource.h.

Referenced by Ogre::Material::operator=().

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

Definition at line 56 of file OgreResource.h.

Referenced by Ogre::Skeleton::_dumpContents(), Ogre::Mesh::_rationaliseBoneAssignments(), Ogre::BspLevel::BspLevel(), Ogre::Mesh::buildTangentVectors(), Ogre::Material::clone(), Ogre::Material::compile(), Ogre::Material::copyDetailsTo(), Ogre::Quake3Shader::createAsMaterial(), Ogre::D3D9HLSLProgram::createLowLevelImpl(), Ogre::CgProgram::createLowLevelImpl(), Ogre::Font::createTextureFromFont(), Ogre::D3D9Texture::D3D9Texture(), Ogre::D3DTexture::D3DTexture(), Ogre::DynLib::DynLib(), Ogre::Font::Font(), Ogre::Mesh::generateLodLevels(), Ogre::Material::getBestTechnique(), getName(), Ogre::Material::getName(), Ogre::GLTexture::GLTexture(), Ogre::GpuProgram::GpuProgram(), Ogre::Zip::load(), Ogre::Skeleton::load(), Ogre::Mesh::load(), Ogre::GLTexture::load(), Ogre::Font::load(), Ogre::DynLib::load(), Ogre::D3DTexture::load(), Ogre::BspLevel::load(), Ogre::D3D9GpuFragmentProgram::loadFromMicrocode(), Ogre::D3D9GpuVertexProgram::loadFromMicrocode(), Ogre::GLArbGpuProgram::loadFromSource(), Ogre::D3D9HLSLProgram::loadFromSource(), Ogre::D3D9GpuProgram::loadFromSource(), Ogre::CgProgram::loadFromSource(), Ogre::GLTexture::loadImages(), Ogre::Material::Material(), Ogre::Mesh::Mesh(), Ogre::Material::operator=(), Overlay(), Ogre::Quake3Shader::Quake3Shader(), Ogre::CgProgram::selectProfile(), Ogre::Mesh::setSkeletonName(), Ogre::Skeleton::Skeleton(), Ogre::StringResource::StringResource(), Ogre::Zip::unload(), Ogre::DynLib::unload(), Ogre::CgProgram::unloadImpl(), and Ogre::Zip::Zip().

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

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

Definition at line 69 of file OgreOverlay.h.

Referenced by _findVisibleObjects(), add3D(), clear(), Overlay(), and remove3D().

Real Ogre::Overlay::mRotate [protected]
 

Definition at line 77 of file OgreOverlay.h.

Referenced by getRotate(), Overlay(), rotate(), setRotate(), and updateTransform().

Real Ogre::Overlay::mScaleX [protected]
 

Definition at line 81 of file OgreOverlay.h.

Referenced by getScaleX(), Overlay(), setScale(), and updateTransform().

Real Ogre::Overlay::mScaleY [protected]
 

Definition at line 81 of file OgreOverlay.h.

Referenced by getScaleY(), Overlay(), setScale(), and updateTransform().

Real Ogre::Overlay::mScrollX [protected]
 

Definition at line 79 of file OgreOverlay.h.

Referenced by getScrollX(), Overlay(), scroll(), setScroll(), and updateTransform().

Real Ogre::Overlay::mScrollY [protected]
 

Definition at line 79 of file OgreOverlay.h.

Referenced by getScrollY(), Overlay(), scroll(), setScroll(), and updateTransform().

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

Definition at line 60 of file OgreResource.h.

Referenced by Ogre::D3D9Texture::_setFinalAttributes(), Ogre::D3DTexture::loadImage(), Ogre::D3DTexture::loadImage3D(), Ogre::GLTexture::loadImages(), and Ogre::Material::operator=().

Matrix4 Ogre::Overlay::mTransform [protected]
 

Definition at line 83 of file OgreOverlay.h.

Referenced by _getWorldTransforms(), and updateTransform().

bool Ogre::Overlay::mTransformOutOfDate [protected]
 

Definition at line 84 of file OgreOverlay.h.

Referenced by Overlay(), scroll(), setRotate(), setScale(), setScroll(), and updateTransform().

bool Ogre::Overlay::mVisible [protected]
 

Definition at line 67 of file OgreOverlay.h.

Referenced by _findVisibleObjects(), hide(), isVisible(), Overlay(), and show().

ushort Ogre::Overlay::mZOrder [protected]
 

Definition at line 66 of file OgreOverlay.h.

Referenced by add2D(), getZOrder(), Overlay(), and setZOrder().


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

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:18:45 2004