CSpotLight.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, 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.2.0 $Rev: 2159 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CSpotLightH
46 #define CSpotLightH
47 //------------------------------------------------------------------------------
50 //------------------------------------------------------------------------------
51 
52 //------------------------------------------------------------------------------
53 namespace chai3d {
54 //------------------------------------------------------------------------------
55 
56 //==============================================================================
63 //==============================================================================
64 
65 //==============================================================================
76 //==============================================================================
78 {
79  //--------------------------------------------------------------------------
80  // CONSTRUCTOR & DESTRUCTOR:
81  //--------------------------------------------------------------------------
82 
83 public:
84 
86  cSpotLight(cWorld* a_world);
87 
89  virtual ~cSpotLight();
90 
91 
92  //--------------------------------------------------------------------------
93  // PUBLIC METHODS - SHADOW CASTING:
94  //--------------------------------------------------------------------------
95 
96 public:
97 
99  bool updateShadowMap(const double a_mirrorH = 1.0,
100  const double a_mirrorV = 1.0);
101 
103  void setShadowMapProperties(const double& a_nearClippingPlane,
104  const double& a_farClippingPlane);
105 
107  void setShadowMapEnabled(const bool a_enabled);
108 
110  bool getShadowMapEnabled() const;
111 
112 
113  //--------------------------------------------------------------------------
114  // PUBLIC MEMBERS - SHADOW CASTING:
115  //--------------------------------------------------------------------------
116 
117 public:
118 
121 
122 
123  //--------------------------------------------------------------------------
124  // PUBLIC METHODS - LIGHTING PROPERTIES:
125  //--------------------------------------------------------------------------
126 
127 public:
128 
130  void setSpotExponent(const GLfloat& a_value) { m_spotExponent = cClamp(a_value, 0.0f, 100.0f); }
131 
133  GLfloat getSpotExponent() const { return (m_spotExponent); }
134 
136  void setCutOffAngleDeg(const GLfloat& a_angleDeg);
137 
139  GLfloat getCutOffAngleDeg() const { return (m_cutOffAngleDeg); }
140 
141 
142  //--------------------------------------------------------------------------
143  // PUBLIC METHODS - DISPLAY MODEL:
144  //--------------------------------------------------------------------------
145 
146 public:
147 
149  void setDisplaySettings(const double& a_sourceRadius = 0.02,
150  const double& a_coneLength = 1.0,
151  const bool a_displayEnabled = true);
152 
153 
154  //--------------------------------------------------------------------------
155  // PUBLIC MEMBERS - DISPLAY MODEL:
156  //--------------------------------------------------------------------------
157 
158 public:
159 
162 
163 
164  //--------------------------------------------------------------------------
165  // PROTECTED MEMBERS - LIGHTING PROPERTIES
166  //--------------------------------------------------------------------------
167 
168 protected:
169 
171  GLfloat m_spotExponent;
172 
175 
176 
177  //--------------------------------------------------------------------------
178  // PROTECTED MEMBERS - SHADOW CASTING
179  //--------------------------------------------------------------------------
180 
181 protected:
182 
185 
188 
189 
190  //--------------------------------------------------------------------------
191  // PROTECTED MEMBERS - DISPLAY MODEL:
192  //--------------------------------------------------------------------------
193 
194 protected:
195 
198 
199 
200  //--------------------------------------------------------------------------
201  // PROTECTED VIRTUAL METHODS:
202  //--------------------------------------------------------------------------
203 
204 protected:
205 
207  virtual void renderLightSource(cRenderOptions& a_options);
208 
210  virtual void render(cRenderOptions& a_options);
211 };
212 
213 //------------------------------------------------------------------------------
214 } // namespace chai3d
215 //------------------------------------------------------------------------------
216 
217 //------------------------------------------------------------------------------
218 #endif
219 //------------------------------------------------------------------------------
220 
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
GLfloat m_cutOffAngleDeg
Cut off angle (for spot lights only). Only values in the range 0 to 90 degrees.
Definition: CSpotLight.h:174
double m_shadowNearClippingPlane
Shadow map near clipping plane.
Definition: CSpotLight.h:184
Implements a directional light source.
void setShadowMapProperties(const double &a_nearClippingPlane, const double &a_farClippingPlane)
This method define the near and far clipping planes of the shadow map.
Definition: CSpotLight.cpp:330
cShadowMap * m_shadowMap
Shadow map.
Definition: CSpotLight.h:120
void setDisplaySettings(const double &a_sourceRadius=0.02, const double &a_coneLength=1.0, const bool a_displayEnabled=true)
This method sets the display settings of light source. To be used for debugging purposes to display l...
Definition: CSpotLight.cpp:198
cColorf m_displayConeColor
Color used for rendering the light cone of the display model.
Definition: CSpotLight.h:161
GLfloat getCutOffAngleDeg() const
This method returns the cut off angle.
Definition: CSpotLight.h:139
Implements a positional light source.
void setCutOffAngleDeg(const GLfloat &a_angleDeg)
This method sets the cutoff angle in degrees (only affects spotlights) (positional lights with angula...
Definition: CSpotLight.cpp:109
This class implements a virtual world.
Definition: CWorld.h:92
This class implements a spot light source.
Definition: CSpotLight.h:77
bool getShadowMapEnabled() const
This method returns true if the shadow map is enabled, false otherwise.
Definition: CSpotLight.cpp:361
This class implements a positional light source.
Definition: CPositionalLight.h:76
virtual void render(cRenderOptions &a_options)
This method renders a graphical representation (display model) of the light source. (used for debuging purposes typically).
Definition: CSpotLight.cpp:217
bool updateShadowMap(const double a_mirrorH=1.0, const double a_mirrorV=1.0)
This method updates the shadow map.
Definition: CSpotLight.cpp:295
void setSpotExponent(const GLfloat &a_value)
This method sets the concentration level of the light (0.0 - 100.0).
Definition: CSpotLight.h:130
GLfloat getSpotExponent() const
This method returns the concentration level of the light.
Definition: CSpotLight.h:133
This class implements a shadow map for spot lights (cSpotLight).
Definition: CShadowMap.h:76
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
virtual void renderLightSource(cRenderOptions &a_options)
This method renders the lighting properties of this light source in OpenGL.
Definition: CSpotLight.cpp:123
virtual ~cSpotLight()
Destructor of cSpotLight.
Definition: CSpotLight.cpp:94
T cClamp(const T &a_value, const T &a_low, const T &a_high)
This function clamps a value to a specified range.
Definition: CMaths.h:362
Definition: CAudioBuffer.cpp:56
cSpotLight(cWorld *a_world)
Constructor of cSpotLight.
Definition: CSpotLight.cpp:67
This class implements a directional light source.
Definition: CDirectionalLight.h:81
void setShadowMapEnabled(const bool a_enabled)
This method enables of disables the shadow map.
Definition: CSpotLight.cpp:345
double m_shadowFarClippingPlane
Shadow map far clipping plane.
Definition: CSpotLight.h:187
double m_displayConeLength
Length of light cone for display model.
Definition: CSpotLight.h:197
GLfloat m_spotExponent
Concentration of the light.
Definition: CSpotLight.h:171