My Project
Loading...
Searching...
No Matches
CShadowMap.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CShadowMapH
46#define CShadowMapH
47//------------------------------------------------------------------------------
49//------------------------------------------------------------------------------
50
51//------------------------------------------------------------------------------
52namespace chai3d {
53//------------------------------------------------------------------------------
54
55//==============================================================================
62//==============================================================================
63
64//==============================================================================
75//==============================================================================
77{
78 //--------------------------------------------------------------------------
79 // CONSTRUCTOR & DESTRUCTOR:
80 //--------------------------------------------------------------------------
81
82public:
83
85 cShadowMap();
86
88 virtual ~cShadowMap() {};
89
90
91 //-----------------------------------------------------------------------
92 // PUBLIC METHODS:
93 //--------------------------------------------------------------------------
94
95public:
96
98 virtual std::string getClassName() { return ("ShadowMap"); }
99
101 void setEnabled(bool a_enabled) { m_enabled = a_enabled; }
102
104 bool getEnabled() const { return(m_enabled); }
105
107 void setQualityVeryLow() { setSize(256, 256); }
108
110 void setQualityLow() { setSize(512, 512); }
111
113 void setQualityMedium() { setSize(1024, 1024); }
114
116 void setQualityHigh() { setSize(2048, 2048); }
117
119 void setQualityVeryHigh() { setSize(4096, 4096); }
120
121
122 //-----------------------------------------------------------------------
123 // PUBLIC MEMBERS:
124 //--------------------------------------------------------------------------
125
126public:
127
130
133
134
135 //-----------------------------------------------------------------------
136 // PUBLIC METHODS: (CHAI3D INTERNAL)
137 //--------------------------------------------------------------------------
138
139public:
140
142 virtual void render(cRenderOptions& a_options);
143
145 bool updateMap(cWorld* a_world,
146 const cVector3d& a_lightPos,
147 const cVector3d& a_lightLookat,
148 const cVector3d& a_lightUp,
149 const double a_lightFieldViewAngle,
150 const double a_distanceNear,
151 const double a_distanceFar,
152 const double a_mirrorH,
153 const double a_mirrorV);
154
155
156 //--------------------------------------------------------------------------
157 // PROTECTED MEMBERS:
158 //--------------------------------------------------------------------------
159
160protected:
161
164};
165
166//------------------------------------------------------------------------------
167} // namespace chai3d
168//------------------------------------------------------------------------------
169
170//------------------------------------------------------------------------------
171#endif
172//------------------------------------------------------------------------------
Implementation of a framebuffer.
This class implements an OpenGL framebuffer.
Definition CFrameBuffer.h:88
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:147
This class implements a shadow map for spot lights (cSpotLight).
Definition CShadowMap.h:77
void setQualityHigh()
This method sets the quality resolution of the shadow map to 2048 x 2048 pixels.
Definition CShadowMap.h:116
cTransform m_lightViewMatrix
View matrix of the light source creating this shadow.
Definition CShadowMap.h:132
void setQualityMedium()
This method sets the quality resolution of the shadow map to 1024 x 1024 pixels.
Definition CShadowMap.h:113
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
virtual ~cShadowMap()
Destructor of cShadowMap.
Definition CShadowMap.h:88
bool updateMap(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:226
bool getEnabled() const
This method returns true if the this shadow map is enabled, false otherwise.
Definition CShadowMap.h:104
void setQualityLow()
This method sets the quality resolution of the shadow map to 512 x 512 pixels.
Definition CShadowMap.h:110
cTransform m_lightProjectionMatrix
Projection matrix of the light source creating this shadow.
Definition CShadowMap.h:129
bool m_enabled
If true, then shadow map is enabled, false otherwise.
Definition CShadowMap.h:163
cShadowMap()
Constructor of cShadowMap.
Definition CShadowMap.cpp:65
void setEnabled(bool a_enabled)
This method enables or disables this shadow map.
Definition CShadowMap.h:101
virtual std::string getClassName()
This method returns the name of the object class.
Definition CShadowMap.h:98
void setQualityVeryHigh()
This method sets the quality resolution of the shadow map to 4096 x 4096 pixels.
Definition CShadowMap.h:119
void setQualityVeryLow()
This method sets the quality resolution of the shadow map to 256 x 256 pixels.
Definition CShadowMap.h:107
This class implements a virtual world.
Definition CWorld.h:93
Definition CAudioBuffer.cpp:57
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83
This class implements a 4D transformation matrix encoded as column-major.
Definition CTransform.h:76
This class implements a 3D vector.
Definition CVector3d.h:89