CHAI3D  3.0.0
CShadowMap.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.0.0 $Rev: 1649 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CShadowMapH
46 #define CShadowMapH
47 //------------------------------------------------------------------------------
48 #include "display/CFrameBuffer.h"
49 //------------------------------------------------------------------------------
50 
51 //------------------------------------------------------------------------------
52 namespace chai3d {
53 //------------------------------------------------------------------------------
54 
55 //==============================================================================
62 //==============================================================================
63 
64 //==============================================================================
75 //==============================================================================
76 class cShadowMap : public cFrameBuffer
77 {
78  //--------------------------------------------------------------------------
79  // CONSTRUCTOR & DESTRUCTOR:
80  //--------------------------------------------------------------------------
81 
82 public:
83 
85  cShadowMap();
86 
88  virtual ~cShadowMap() {};
89 
90 
91  //-----------------------------------------------------------------------
92  // PUBLIC METHODS:
93  //--------------------------------------------------------------------------
94 
95 public:
96 
98  void setEnabled(bool a_enabled) { m_enabled = a_enabled; }
99 
101  bool getEnabled() const { return(m_enabled); }
102 
104  void setQualityVeryLow() { setSize(256, 256); }
105 
107  void setQualityLow() { setSize(512, 512); }
108 
110  void setQualityMedium() { setSize(1024, 1024); }
111 
113  void setQualityHigh() { setSize(2048, 2048); }
114 
116  void setQualityVeryHigh() { setSize(4096, 4096); }
117 
118 
119  //-----------------------------------------------------------------------
120  // PUBLIC MEMBERS:
121  //--------------------------------------------------------------------------
122 
123 public:
124 
127 
130 
131 
132  //-----------------------------------------------------------------------
133  // PUBLIC METHODS: (CHAI3D INTERNAL)
134  //--------------------------------------------------------------------------
135 
136 public:
137 
139  virtual void render(cRenderOptions& a_options);
140 
142  bool updateMap(const int a_displayContext,
143  cWorld* a_world,
144  const cVector3d& a_lightPos,
145  const cVector3d& a_lightLookat,
146  const cVector3d& a_lightUp,
147  const double a_lightFieldViewAngle,
148  const double a_distanceNear,
149  const double a_distanceFar,
150  const double a_mirrorH,
151  const double a_mirrorV);
152 
153 
154  //--------------------------------------------------------------------------
155  // PROTECTED MEMBERS:
156  //--------------------------------------------------------------------------
157 
158 protected:
159 
161  bool m_enabled;
162 };
163 
164 //------------------------------------------------------------------------------
165 } // namespace chai3d
166 //------------------------------------------------------------------------------
167 
168 //------------------------------------------------------------------------------
169 #endif
170 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:85
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
cTransform m_lightViewMatrix
View matrix of the light source creating this shadow.
Definition: CShadowMap.h:129
void setQualityMedium()
This method sets the quality resolution of the shadow map to 1024 x 1024 pixels.
Definition: CShadowMap.h:110
void setQualityVeryHigh()
This method sets the quality resolution of the shadow map to 4096 x 4096 pixels.
Definition: CShadowMap.h:116
virtual void render(cRenderOptions &a_options)
This method contains the OpenGL rendering code for shadow maps. (Do not call this code directly...
Definition: CShadowMap.cpp:88
This class implements a virtual world.
Definition: CWorld.h:92
void setQualityHigh()
This method sets the quality resolution of the shadow map to 2048 x 2048 pixels.
Definition: CShadowMap.h:113
Implementation of a framebuffer.
bool m_enabled
If true, then shadow map is enabled, false otherwise.
Definition: CShadowMap.h:161
This class implements an OpenGL framebuffer.
Definition: CFrameBuffer.h:87
This class implements a 4D transformation matrix encoded as column-major.
Definition: CTransform.h:75
cShadowMap()
Constructor of cShadowMap.
Definition: CShadowMap.cpp:65
bool updateMap(const int a_displayContext, cWorld *a_world, const cVector3d &a_lightPos, const cVector3d &a_lightLookat, const cVector3d &a_lightUp, const double a_lightFieldViewAngle, const double a_distanceNear, const double a_distanceFar, const double a_mirrorH, const double a_mirrorV)
This method updates the shadow map. (Do not call this code directly.)
Definition: CShadowMap.cpp:227
void setQualityVeryLow()
This method sets the quality resolution of the shadow map to 256 x 256 pixels.
Definition: CShadowMap.h:104
This class implements a shadow map for spot lights (cSpotLight).
Definition: CShadowMap.h:76
virtual ~cShadowMap()
Destructor of cShadowMap.
Definition: CShadowMap.h:88
cTransform m_lightProjectionMatrix
Projection matrix of the light source creating this shadow.
Definition: CShadowMap.h:126
Definition: CAudioBuffer.cpp:56
void setQualityLow()
This method sets the quality resolution of the shadow map to 512 x 512 pixels.
Definition: CShadowMap.h:107
void setEnabled(bool a_enabled)
This method enables or disables this shadow map.
Definition: CShadowMap.h:98
void setSize(const unsigned int a_width, const unsigned int a_height)
This method sets the resolution of the framebuffer by defining its width and height in pixels...
Definition: CFrameBuffer.cpp:153
bool getEnabled() const
This method returns true if the this shadow map is enabled, false otherwise.
Definition: CShadowMap.h:101

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.