OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
38 
54  {
55  protected:
58  ShadowRenderable* mLightCap; // used only if isLightCapSeparate == true
59  public:
60  ShadowRenderable() : mMaterial(), mLightCap(0) {}
61  virtual ~ShadowRenderable() { delete mLightCap; }
65  void setMaterial(const MaterialPtr& mat) { mMaterial = mat; }
67  const MaterialPtr& getMaterial(void) const { return mMaterial; }
69  void getRenderOperation(RenderOperation& op) { op = mRenderOp; }
71  RenderOperation* getRenderOperationForUpdate(void) {return &mRenderOp;}
73  void getWorldTransforms(Matrix4* xform) const = 0;
75  Real getSquaredViewDepth(const Camera*) const{ return 0; /* not used */}
77  const LightList& getLights(void) const;
88  bool isLightCapSeparate(void) const { return mLightCap != 0; }
89 
91  ShadowRenderable* getLightCapRenderable(void) { return mLightCap; }
93  virtual bool isVisible(void) const { return true; }
94 
100  virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer) = 0;
101 
102  };
103 
106  {
108  SRF_INCLUDE_LIGHT_CAP = 0x00000001,
110  SRF_INCLUDE_DARK_CAP = 0x00000002,
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 
154  virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator(
155  ShadowTechnique shadowTechnique, const Light* light,
156  HardwareIndexBufferSharedPtr* indexBuffer,
157  bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0;
158 
178  static void extrudeVertices(const HardwareVertexBufferSharedPtr& vertexBuffer,
179  size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist);
181  virtual Real getPointExtrusionDistance(const Light* l) const = 0;
182  protected:
184  Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const;
192  virtual void updateEdgeListLightFacing(EdgeData* edgeData,
193  const Vector4& lightPos);
194 
208  virtual void generateShadowVolume(EdgeData* edgeData,
209  const HardwareIndexBufferSharedPtr& indexBuffer, const Light* light,
210  ShadowRenderableList& shadowRenderables, unsigned long flags);
217  virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos,
218  Real extrudeDist) const;
219 
220 
221  };
224 }
225 
226 #include "OgreHeaderSuffix.h"
227 
228 #endif
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
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...
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:233
ShadowRenderable * mLightCap
ShadowRenderableFlags
A set of flags that can be used to influence ShadowRenderable creation.
Shared pointer implementation used to share index buffers.
A 3D box aligned with the x/y/z axes.
Abstract class defining the interface all renderable objects must implement.
Shared pointer implementation used to share index buffers.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
virtual bool isVisible(void) const
Should this ShadowRenderable be treated as visible?
RenderOperation * getRenderOperationForUpdate(void)
Get the internal render operation for set up.
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:193
VectorIterator< ShadowRenderableList > ShadowRenderableListIterator
Class which represents the renderable aspects of a set of shadow volume faces.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Real getSquaredViewDepth(const Camera *) const
Overridden from Renderable.
const MaterialPtr & getMaterial(void) const
Overridden from Renderable.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
bool isLightCapSeparate(void) const
Does this renderable require a separate light cap?
'New' rendering operation using vertex buffers.
This class contains the information required to describe the edge connectivity of a given set of vert...
For shadow volume techniques only, indicates volume is extruded to infinity.
RenderOperation mRenderOp
For shadow volume techniques only, generate a dark cap on the volume.
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
This class defines the interface that must be implemented by shadow casters.
Concrete IteratorWrapper for nonconst access to the underlying container.
void getRenderOperation(RenderOperation &op)
Overridden from Renderable.
For shadow volume techniques only, generate a light cap on the volume.
ShadowRenderable * getLightCapRenderable(void)
Get the light cap version of this renderable.
vector< ShadowRenderable * >::type ShadowRenderableList