OgreRenderable.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Renderable_H__
#define __Renderable_H__
#include "OgrePrerequisites.h"
#include "OgreCommon.h"
#include "OgreRenderOperation.h"
#include "OgreMatrix4.h"
#include "OgreMaterial.h"
#include "OgrePlane.h"
#include "OgreGpuProgram.h"
#include "OgreVector4.h"
#include "OgreException.h"
#include "OgreUserObjectBindings.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport Renderable
{
public:
class RenderSystemData {};
public:
Renderable() : mPolygonModeOverrideable(true), mUseIdentityProjection(false), mUseIdentityView(false), mRenderSystemData(NULL) {}
virtual ~Renderable()
{
if (mRenderSystemData)
{
delete mRenderSystemData;
mRenderSystemData = NULL;
}
}
virtual const MaterialPtr& getMaterial(void) const = 0;
virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(0, this); }
virtual void getRenderOperation(RenderOperation& op) = 0;
virtual bool preRender(SceneManager* sm, RenderSystem* rsys)
{ (void)sm; (void)rsys; return true; }
virtual void postRender(SceneManager* sm, RenderSystem* rsys)
{ (void)sm; (void)rsys; }
virtual void getWorldTransforms(Matrix4* xform) const = 0;
virtual unsigned short getNumWorldTransforms(void) const { return 1; }
void setUseIdentityProjection(bool useIdentityProjection)
{
mUseIdentityProjection = useIdentityProjection;
}
bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
void setUseIdentityView(bool useIdentityView)
{
mUseIdentityView = useIdentityView;
}
bool getUseIdentityView(void) const { return mUseIdentityView; }
virtual Real getSquaredViewDepth(const Camera* cam) const = 0;
virtual const LightList& getLights(void) const = 0;
virtual bool getCastsShadows(void) const { return false; }
void setCustomParameter(size_t index, const Vector4& value)
{
mCustomParameters[index] = value;
}
void removeCustomParameter(size_t index)
{
mCustomParameters.erase(index);
}
bool hasCustomParameter(size_t index) const
{
return mCustomParameters.find(index) != mCustomParameters.end();
}
const Vector4& getCustomParameter(size_t index) const
{
CustomParameterMap::const_iterator i = mCustomParameters.find(index);
if (i != mCustomParameters.end())
{
return i->second;
}
else
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Parameter at the given index was not found.",
"Renderable::getCustomParameter");
}
}
virtual void _updateCustomGpuParameter(
const GpuProgramParameters::AutoConstantEntry& constantEntry,
GpuProgramParameters* params) const
{
CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data);
if (i != mCustomParameters.end())
{
params->_writeRawConstant(constantEntry.physicalIndex, i->second,
constantEntry.elementCount);
}
}
virtual void setPolygonModeOverrideable(bool override)
{
mPolygonModeOverrideable = override;
}
virtual bool getPolygonModeOverrideable(void) const
{
return mPolygonModeOverrideable;
}
OGRE_DEPRECATED virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
OGRE_DEPRECATED virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
class Visitor
{
public:
virtual ~Visitor() { }
virtual void visit(Renderable* rend, ushort lodIndex, bool isDebug,
Any* pAny = 0) = 0;
};
virtual RenderSystemData * getRenderSystemData() const
{
return mRenderSystemData;
}
virtual void setRenderSystemData(RenderSystemData * val) const
{
mRenderSystemData = val;
}
protected:
typedef map<size_t, Vector4>::type CustomParameterMap;
CustomParameterMap mCustomParameters;
bool mPolygonModeOverrideable;
bool mUseIdentityProjection;
bool mUseIdentityView;
UserObjectBindings mUserObjectBindings;
mutable RenderSystemData * mRenderSystemData;
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif //__Renderable_H__
OgreVector4.h
Ogre::Renderable::mUserObjectBindings
UserObjectBindings mUserObjectBindings
Definition: OgreRenderable.h:419
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
OgrePlane.h
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::GpuProgramParameters::AutoConstantEntry::data
size_t data
Definition: OgreGpuProgramParams.h:1228
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Renderable::setUserAny
virtual OGRE_DEPRECATED void setUserAny(const Any &anything)
Definition: OgreRenderable.h:344
Ogre::Renderable::setRenderSystemData
virtual void setRenderSystemData(RenderSystemData *val) const
Sets RenderSystem private data.
Definition: OgreRenderable.h:407
Ogre::Renderable::getUserObjectBindings
const UserObjectBindings & getUserObjectBindings() const
Return an instance of user objects binding associated with this class.
Definition: OgreRenderable.h:361
OGRE_DEPRECATED
#define OGRE_DEPRECATED
Definition: OgrePlatform.h:189
Ogre::GpuProgramParameters::AutoConstantEntry
Structure recording the use of an automatic parameter.
Definition: OgreGpuProgramParams.h:1215
Ogre::Renderable::getNumWorldTransforms
virtual unsigned short getNumWorldTransforms(void) const
Returns the number of world transform matrices this renderable requires.
Definition: OgreRenderable.h:153
Ogre::GpuProgramParameters::AutoConstantEntry::elementCount
size_t elementCount
The number of elements per individual entry in this constant Used in case people used packed elements...
Definition: OgreGpuProgramParams.h:1225
Ogre::Renderable::setCustomParameter
void setCustomParameter(size_t index, const Vector4 &value)
Sets a custom parameter for this Renderable, which may be used to drive calculations for this specifi...
Definition: OgreRenderable.h:241
Ogre::Any
Variant type that can hold Any other type.
Definition: OgreAny.h:56
Ogre::Renderable::getUserAny
virtual OGRE_DEPRECATED const Any & getUserAny(void) const
Definition: OgreRenderable.h:349
Ogre::Renderable::RenderSystemData
An internal class that should be used only by a render system for internal use.
Definition: OgreRenderable.h:71
Ogre::Renderable::Visitor::~Visitor
virtual ~Visitor()
Virtual destructor needed as class has virtual methods.
Definition: OgreRenderable.h:381
OgreCommon.h
Ogre::Renderable::getCastsShadows
virtual bool getCastsShadows(void) const
Method which reports whether this renderable would normally cast a shadow.
Definition: OgreRenderable.h:224
Ogre::GpuProgramParameters::AutoConstantEntry::physicalIndex
size_t physicalIndex
The target (physical) constant index.
Definition: OgreGpuProgramParams.h:1221
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Renderable::removeCustomParameter
void removeCustomParameter(size_t index)
Removes a custom value which is associated with this Renderable at the given index.
Definition: OgreRenderable.h:250
Ogre::Renderable::setUseIdentityView
void setUseIdentityView(bool useIdentityView)
Sets whether or not to use an &#39;identity&#39; view.
Definition: OgreRenderable.h:189
Ogre::Renderable::getUseIdentityView
bool getUseIdentityView(void) const
Returns whether or not to use an &#39;identity&#39; view.
Definition: OgreRenderable.h:203
OgreUserObjectBindings.h
Ogre::GpuProgramParameters::_writeRawConstant
void _writeRawConstant(size_t physicalIndex, const Vector4 &vec, size_t count=4)
Write a 4-element floating-point parameter to the program directly to the underlying constants buffer...
OgrePrerequisites.h
Ogre::Renderable::mCustomParameters
CustomParameterMap mCustomParameters
Definition: OgreRenderable.h:415
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Definition: OgreRenderable.h:377
Ogre::Renderable::preRender
virtual bool preRender(SceneManager *sm, RenderSystem *rsys)
Called just prior to the Renderable being rendered.
Definition: OgreRenderable.h:123
Ogre::RenderSystem
Defines the functionality of a 3D API.
Definition: OgreRenderSystem.h:125
Ogre::Renderable::postRender
virtual void postRender(SceneManager *sm, RenderSystem *rsys)
Called immediately after the Renderable has been rendered.
Definition: OgreRenderable.h:128
Ogre::Renderable::Renderable
Renderable()
Definition: OgreRenderable.h:73
OgreRenderOperation.h
OgreMatrix4.h
Ogre::Renderable::mPolygonModeOverrideable
bool mPolygonModeOverrideable
Definition: OgreRenderable.h:416
Ogre::Renderable::getPolygonModeOverrideable
virtual bool getPolygonModeOverrideable(void) const
Gets whether this renderable&#39;s chosen detail level can be overridden (downgraded) by the camera setti...
Definition: OgreRenderable.h:332
Ogre::Renderable::getCustomParameter
const Vector4 & getCustomParameter(size_t index) const
Gets the custom value associated with this Renderable at the given index.
Definition: OgreRenderable.h:268
Ogre::Renderable::getUseIdentityProjection
bool getUseIdentityProjection(void) const
Returns whether or not to use an &#39;identity&#39; projection.
Definition: OgreRenderable.h:178
Ogre::Renderable::mRenderSystemData
RenderSystemData * mRenderSystemData
User objects binding.
Definition: OgreRenderable.h:420
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::Renderable::getUserObjectBindings
UserObjectBindings & getUserObjectBindings()
Return an instance of user objects binding associated with this class.
Definition: OgreRenderable.h:355
OGRE_EXCEPT
#define OGRE_EXCEPT(num, desc, src)
Definition: OgreException.h:334
Ogre::Exception::ERR_ITEM_NOT_FOUND
Definition: OgreException.h:106
Ogre
Definition: OgreAndroidLogListener.h:34
OgreException.h
Ogre::Renderable::CustomParameterMap
map< size_t, Vector4 >::type CustomParameterMap
Definition: OgreRenderable.h:414
Ogre::Renderable::setUseIdentityProjection
void setUseIdentityProjection(bool useIdentityProjection)
Sets whether or not to use an &#39;identity&#39; projection.
Definition: OgreRenderable.h:164
Ogre::SharedPtr< Material >
OgreHeaderPrefix.h
Ogre::UserObjectBindings
Class that provides convenient interface to establish a linkage between custom user application objec...
Definition: OgreUserObjectBindings.h:49
Ogre::Renderable::setPolygonModeOverrideable
virtual void setPolygonModeOverrideable(bool override)
Sets whether this renderable&#39;s chosen detail level can be overridden (downgraded) by the camera setti...
Definition: OgreRenderable.h:324
Ogre::Renderable::getTechnique
virtual Technique * getTechnique(void) const
Retrieves a pointer to the Material Technique this renderable object uses.
Definition: OgreRenderable.h:94
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::Technique
Class representing an approach to rendering this particular Material.
Definition: OgreTechnique.h:53
Ogre::Renderable::~Renderable
virtual ~Renderable()
Virtual destructor needed as class has virtual methods.
Definition: OgreRenderable.h:75
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::Renderable::mUseIdentityProjection
bool mUseIdentityProjection
Definition: OgreRenderable.h:417
OgreMaterial.h
Ogre::Renderable::mUseIdentityView
bool mUseIdentityView
Definition: OgreRenderable.h:418
Ogre::Renderable::hasCustomParameter
bool hasCustomParameter(size_t index) const
Checks whether a custom value is associated with this Renderable at the given index.
Definition: OgreRenderable.h:259
Ogre::SceneManager
Manages the organisation and rendering of a &#39;scene&#39; i.e.
Definition: OgreSceneManager.h:143
Ogre::Renderable::_updateCustomGpuParameter
virtual void _updateCustomGpuParameter(const GpuProgramParameters::AutoConstantEntry &constantEntry, GpuProgramParameters *params) const
Update a custom GpuProgramParameters constant which is derived from information only this Renderable ...
Definition: OgreRenderable.h:307
OgreGpuProgram.h
Ogre::Renderable::getRenderSystemData
virtual RenderSystemData * getRenderSystemData() const
Gets RenderSystem private data.
Definition: OgreRenderable.h:399
Ogre::GpuProgramParameters
Collects together the program parameters used for a GpuProgram.
Definition: OgreGpuProgramParams.h:702

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