# Ogre::Renderable Class Reference

Abstract class defining the interface all renderable objects must implement. More...

`#include <OgreRenderable.h>`

Inheritance diagram for Ogre::Renderable:

[legend]

List of all members.

## Public Member Functions

| Renderable ()
virtual | ~Renderable ()
| Virtual destructor needed as class has virtual methods.
virtual const MaterialPtr & | getMaterial (void) const =0
| Retrieves a weak reference to the material this renderable object uses.
virtual Technique * | getTechnique (void) const
| Retrieves a pointer to the Material Technique this renderable object uses.
virtual void | getRenderOperation (RenderOperation &op)=0
| Gets the render operation required to send this object to the frame buffer.
virtual bool | preRender (SceneManager *sm, RenderSystem *rsys)
| Called just prior to the Renderable being rendered.
virtual void | postRender (SceneManager *sm, RenderSystem *rsys)
| Called immediately after the Renderable has been rendered.
virtual void | getWorldTransforms (Matrix4 *xform) const =0
| Gets the world transform matrix / matrices for this renderable object.
virtual unsigned short | getNumWorldTransforms (void) const
| Returns the number of world transform matrices this renderable requires.
void | setUseIdentityProjection (bool useIdentityProjection)
| Sets whether or not to use an 'identity' projection.
bool | getUseIdentityProjection (void) const
| Returns whether or not to use an 'identity' projection.
void | setUseIdentityView (bool useIdentityView)
| Sets whether or not to use an 'identity' view.
bool | getUseIdentityView (void) const
| Returns whether or not to use an 'identity' view.
virtual Real | getSquaredViewDepth (const Camera *cam) const =0
| Returns the camera-relative squared depth of this renderable.
virtual const LightList & | getLights (void) const =0
| Gets a list of lights, ordered relative to how close they are to this renderable.
virtual bool | getCastsShadows (void) const
| Method which reports whether this renderable would normally cast a shadow.
void | setCustomParameter (size_t index, const Vector4 &value)
| Sets a custom parameter for this Renderable, which may be used to drive calculations for this specific Renderable, like GPU program parameters.
const Vector4 & | getCustomParameter (size_t index) const
| Gets the custom value associated with this Renderable at the given index.
virtual void | _updateCustomGpuParameter (const GpuProgramParameters::AutoConstantEntry &constantEntry, GpuProgramParameters *params) const
| Update a custom GpuProgramParameters constant which is derived from information only this Renderable knows.
virtual void | setPolygonModeOverrideable (bool override)
| Sets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.
virtual bool | getPolygonModeOverrideable (void) const
| Gets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.
virtual void | setUserAny (const Any &anything)
| Sets any kind of user value on this object.
virtual const Any & | getUserAny (void) const
| Retrieves the custom user value associated with this object.
virtual RenderSystemData * | getRenderSystemData () const
| Sets render system private data.
virtual void | setRenderSystemData (RenderSystemData *val) const
| gets render system private data

## Protected Types

typedef std::map< size_t, Vector4 > | CustomParameterMap

## Protected Attributes

CustomParameterMap | mCustomParameters
bool | mPolygonModeOverrideable
bool | mUseIdentityProjection
bool | mUseIdentityView
Any | mUserAny
RenderSystemData * | mRenderSystemData

## Classes

class | RenderSystemData
| An internal class that should be used only by a render system for internal use. More...
class | Visitor
| Visitor object that can be used to iterate over a collection of Renderable instances abstractly. More...

## Detailed Description

Abstract class defining the interface all renderable objects must implement.

Remarks:
  This interface abstracts renderable discrete objects which will be queued in the render pipeline, grouped by material. Classes implementing this interface must be based on a single material, a single world matrix (or a collection of world matrices which are blended by weights), and must be renderable via a single render operation.

  Note that deciding whether to put these objects in the rendering pipeline is done from the more specific classes e.g. entities. Only once it is decided that the specific class is to be rendered is the abstract version created (could be more than one per visible object) and pushed onto the rendering queue.

Definition at line 57 of file OgreRenderable.h.

## Member Typedef Documentation

typedef std::map<size_t, Vector4> Ogre::Renderable::CustomParameterMap `[protected]`

Definition at line 371 of file OgreRenderable.h.

## Constructor & Destructor Documentation

Ogre::Renderable::Renderable | ( |  | ) |

Definition at line 67 of file OgreRenderable.h.

virtual Ogre::Renderable::~Renderable | ( |  | ) | `[virtual]`

Virtual destructor needed as class has virtual methods.

Definition at line 69 of file OgreRenderable.h.

## Member Function Documentation

virtual const MaterialPtr& Ogre::Renderable::getMaterial | ( | void |  | ) | const`[pure virtual]`

Retrieves a weak reference to the material this renderable object uses.

