OgreShadowCaster.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __ShadowCaster_H__
29 #define __ShadowCaster_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreRenderable.h"
33 #include "OgreHeaderPrefix.h"
34 
35 
36 namespace Ogre {
37 
53  {
54  protected:
58  public:
59  ShadowRenderable() : mMaterial(), mLightCap(0) {}
60  virtual ~ShadowRenderable() { delete mLightCap; }
64  void setMaterial(const MaterialPtr& mat) { mMaterial = mat; }
66  const MaterialPtr& getMaterial(void) const { return mMaterial; }
68  void getRenderOperation(RenderOperation& op) { op = mRenderOp; }
70  RenderOperation* getRenderOperationForUpdate(void) {return &mRenderOp;}
72  void getWorldTransforms(Matrix4* xform) const = 0;
74  Real getSquaredViewDepth(const Camera*) const{ return 0; /* not used */}
76  const LightList& getLights(void) const;
87  bool isLightCapSeparate(void) const { return mLightCap != 0; }
88 
90  ShadowRenderable* getLightCapRenderable(void) { return mLightCap; }
92  virtual bool isVisible(void) const { return true; }
93 
100  virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer) = 0;
101 
102  };
103 
106  {
108  SRF_INCLUDE_LIGHT_CAP = 0x00000001,
110  SRF_INCLUDE_DARK_CAP = 0x00000002,
112  SRF_EXTRUDE_TO_INFINITY = 0x00000004
113  };
114 
118  {
119  public:
120  virtual ~ShadowCaster() { }
122  virtual bool getCastShadows(void) const = 0;
123 
125  virtual EdgeData* getEdgeList(void) = 0;
127  virtual bool hasEdgeList(void) = 0;
128 
130  virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0;
132  virtual const AxisAlignedBox& getLightCapBounds(void) const = 0;
134  virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0;
135 
138 
161  ShadowTechnique shadowTechnique, const Light* light,
162  HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
163  bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0;
164 
188  static void extrudeVertices(const HardwareVertexBufferSharedPtr& vertexBuffer,
189  size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist);
191  virtual Real getPointExtrusionDistance(const Light* l) const = 0;
192  protected:
194  Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const;
203  virtual void updateEdgeListLightFacing(EdgeData* edgeData,
204  const Vector4& lightPos);
205 
228  virtual void generateShadowVolume(EdgeData* edgeData,
229  const HardwareIndexBufferSharedPtr& indexBuffer, size_t& indexBufferUsedSize,
230  const Light* light, ShadowRenderableList& shadowRenderables, unsigned long flags);
240  virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos,
241  Real extrudeDist) const;
242 
243 
244  };
247 } // namespace Ogre
248 #include "OgreHeaderSuffix.h"
249 
250 #endif // __ShadowCaster_H__
OgreHeaderSuffix.h
Ogre::HashedVector< Light * >
Ogre::ShadowRenderable::ShadowRenderable
ShadowRenderable()
Used only if isLightCapSeparate == true.
Definition: OgreShadowCaster.h:59
Ogre::ShadowCaster::getCastShadows
virtual bool getCastShadows(void) const =0
Returns whether or not this object currently casts a shadow.
Ogre::ShadowCaster::updateEdgeListLightFacing
virtual void updateEdgeListLightFacing(EdgeData *edgeData, const Vector4 &lightPos)
Tells the caster to perform the tasks necessary to update the edge data's light listing.
Ogre::SRF_INCLUDE_DARK_CAP
@ SRF_INCLUDE_DARK_CAP
For shadow volume techniques only, generate a dark cap on the volume.
Definition: OgreShadowCaster.h:110
Ogre::SRF_EXTRUDE_TO_INFINITY
@ SRF_EXTRUDE_TO_INFINITY
For shadow volume techniques only, indicates volume is extruded to infinity.
Definition: OgreShadowCaster.h:112
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:59
Ogre
Definition: OgreAndroidLogListener.h:35
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::ShadowRenderable::getSquaredViewDepth
Real getSquaredViewDepth(const Camera *) const
Returns the camera-relative squared depth of this renderable.
Definition: OgreShadowCaster.h:74
Ogre::ShadowRenderable::getRenderOperationForUpdate
RenderOperation * getRenderOperationForUpdate(void)
Get the internal render operation for set up.
Definition: OgreShadowCaster.h:70
Ogre::ShadowCaster::ShadowRenderableList
vector< ShadowRenderable * >::type ShadowRenderableList
Definition: OgreShadowCaster.h:136
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Ogre::ShadowCaster::hasEdgeList
virtual bool hasEdgeList(void)=0
Returns whether the object has a valid edge list.
Ogre::ShadowRenderable::getLights
const LightList & getLights(void) const
Ogre::SRF_INCLUDE_LIGHT_CAP
@ SRF_INCLUDE_LIGHT_CAP
For shadow volume techniques only, generate a light cap on the volume.
Definition: OgreShadowCaster.h:108
Ogre::ShadowCaster::getShadowVolumeRenderableIterator
virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator(ShadowTechnique shadowTechnique, const Light *light, HardwareIndexBufferSharedPtr *indexBuffer, size_t *indexBufferUsedSize, bool extrudeVertices, Real extrusionDistance, unsigned long flags=0)=0
Gets an iterator over the renderables required to render the shadow volume.
Ogre::ShadowRenderable
Class which represents the renderable aspects of a set of shadow volume faces.
Definition: OgreShadowCaster.h:53
Ogre::ShadowCaster
This class defines the interface that must be implemented by shadow casters.
Definition: OgreShadowCaster.h:118
Ogre::ShadowTechnique
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:191
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:74
Ogre::ShadowCaster::generateShadowVolume
virtual void generateShadowVolume(EdgeData *edgeData, const HardwareIndexBufferSharedPtr &indexBuffer, size_t &indexBufferUsedSize, 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,...
Ogre::ShadowRenderable::isLightCapSeparate
bool isLightCapSeparate(void) const
Does this renderable require a separate light cap?
Definition: OgreShadowCaster.h:87
Ogre::HardwareIndexBufferSharedPtr
Shared pointer implementation used to share index buffers.
Definition: OgreHardwareIndexBuffer.h:80
Ogre::ShadowCaster::ShadowRenderableListIterator
VectorIterator< ShadowRenderableList > ShadowRenderableListIterator
Definition: OgreShadowCaster.h:137
Ogre::ShadowRenderable::isVisible
virtual bool isVisible(void) const
Should this ShadowRenderable be treated as visible?
Definition: OgreShadowCaster.h:92
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::ShadowRenderableFlags
ShadowRenderableFlags
A set of flags that can be used to influence ShadowRenderable creation.
Definition: OgreShadowCaster.h:106
Ogre::ShadowRenderable::~ShadowRenderable
virtual ~ShadowRenderable()
Definition: OgreShadowCaster.h:60
Ogre::ShadowCaster::extrudeVertices
static void extrudeVertices(const HardwareVertexBufferSharedPtr &vertexBuffer, size_t originalVertexCount, const Vector4 &lightPos, Real extrudeDist)
Utility method for extruding vertices based on a light.
OgreHeaderPrefix.h
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Ogre::ShadowCaster::getEdgeList
virtual EdgeData * getEdgeList(void)=0
Returns details of the edges which might be used to determine a silhouette.
OgrePrerequisites.h
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:87
Ogre::ShadowCaster::getPointExtrusionDistance
virtual Real getPointExtrusionDistance(const Light *l) const =0
Get the distance to extrude for a point/spot light.
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:55
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::ShadowCaster::getExtrusionDistance
Real getExtrusionDistance(const Vector3 &objectPos, const Light *light) const
Helper method for calculating extrusion distance.
Ogre::ShadowRenderable::getMaterial
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
Definition: OgreShadowCaster.h:66
Ogre::ShadowRenderable::mRenderOp
RenderOperation mRenderOp
Definition: OgreShadowCaster.h:56
Ogre::ShadowCaster::~ShadowCaster
virtual ~ShadowCaster()
Definition: OgreShadowCaster.h:120
Ogre::SharedPtr< Material >
OgreRenderable.h
Ogre::ShadowRenderable::getLightCapRenderable
ShadowRenderable * getLightCapRenderable(void)
Get the light cap version of this renderable.
Definition: OgreShadowCaster.h:90
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:46
Ogre::ShadowRenderable::rebindIndexBuffer
virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr &indexBuffer)=0
This function informs the shadow renderable that the global index buffer from the SceneManager has be...
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:64
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::ShadowRenderable::getWorldTransforms
void getWorldTransforms(Matrix4 *xform) const =0
Gets the world transform matrix / matrices for this renderable object.
Ogre::EdgeData
This class contains the information required to describe the edge connectivity of a given set of vert...
Definition: OgreEdgeListBuilder.h:53
Ogre::ShadowCaster::getDarkCapBounds
virtual const AxisAlignedBox & getDarkCapBounds(const Light &light, Real dirLightExtrusionDist) const =0
Gets the world space bounding box of the dark cap, as extruded using the light provided.
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::ShadowCaster::getLightCapBounds
virtual const AxisAlignedBox & getLightCapBounds(void) const =0
Gets the world space bounding box of the light cap.
Ogre::ShadowRenderable::mLightCap
ShadowRenderable * mLightCap
Definition: OgreShadowCaster.h:57
Ogre::ShadowCaster::getWorldBoundingBox
virtual const AxisAlignedBox & getWorldBoundingBox(bool derive=false) const =0
Get the world bounding box of the caster.
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
Ogre::RenderOperation
'New' rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::ShadowCaster::extrudeBounds
virtual void extrudeBounds(AxisAlignedBox &box, const Vector4 &lightPos, Real extrudeDist) const
Utility method for extruding a bounding box.
Ogre::ShadowRenderable::mMaterial
MaterialPtr mMaterial
Definition: OgreShadowCaster.h:55

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