OgreShadowCaster.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 __ShadowCaster_H__
#define __ShadowCaster_H__
#include "OgrePrerequisites.h"
#include "OgreRenderable.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport ShadowRenderable : public Renderable, public ShadowDataAlloc
{
protected:
MaterialPtr mMaterial;
RenderOperation mRenderOp;
ShadowRenderable* mLightCap;
public:
ShadowRenderable() : mMaterial(), mLightCap(0) {}
virtual ~ShadowRenderable() { delete mLightCap; }
void setMaterial(const MaterialPtr& mat) { mMaterial = mat; }
const MaterialPtr& getMaterial(void) const { return mMaterial; }
void getRenderOperation(RenderOperation& op) { op = mRenderOp; }
RenderOperation* getRenderOperationForUpdate(void) {return &mRenderOp;}
void getWorldTransforms(Matrix4* xform) const = 0;
Real getSquaredViewDepth(const Camera*) const{ return 0; /* not used */}
const LightList& getLights(void) const;
bool isLightCapSeparate(void) const { return mLightCap != 0; }
ShadowRenderable* getLightCapRenderable(void) { return mLightCap; }
virtual bool isVisible(void) const { return true; }
virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer) = 0;
};
enum ShadowRenderableFlags
{
SRF_INCLUDE_LIGHT_CAP = 0x00000001,
SRF_INCLUDE_DARK_CAP = 0x00000002,
SRF_EXTRUDE_TO_INFINITY = 0x00000004
};
class _OgreExport ShadowCaster
{
public:
virtual ~ShadowCaster() { }
virtual bool getCastShadows(void) const = 0;
virtual EdgeData* getEdgeList(void) = 0;
virtual bool hasEdgeList(void) = 0;
virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0;
virtual const AxisAlignedBox& getLightCapBounds(void) const = 0;
virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0;
typedef vector<ShadowRenderable*>::type ShadowRenderableList;
typedef VectorIterator<ShadowRenderableList> ShadowRenderableListIterator;
virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator(
ShadowTechnique shadowTechnique, const Light* light,
HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0;
static void extrudeVertices(const HardwareVertexBufferSharedPtr& vertexBuffer,
size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist);
virtual Real getPointExtrusionDistance(const Light* l) const = 0;
protected:
Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const;
virtual void updateEdgeListLightFacing(EdgeData* edgeData,
const Vector4& lightPos);
virtual void generateShadowVolume(EdgeData* edgeData,
const HardwareIndexBufferSharedPtr& indexBuffer, size_t& indexBufferUsedSize,
const Light* light, ShadowRenderableList& shadowRenderables, unsigned long flags);
virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos,
Real extrudeDist) const;
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif // __ShadowCaster_H__
Ogre::ShadowRenderable
Class which represents the renderable aspects of a set of shadow volume faces.
Definition: OgreShadowCaster.h:52
Ogre::ShadowRenderable::isVisible
virtual bool isVisible(void) const
Should this ShadowRenderable be treated as visible?
Definition: OgreShadowCaster.h:92
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::ShadowRenderable::~ShadowRenderable
virtual ~ShadowRenderable()
Definition: OgreShadowCaster.h:60
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::ShadowRenderable::getMaterial
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
Definition: OgreShadowCaster.h:66
Ogre::ShadowCaster::ShadowRenderableListIterator
VectorIterator< ShadowRenderableList > ShadowRenderableListIterator
Definition: OgreShadowCaster.h:137
Ogre::HardwareIndexBufferSharedPtr
Shared pointer implementation used to share index buffers.
Definition: OgreHardwareIndexBuffer.h:79
Ogre::SRF_EXTRUDE_TO_INFINITY
For shadow volume techniques only, indicates volume is extruded to infinity.
Definition: OgreShadowCaster.h:112
OgreRenderable.h
Ogre::ShadowCaster::ShadowRenderableList
vector< ShadowRenderable * >::type ShadowRenderableList
Definition: OgreShadowCaster.h:136
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::ShadowRenderable::getRenderOperation
void getRenderOperation(RenderOperation &op)
Gets the render operation required to send this object to the frame buffer.
Definition: OgreShadowCaster.h:68
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::ShadowRenderable::setMaterial
void setMaterial(const MaterialPtr &mat)
Set the material to be used by the shadow, should be set by the caller before adding to a render queu...
Definition: OgreShadowCaster.h:64
Ogre::ShadowTechnique
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:190
Ogre::EdgeData
This class contains the information required to describe the edge connectivity of a given set of vert...
Definition: OgreEdgeListBuilder.h:52
Ogre::ShadowRenderableFlags
ShadowRenderableFlags
A set of flags that can be used to influence ShadowRenderable creation.
Definition: OgreShadowCaster.h:105
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:86
OgrePrerequisites.h
Ogre::ShadowRenderable::getLightCapRenderable
ShadowRenderable * getLightCapRenderable(void)
Get the light cap version of this renderable.
Definition: OgreShadowCaster.h:90
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::ShadowCaster::~ShadowCaster
virtual ~ShadowCaster()
Definition: OgreShadowCaster.h:120
Ogre::ShadowCaster
This class defines the interface that must be implemented by shadow casters.
Definition: OgreShadowCaster.h:117
Ogre::ShadowRenderable::getRenderOperationForUpdate
RenderOperation * getRenderOperationForUpdate(void)
Get the internal render operation for set up.
Definition: OgreShadowCaster.h:70
Ogre::SRF_INCLUDE_LIGHT_CAP
For shadow volume techniques only, generate a light cap on the volume.
Definition: OgreShadowCaster.h:108
Ogre::ShadowRenderable::isLightCapSeparate
bool isLightCapSeparate(void) const
Does this renderable require a separate light cap?
Definition: OgreShadowCaster.h:87
Ogre::ShadowRenderable::mLightCap
ShadowRenderable * mLightCap
Definition: OgreShadowCaster.h:57
Ogre::ShadowRenderable::mMaterial
MaterialPtr mMaterial
Definition: OgreShadowCaster.h:55
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::SRF_INCLUDE_DARK_CAP
For shadow volume techniques only, generate a dark cap on the volume.
Definition: OgreShadowCaster.h:110
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ShadowRenderable::getSquaredViewDepth
Real getSquaredViewDepth(const Camera *) const
Returns the camera-relative squared depth of this renderable.
Definition: OgreShadowCaster.h:74
Ogre::SharedPtr< Material >
Ogre::vector
Definition: OgrePrerequisites.h:491
OgreHeaderPrefix.h
Ogre::ShadowRenderable::mRenderOp
RenderOperation mRenderOp
Definition: OgreShadowCaster.h:56
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::ShadowRenderable::ShadowRenderable
ShadowRenderable()
Used only if isLightCapSeparate == true.
Definition: OgreShadowCaster.h:59
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58

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