Remarks:
  Note that the Renderable also has the option to override the getTechnique method to specify a particular Technique to use instead of the best one available.

Implemented in Ogre::BillboardChain, Ogre::BillboardSet, Ogre::BorderRenderable, Ogre::Frustum, Ogre::InstancedGeometry::GeometryBucket, Ogre::ManualObject::ManualObjectSection, Ogre::Node, Ogre::OverlayElement, Ogre::ShadowRenderable, Ogre::SimpleRenderable, Ogre::StaticGeometry::GeometryBucket, and Ogre::SubEntity.

virtual Technique* Ogre::Renderable::getTechnique | ( | void |  | ) | const`[virtual]`

Retrieves a pointer to the Material Technique this renderable object uses.

Remarks:
  This is to allow Renderables to use a chosen Technique if they wish, otherwise they will use the best Technique available for the Material they are using.

Reimplemented in Ogre::InstancedGeometry::GeometryBucket, Ogre::StaticGeometry::GeometryBucket, and Ogre::SubEntity.

Definition at line 87 of file OgreRenderable.h.

virtual void Ogre::Renderable::getRenderOperation | ( | RenderOperation & | op | ) | `[pure virtual]`

Gets the render operation required to send this object to the frame buffer.

Implemented in Ogre::BillboardChain, Ogre::BillboardSet, Ogre::BorderRenderable, Ogre::Frustum, Ogre::ManualObject::ManualObjectSection, Ogre::Node, Ogre::PanelOverlayElement, Ogre::ShadowRenderable, Ogre::SimpleRenderable, Ogre::StaticGeometry::GeometryBucket, Ogre::SubEntity, and Ogre::TextAreaOverlayElement.

virtual bool Ogre::Renderable::preRender | ( | SceneManager * | sm,
|  | RenderSystem * | rsys |
| ) |  |  | `[virtual]`

Called just prior to the Renderable being rendered.

Remarks:
  OGRE is a queued renderer, so the actual render commands are executed at a later time than the point at which an object is discovered to be visible. This allows ordering & grouping of renders without the discovery process having to be aware of it. It also means OGRE uses declarative render information rather than immediate mode rendering - this is very useful in that certain effects and processes can automatically be applied to a wide range of scenes, but the downside is that special cases are more difficult to handle, because there is not the declared state to cope with it.

  This method allows a Renderable to do something special at the actual point of rendering if it wishes to. When this method is called, all the material render state as declared by this Renderable has already been set, all that is left to do is to bind the buffers and perform the render. The Renderable may modify render state itself if it wants to (and restore it in the postRender call) before the automated render happens, or by returning 'false' from this method can actually suppress the automatic render and perform one of its own.

Returns:
  true if the automatic render should proceed, false to skip it on the assumption that the Renderable has done it manually.

Definition at line 116 of file OgreRenderable.h.

virtual void Ogre::Renderable::postRender | ( | SceneManager * | sm,
|  | RenderSystem * | rsys |
| ) |  |  | `[virtual]`

Called immediately after the Renderable has been rendered.

Definition at line 119 of file OgreRenderable.h.

virtual void Ogre::Renderable::getWorldTransforms | ( | Matrix4 * | xform | ) | const`[pure virtual]`

Gets the world transform matrix / matrices for this renderable object.

Remarks:
  If the object has any derived transforms, these are expected to be up to date as long as all the SceneNode structures have been updated before this is called.

  This method will populate xform with 1 matrix if it does not use vertex blending. If it does use vertex blending it will fill the passed in pointer with an array of matrices, the length being the value returned from getNumWorldTransforms.

Note:
  Internal Ogre never supports non-affine matrix for world transform matrix/matrices, the behavior is undefined if returns non-affine matrix here.

See also:
  Matrix4::isAffine.

Implemented in Ogre::BillboardChain, Ogre::BillboardSet, Ogre::BorderRenderable, Ogre::Entity::EntityShadowRenderable, Ogre::Frustum, Ogre::InstancedGeometry::GeometryBucket, Ogre::ManualObject::ManualObjectSection, Ogre::ManualObject::ManualObjectSectionShadowRenderable, Ogre::Node, Ogre::OverlayElement, Ogre::Rectangle2D, Ogre::ShadowRenderable, Ogre::SimpleRenderable, Ogre::StaticGeometry::GeometryBucket, Ogre::StaticGeometry::LODBucket::LODShadowRenderable, Ogre::SubEntity, and Ogre::WireBoundingBox.

virtual unsigned short Ogre::Renderable::getNumWorldTransforms | ( | void |  | ) | const`[virtual]`

Returns the number of world transform matrices this renderable requires.

Remarks:
  When a renderable uses vertex blending, it uses multiple world matrices instead of a single one. Each vertex sent to the pipeline can reference one or more matrices in this list with given weights. If a renderable does not use vertex blending this method returns 1, which is the default for simplicity.

