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

Ogre::ShadowCaster Class Reference

This class defines the interface that must be implemented by shadow casters. More...

#include <OgreShadowCaster.h>

Inheritance diagram for Ogre::ShadowCaster:

Inheritance graph
[legend]
List of all members.

Public Types

typedef std::vector< ShadowRenderable * > ShadowRenderableList
typedef VectorIterator< ShadowRenderableListShadowRenderableListIterator

Public Methods

virtual bool getCastShadows (void) const=0
 Returns whether or not this object currently casts a shadow.

virtual EdgeDatagetEdgeList (void)=0
 Returns details of the edges which might be used to determine a silhouette.

virtual const AxisAlignedBoxgetWorldBoundingBox (bool derive=false) const=0
 Get the world bounding box of the caster.

virtual const AxisAlignedBoxgetLightCapBounds (void) const=0
 Gets the world space bounding box of the light cap.

virtual const AxisAlignedBoxgetDarkCapBounds (const Light &light, Real dirLightExtrusionDist) const=0
 Gets the world space bounding box of the dark cap, as extruded using the light provided.

virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator (ShadowTechnique shadowTechnique, const Light *light, HardwareIndexBufferSharedPtr *indexBuffer, bool extrudeVertices, Real extrusionDistance, unsigned long flags=0)=0
 Gets an iterator over the renderables required to render the shadow volume.

virtual Real getPointExtrusionDistance (const Light *l) const=0
 Get the distance to extrude for a point/spot light.


Static Public Methods

void extrudeVertices (HardwareVertexBufferSharedPtr vertexBuffer, size_t originalVertexCount, const Vector4 &lightPos, Real extrudeDist)
 Utility method for extruding vertices based on a light.


Protected Methods

Real getExtrusionDistance (const Vector3 &objectPos, const Light *light) const
 Helper moethod for calculating extrusion distance.

virtual void updateEdgeListLightFacing (EdgeData *edgeData, const Vector4 &lightPos)
 Tells the caster to perform the tasks necessary to update the edge data's light listing.

virtual void generateShadowVolume (EdgeData *edgeData, HardwareIndexBufferSharedPtr indexBuffer, const Light *light, ShadowRenderableList &shadowRenderables, unsigned long flags)
 Generates the indexes required to render a shadow volume into the index buffer which is passed in, and updates shadow renderables to use it.

virtual void extrudeBounds (AxisAlignedBox &box, const Vector4 &lightPos, Real extrudeDist) const
 Utility method for extruding a bounding box.


Detailed Description

This class defines the interface that must be implemented by shadow casters.

Definition at line 109 of file OgreShadowCaster.h.


Member Typedef Documentation

typedef std::vector<ShadowRenderable*> Ogre::ShadowCaster::ShadowRenderableList
 

Definition at line 125 of file OgreShadowCaster.h.

typedef VectorIterator<ShadowRenderableList> Ogre::ShadowCaster::ShadowRenderableListIterator
 

Definition at line 126 of file OgreShadowCaster.h.

Referenced by Ogre::Entity::getShadowVolumeRenderableIterator().


Member Function Documentation

void Ogre::ShadowCaster::extrudeBounds AxisAlignedBox   box,
const Vector4   lightPos,
Real    extrudeDist
const [protected, virtual]
 

Utility method for extruding a bounding box.

Parameters:
box  Original bounding box, will be updated in-place
lightPos  4D light position in object space, when w=0.0f this represents a directional light
extrudeDist  The distance to extrude

Definition at line 274 of file OgreShadowCaster.cpp.

References Ogre::AxisAlignedBox::getAllCorners(), Ogre::AxisAlignedBox::getMaximum(), Ogre::AxisAlignedBox::getMinimum(), Ogre::Vector3::makeCeil(), Ogre::Vector3::makeFloor(), Ogre::Vector3::normalise(), Ogre::Real, Ogre::AxisAlignedBox::setExtents(), Ogre::Vector4::w, Ogre::Vector4::x, Ogre::Vector3::x, Ogre::Vector4::y, Ogre::Vector3::y, Ogre::Vector4::z, and Ogre::Vector3::z.

Referenced by Ogre::MovableObject::getDarkCapBounds().

void Ogre::ShadowCaster::extrudeVertices HardwareVertexBufferSharedPtr    vertexBuffer,
size_t    originalVertexCount,
const Vector4   lightPos,
Real    extrudeDist
[static]
 

Utility method for extruding vertices based on a light.

Remarks:
Unfortunately, because D3D cannot handle homogenous (4D) position coordinates in the fixed-function pipeline (GL can, but we have to be cross-API), when we extrude in software we cannot extrude to infinity the way we do in the vertex program (by setting w to 0.0f). Therefore we extrude by a fixed distance, which may cause some problems with larger scenes. Luckily better hardware (ie vertex programs) can fix this.
Parameters:
vertexBuffer  The vertex buffer containing ONLY xyz position values, which must be originalVertexCount * 2 * 3 floats long.
originalVertexCount  The count of the original number of vertices, ie the number in the mesh, not counting the doubling which has already been done (by VertexData::prepareForShadowVolume) to provide the extruded area of the buffer.
lightPos  4D light position in object space, when w=0.0f this represents a directional light
extrudeDist  The distance to extrude

Definition at line 235 of file OgreShadowCaster.cpp.

References Ogre::Vector3::normalise(), Ogre::Real, Ogre::Vector4::w, Ogre::Vector3::x, Ogre::Vector4::x, Ogre::Vector3::y, Ogre::Vector4::y, Ogre::Vector3::z, and Ogre::Vector4::z.

Referenced by Ogre::Entity::getShadowVolumeRenderableIterator().

