My Project
Loading...
Searching...
No Matches
CSpotLight.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 CSpotLightH
46#define CSpotLightH
47//------------------------------------------------------------------------------
50//------------------------------------------------------------------------------
51
52//------------------------------------------------------------------------------
53namespace chai3d {
54//------------------------------------------------------------------------------
55
56//==============================================================================
63//==============================================================================
64
65//==============================================================================
76//==============================================================================
78{
79 //--------------------------------------------------------------------------
80 // CONSTRUCTOR & DESTRUCTOR:
81 //--------------------------------------------------------------------------
82
83public:
84
86 cSpotLight(cWorld* a_world);
87
89 virtual ~cSpotLight();
90
91
92 //--------------------------------------------------------------------------
93 // GENERAL:
94 //--------------------------------------------------------------------------
95
96public:
97
99 virtual std::string getClassName() { return ("SpotLight"); }
100
101
102 //--------------------------------------------------------------------------
103 // PUBLIC METHODS - SHADOW CASTING:
104 //--------------------------------------------------------------------------
105
106public:
107
109 bool updateShadowMap(const double a_mirrorH = 1.0,
110 const double a_mirrorV = 1.0);
111
113 void setShadowMapProperties(const double& a_nearClippingPlane,
114 const double& a_farClippingPlane);
115
117 void setShadowMapEnabled(const bool a_enabled);
118
120 bool getShadowMapEnabled() const;
121
122
123 //--------------------------------------------------------------------------
124 // PUBLIC MEMBERS - SHADOW CASTING:
125 //--------------------------------------------------------------------------
126
127public:
128
131
132
133 //--------------------------------------------------------------------------
134 // PUBLIC METHODS - LIGHTING PROPERTIES:
135 //--------------------------------------------------------------------------
136
137public:
138
140 void setSpotExponent(const GLfloat& a_value) { m_spotExponent = cClamp(a_value, 0.0f, 100.0f); }
141
143 GLfloat getSpotExponent() const { return (m_spotExponent); }
144
146 void setCutOffAngleDeg(const GLfloat& a_angleDeg);
147
149 GLfloat getCutOffAngleDeg() const { return (m_cutOffAngleDeg); }
150
151
152 //--------------------------------------------------------------------------
153 // PUBLIC METHODS - DISPLAY MODEL:
154 //--------------------------------------------------------------------------
155
156public:
157
159 void setDisplaySettings(const double& a_sourceRadius = 0.02,
160 const double& a_coneLength = 1.0,
161 const bool a_displayEnabled = true);
162
163
164 //--------------------------------------------------------------------------
165 // PUBLIC MEMBERS - DISPLAY MODEL:
166 //--------------------------------------------------------------------------
167
168public:
169
172
173
174 //--------------------------------------------------------------------------
175 // PROTECTED MEMBERS - LIGHTING PROPERTIES
176 //--------------------------------------------------------------------------
177
178protected:
179
182
185
186
187 //--------------------------------------------------------------------------
188 // PROTECTED MEMBERS - SHADOW CASTING
189 //--------------------------------------------------------------------------
190
191protected:
192
195
198
199
200 //--------------------------------------------------------------------------
201 // PROTECTED MEMBERS - DISPLAY MODEL:
202 //--------------------------------------------------------------------------
203
204protected:
205
208
209
210 //--------------------------------------------------------------------------
211 // PROTECTED VIRTUAL METHODS:
212 //--------------------------------------------------------------------------
213
214protected:
215
217 virtual void renderLightSource(cRenderOptions& a_options);
218
220 virtual void render(cRenderOptions& a_options);
221};
222
223//------------------------------------------------------------------------------
224} // namespace chai3d
225//------------------------------------------------------------------------------
226
227//------------------------------------------------------------------------------
228#endif
229//------------------------------------------------------------------------------
230
Implements a directional light source.
Implements a positional light source.
This class implements a directional light source.
Definition CDirectionalLight.h:82
This class implements a positional light source.
Definition CPositionalLight.h:77
This class implements a shadow map for spot lights (cSpotLight).
Definition CShadowMap.h:77
This class implements a spot light source.
Definition CSpotLight.h:78
void setShadowMapEnabled(const bool a_enabled)
This method enables of disables the shadow map.
Definition CSpotLight.cpp:345
GLfloat getSpotExponent() const
This method returns the concentration level of the light.
Definition CSpotLight.h:143
cColorf m_displayConeColor
Color used for rendering the light cone of the display model.
Definition CSpotLight.h:171
GLfloat m_cutOffAngleDeg
Cut off angle (for spot lights only). Only values in the range 0 to 90 degrees.
Definition CSpotLight.h:184
void setSpotExponent(const GLfloat &a_value)
This method sets the concentration level of the light (0.0 - 100.0).
Definition CSpotLight.h:140
virtual void renderLightSource(cRenderOptions &a_options)
This method renders the lighting properties of this light source in OpenGL.
Definition CSpotLight.cpp:123
virtual void render(cRenderOptions &a_options)
This method renders a graphical representation (display model) of the light source....
Definition CSpotLight.cpp:217
double m_displayConeLength
Length of light cone for display model.
Definition CSpotLight.h:207
double m_shadowFarClippingPlane
Shadow map far clipping plane.
Definition CSpotLight.h:197
GLfloat getCutOffAngleDeg() const
This method returns the cut off angle.
Definition CSpotLight.h:149
virtual std::string getClassName()
This method returns the name of the object class.
Definition CSpotLight.h:99
bool updateShadowMap(const double a_mirrorH=1.0, const double a_mirrorV=1.0)
This method updates the shadow map.
Definition CSpotLight.cpp:295
double m_shadowNearClippingPlane
Shadow map near clipping plane.
Definition CSpotLight.h:194
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
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
bool getShadowMapEnabled() const
This method returns true if the shadow map is enabled, false otherwise.
Definition CSpotLight.cpp:361
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:130
GLfloat m_spotExponent
Concentration of the light.
Definition CSpotLight.h:181
virtual ~cSpotLight()
Destructor of cSpotLight.
Definition CSpotLight.cpp:94
This class implements a virtual world.
Definition CWorld.h:93
Definition CAudioBuffer.cpp:57
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:387
This class defines a color using a GLfloat representation for each component.
Definition CColor.h:139
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83