Reimplemented in Ogre::BorderRenderable, Ogre::InstancedGeometry::GeometryBucket, and Ogre::SubEntity.

Definition at line 143 of file OgreRenderable.h.

void Ogre::Renderable::setUseIdentityProjection | ( | bool | useIdentityProjection | ) |

Sets whether or not to use an 'identity' projection.

Remarks:
  Usually Renderable objects will use a projection matrix as determined by the active camera. However, if they want they can cancel this out and use an identity projection, which effectively projects in 2D using a {-1, 1} view space. Useful for overlay rendering. Normal renderables need not change this. The default is false.

See also:
  Renderable::getUseIdentityProjection

Definition at line 154 of file OgreRenderable.h.

bool Ogre::Renderable::getUseIdentityProjection | ( | void |  | ) | const

Returns whether or not to use an 'identity' projection.

Remarks:
  Usually Renderable objects will use a projection matrix as determined by the active camera. However, if they want they can cancel this out and use an identity projection, which effectively projects in 2D using a {-1, 1} view space. Useful for overlay rendering. Normal renderables need not change this.

See also:
  Renderable::setUseIdentityProjection

Definition at line 168 of file OgreRenderable.h.

void Ogre::Renderable::setUseIdentityView | ( | bool | useIdentityView | ) |

Sets whether or not to use an 'identity' view.

Remarks:
  Usually Renderable objects will use a view matrix as determined by the active camera. However, if they want they can cancel this out and use an identity matrix, which means all geometry is assumed to be relative to camera space already. Useful for overlay rendering. Normal renderables need not change this. The default is false.

See also:
  Renderable::getUseIdentityView

Definition at line 179 of file OgreRenderable.h.

bool Ogre::Renderable::getUseIdentityView | ( | void |  | ) | const

Returns whether or not to use an 'identity' view.

Remarks:
  Usually Renderable objects will use a view matrix as determined by the active camera. However, if they want they can cancel this out and use an identity matrix, which means all geometry is assumed to be relative to camera space already. Useful for overlay rendering. Normal renderables need not change this.

See also:
  Renderable::setUseIdentityView

Definition at line 193 of file OgreRenderable.h.

virtual Real Ogre::Renderable::getSquaredViewDepth | ( | const Camera * | cam | ) | const`[pure virtual]`

Returns the camera-relative squared depth of this renderable.

Remarks:
  Used to sort transparent objects. Squared depth is used rather than actual depth to avoid having to perform a square root on the result.

Implemented in Ogre::BillboardChain, Ogre::BillboardSet, Ogre::BorderRenderable, Ogre::Frustum, Ogre::InstancedGeometry::GeometryBucket, Ogre::ManualObject::ManualObjectSection, Ogre::Node, Ogre::OverlayElement, Ogre::Rectangle2D, Ogre::ShadowRenderable, Ogre::StaticGeometry::GeometryBucket, Ogre::SubEntity, and Ogre::WireBoundingBox.

Referenced by Ogre::QueuedRenderableCollection::RadixSortFunctorDistance::operator()(), and Ogre::QueuedRenderableCollection::DepthSortDescendingLess::operator()().

virtual const LightList& Ogre::Renderable::getLights | ( | void |  | ) | const`[pure virtual]`

Gets a list of lights, ordered relative to how close they are to this renderable.

Remarks:
  Directional lights, which have no position, will always be first on this list.

Implemented in Ogre::BillboardChain, Ogre::BillboardSet, Ogre::BorderRenderable, Ogre::Frustum, Ogre::InstancedGeometry::GeometryBucket, Ogre::ManualObject::ManualObjectSection, Ogre::Node, Ogre::OverlayElement, Ogre::ShadowRenderable, Ogre::SimpleRenderable, Ogre::StaticGeometry::GeometryBucket, Ogre::SubEntity, and Ogre::TagPoint.

virtual bool Ogre::Renderable::getCastsShadows | ( | void |  | ) | const`[virtual]`

Method which reports whether this renderable would normally cast a shadow.

Remarks:
  Subclasses should override this if they could have been used to generate a shadow.

Reimplemented in Ogre::InstancedGeometry::GeometryBucket, Ogre::StaticGeometry::GeometryBucket, and Ogre::SubEntity.

Definition at line 214 of file OgreRenderable.h.

void Ogre::Renderable::setCustomParameter | ( | size_t | index,
|  | const Vector4 & | value |
| ) |  |  |

Sets a custom parameter for this Renderable, which may be used to drive calculations for this specific Renderable, like GPU program parameters.

Remarks:
  Calling this method simply associates a numeric index with a 4-dimensional value for this specific Renderable. This is most useful if the material which this Renderable uses a vertex or fragment program, and has an ACT_CUSTOM parameter entry. This parameter entry can refer to the index you specify as part of this call, thereby mapping a custom parameter for this renderable to a program parameter.