void Ogre::ShadowCaster::generateShadowVolume EdgeData   edgeData,
HardwareIndexBufferSharedPtr    indexBuffer,
const Light   light,
ShadowRenderableList   shadowRenderables,
unsigned long    flags
[protected, virtual]
 

Generates the indexes required to render a shadow volume into the index buffer which is passed in, and updates shadow renderables to use it.

Parameters:
edgeData  The edge information to use
indexBuffer  The buffer into which to write data into; current contents are assumed to be discardable.
light  The light, mainly for type info as silhouette calculations should already have been done in updateEdgeListLightFacing
shadowRenderables  A list of shadow renderables which has already been constructed but will need populating with details of the index ranges to be used.
flags  Additional controller flags, see ShadowRenderableFlags

Definition at line 37 of file OgreShadowCaster.cpp.

References Ogre::EdgeData::Edge::degenerate, Ogre::EdgeData::edgeGroups, Ogre::EdgeData::EdgeGroup::edges, Ogre::ShadowRenderable::getLightCapRenderable(), Ogre::ShadowRenderable::getRenderOperationForUpdate(), Ogre::Light::getType(), Ogre::IndexData::indexCount, Ogre::RenderOperation::indexData, Ogre::IndexData::indexStart, Ogre::EdgeData::Triangle::lightFacing, Ogre::SRF_EXTRUDE_TO_INFINITY, Ogre::SRF_INCLUDE_DARK_CAP, Ogre::SRF_INCLUDE_LIGHT_CAP, Ogre::EdgeData::triangles, Ogre::EdgeData::Edge::triIndex, Ogre::VertexData::vertexCount, Ogre::EdgeData::EdgeGroup::vertexData, Ogre::EdgeData::EdgeGroup::vertexSet, Ogre::EdgeData::Triangle::vertexSet, Ogre::EdgeData::Triangle::vertIndex, and Ogre::EdgeData::Edge::vertIndex.

Referenced by Ogre::Entity::getShadowVolumeRenderableIterator().

virtual bool Ogre::ShadowCaster::getCastShadows void    const [pure virtual]
 

Returns whether or not this object currently casts a shadow.

Implemented in Ogre::MovableObject.

virtual const AxisAlignedBox& Ogre::ShadowCaster::getDarkCapBounds const Light   light,
Real    dirLightExtrusionDist
const [pure virtual]
 

Gets the world space bounding box of the dark cap, as extruded using the light provided.

Implemented in Ogre::MovableObject.

Referenced by Ogre::SceneManager::renderShadowVolumesToStencil().

virtual EdgeData* Ogre::ShadowCaster::getEdgeList void    [pure virtual]
 

Returns details of the edges which might be used to determine a silhouette.

Implemented in Ogre::Entity, and Ogre::MovableObject.

Real Ogre::ShadowCaster::getExtrusionDistance const Vector3   objectPos,
const Light   light
const [protected]
 

Helper moethod for calculating extrusion distance.

Definition at line 320 of file OgreShadowCaster.cpp.

References Ogre::Light::getAttenuationRange(), Ogre::Light::getDerivedPosition(), Ogre::Vector3::length(), and Ogre::Real.

Referenced by Ogre::MovableObject::getPointExtrusionDistance().

virtual const AxisAlignedBox& Ogre::ShadowCaster::getLightCapBounds void    const [pure virtual]
 

Gets the world space bounding box of the light cap.

Implemented in Ogre::MovableObject.

Referenced by Ogre::SceneManager::renderShadowVolumesToStencil().

virtual Real Ogre::ShadowCaster::getPointExtrusionDistance const Light   l const [pure virtual]
 

Get the distance to extrude for a point/spot light.

Implemented in Ogre::MovableObject.

Referenced by Ogre::SceneManager::renderShadowVolumesToStencil().

virtual ShadowRenderableListIterator Ogre::ShadowCaster::getShadowVolumeRenderableIterator ShadowTechnique    shadowTechnique,
const Light   light,
HardwareIndexBufferSharedPtr   indexBuffer,
bool    extrudeVertices,
Real    extrusionDistance,
unsigned long    flags = 0
[pure virtual]
 

Gets an iterator over the renderables required to render the shadow volume.

Remarks:
Shadowable geometry should ideally be designed such that there is only one ShadowRenderable required to render the the shadow; however this is not a necessary limitation and it can be exceeded if required.
Parameters:
shadowTechnique  The technique being used to generate the shadow
light  The light to generate the shadow from
indexBuffer  The index buffer to build the renderables into, the current contents are assumed to be disposable.
extrudeVertices  If true, this means this class should extrude the vertices of the back of the volume in software. If false, it will not be done (a vertex program is assumed).
extrusionDistance  The distance to extrude the shadow volume
flags  Technique-specific flags, see ShadowRenderableFlags

Implemented in Ogre::Entity, and Ogre::MovableObject.

Referenced by Ogre::SceneManager::renderShadowVolumesToStencil().

virtual const AxisAlignedBox& Ogre::ShadowCaster::getWorldBoundingBox bool    derive = false const [pure virtual]
 

Get the world bounding box of the caster.

Implemented in Ogre::MovableObject.

Referenced by Ogre::SceneManager::renderShadowVolumesToStencil().

void Ogre::ShadowCaster::updateEdgeListLightFacing EdgeData   edgeData,
const Vector4   lightPos
[protected, virtual]
 

Tells the caster to perform the tasks necessary to update the edge data's light listing.

Can be overridden if the subclass needs to do additional things.

Parameters:
edgeData  The edge information to update
lightPos  4D vector representing the light, a directional light has w=0.0

Definition at line 31 of file OgreShadowCaster.cpp.

References Ogre::EdgeData::updateTriangleLightFacing().

Referenced by Ogre::Entity::getShadowVolumeRenderableIterator().


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

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:27:14 2004