Parameters:

  | index | The index with which to associate the value. Note that this does not have to start at 0, and can include gaps. It also has no direct correlation with a GPU program parameter index - the mapping between the two is performed by the ACT_CUSTOM entry, if that is used.
  | value | The value to associate.

Definition at line 231 of file OgreRenderable.h.

const Vector4& Ogre::Renderable::getCustomParameter | ( | size_t | index | ) | const

Gets the custom value associated with this Renderable at the given index.

Parameters:

  | @see | setCustomParaemter for full details.

Definition at line 240 of file OgreRenderable.h.

References Ogre::Exception::ERR_ITEM_NOT_FOUND, and OGRE_EXCEPT.

virtual void Ogre::Renderable::_updateCustomGpuParameter | ( | const GpuProgramParameters::AutoConstantEntry & | constantEntry,
|  | GpuProgramParameters * | params |
| ) |  |  | const`[virtual]`

Update a custom GpuProgramParameters constant which is derived from information only this Renderable knows.

Remarks:
  This method allows a Renderable to map in a custom GPU program parameter based on it's own data. This is represented by a GPU auto parameter of ACT_CUSTOM, and to allow there to be more than one of these per Renderable, the 'data' field on the auto parameter will identify which parameter is being updated. The implementation of this method must identify the parameter being updated, and call a 'setConstant' method on the passed in GpuProgramParameters object, using the details provided in the incoming auto constant setting to identify the index at which to set the parameter.

  You do not need to override this method if you're using the standard sets of data associated with the Renderable as provided by setCustomParameter and getCustomParameter. By default, the implementation will map from the value indexed by the 'constantEntry.data' parameter to a value previously set by setCustomParameter. But custom Renderables are free to override this if they want, in any case.

Parameters:

  | constantEntry | The auto constant entry referring to the parameter being updated
  | params | The parameters object which this method should call to set the updated parameters.

Reimplemented in Ogre::SubEntity.

Definition at line 279 of file OgreRenderable.h.

References Ogre::GpuProgramParameters::_writeRawConstant(), Ogre::GpuProgramParameters::AutoConstantEntry::data, Ogre::GpuProgramParameters::AutoConstantEntry::elementCount, and Ogre::GpuProgramParameters::AutoConstantEntry::physicalIndex.

virtual void Ogre::Renderable::setPolygonModeOverrideable | ( | bool | override | ) | `[virtual]`

Sets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.

Parameters:

  | override | true means that a lower camera detail will override this renderables detail level, false means it won't.

Definition at line 296 of file OgreRenderable.h.

virtual bool Ogre::Renderable::getPolygonModeOverrideable | ( | void |  | ) | const`[virtual]`

Gets whether this renderable's chosen detail level can be overridden (downgraded) by the camera setting.

Reimplemented in Ogre::BorderRenderable.

Definition at line 304 of file OgreRenderable.h.

virtual void Ogre::Renderable::setUserAny | ( | const Any & | anything | ) | `[virtual]`

Sets any kind of user value on this object.

Remarks:
  This method allows you to associate any user value you like with this Renderable. This can be a pointer back to one of your own classes for instance.

Definition at line 315 of file OgreRenderable.h.

virtual const Any& Ogre::Renderable::getUserAny | ( | void |  | ) | const`[virtual]`

Retrieves the custom user value associated with this object.

Definition at line 319 of file OgreRenderable.h.

virtual RenderSystemData* Ogre::Renderable::getRenderSystemData | ( |  | ) | const`[virtual]`

Sets render system private data.

Remarks:
  This should only be used by a render system

Definition at line 356 of file OgreRenderable.h.

virtual void Ogre::Renderable::setRenderSystemData | ( | RenderSystemData * | val | ) | const`[virtual]`

gets render system private data

Remarks:
  This should only be used by a render system

Definition at line 364 of file OgreRenderable.h.

## Member Data Documentation

CustomParameterMap Ogre::Renderable::mCustomParameters `[protected]`

Definition at line 372 of file OgreRenderable.h.

bool Ogre::Renderable::mPolygonModeOverrideable `[protected]`

Definition at line 373 of file OgreRenderable.h.

bool Ogre::Renderable::mUseIdentityProjection `[protected]`

Definition at line 374 of file OgreRenderable.h.

bool Ogre::Renderable::mUseIdentityView `[protected]`

Definition at line 375 of file OgreRenderable.h.

Any Ogre::Renderable::mUserAny `[protected]`

Definition at line 376 of file OgreRenderable.h.

RenderSystemData* Ogre::Renderable::mRenderSystemData `[mutable, protected]`

Definition at line 377 of file OgreRenderable.h.

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

- OgreRenderable.h

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:35:17 2009