My Project
Loading...
Searching...
No Matches
CPositionalLight.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 CPositionalLightH
46#define CPositionalLightH
47//------------------------------------------------------------------------------
49//--------------------------------------------------------------------------
50
51//------------------------------------------------------------------------------
52namespace chai3d {
53//------------------------------------------------------------------------------
54
55//==============================================================================
62//==============================================================================
63
64//==============================================================================
75//==============================================================================
76class cPositionalLight : public virtual cGenericLight
77{
78 //--------------------------------------------------------------------------
79 // CONSTRUCTOR & DESTRUCTOR:
80 //--------------------------------------------------------------------------
81
82public:
83
85 cPositionalLight(cWorld* a_world);
86
88 virtual ~cPositionalLight();
89
90
91 //-----------------------------------------------------------------------
92 // PUBLIC METHODS - LIGHTING PROPERTIES:
93 //-----------------------------------------------------------------------
94
95public:
96
98 virtual std::string getClassName() { return ("PositionalLight"); }
99
101 void setAttConstant(const GLfloat& a_value) { m_attConstant = cClamp(a_value, 0.0f, 1.0f); }
102
104 GLfloat getAttConstant() const { return (m_attConstant); }
105
107 void setAttLinear(const GLfloat& a_value) { m_attLinear = cClamp(a_value, 0.0f, 1.0f); }
108
110 GLfloat getAttLinear() const { return (m_attLinear); }
111
113 void setAttQuadratic(const GLfloat& a_value) { m_attQuadratic = cClamp(a_value, 0.0f, 1.0f); }
114
116 GLfloat getAttQuadratic() const { return (m_attQuadratic); }
117
118
119 //-----------------------------------------------------------------------
120 // METHODS - DISPLAY MODEL:
121 //-----------------------------------------------------------------------
122
123public:
124
126 void setDisplaySettings(const double& a_sourceRadius = 0.02,
127 const bool a_displayEnabled = true);
128
129
130 //-----------------------------------------------------------------------
131 // PUBLIC MEMBERS - DISPLAY MODEL
132 //-----------------------------------------------------------------------
133
134public:
135
138
139
140 //-----------------------------------------------------------------------
141 // PROTECTED MEMBERS - LIGHTING PROPERTIES:
142 //-----------------------------------------------------------------------
143
144protected:
145
148
150 GLfloat m_attLinear;
151
154
155
156 //-----------------------------------------------------------------------
157 // PROTECTED MEMBERS - DISPLAY MODEL:
158 //-----------------------------------------------------------------------
159
160protected:
161
164
165
166 //-----------------------------------------------------------------------
167 // VIRTUAL PROTECTED METHODS:
168 //-----------------------------------------------------------------------
169
170protected:
171
173 virtual void renderLightSource(cRenderOptions& a_options);
174
176 virtual void render(cRenderOptions& a_options);
177};
178
179
180//------------------------------------------------------------------------------
181} // namespace chai3d
182//------------------------------------------------------------------------------
183
184//------------------------------------------------------------------------------
185#endif
186//------------------------------------------------------------------------------
187
Implements a base class for light sources.
This class implements a base class for modeling light sources.
Definition CGenericLight.h:80
This class implements a positional light source.
Definition CPositionalLight.h:77
double m_displaySourceRadius
Radius of display model representing light source.
Definition CPositionalLight.h:163
virtual ~cPositionalLight()
Destructor of cPositionalLight.
Definition CPositionalLight.cpp:80
void setAttLinear(const GLfloat &a_value)
This method sets the linear attenuation parameter.
Definition CPositionalLight.h:107
GLfloat getAttLinear() const
This method returns the linear attenuation parameter.
Definition CPositionalLight.h:110
virtual std::string getClassName()
This method returns the name of the object class.
Definition CPositionalLight.h:98
GLfloat m_attLinear
Linear attenuation parameter.
Definition CPositionalLight.h:150
GLfloat getAttConstant() const
This method returns the constant attenuation parameter.
Definition CPositionalLight.h:104
virtual void render(cRenderOptions &a_options)
This method renders a graphical representation (display model) of the light source....
Definition CPositionalLight.cpp:111
void setAttConstant(const GLfloat &a_value)
This method sets the constant attenuation parameter.
Definition CPositionalLight.h:101
void setAttQuadratic(const GLfloat &a_value)
This method set the quadratic attenuation parameter.
Definition CPositionalLight.h:113
GLfloat m_attConstant
Constant attenuation parameter.
Definition CPositionalLight.h:147
cColorf m_displaySourceColor
Color used for rendering the display model of the light source.
Definition CPositionalLight.h:137
virtual void renderLightSource(cRenderOptions &a_options)
This method renders the lighting properties of this light source in OpenGL.
Definition CPositionalLight.cpp:145
void setDisplaySettings(const double &a_sourceRadius=0.02, const bool a_displayEnabled=true)
This method sets the display settings of this light source. (To be used for debugging purposes to dis...
Definition CPositionalLight.cpp:95
GLfloat getAttQuadratic() const
This method returns the quadratic attenuation parameter.
Definition CPositionalLight.h:116
GLfloat m_attQuadratic
Quadratic attenuation parameter.
Definition CPositionalLight.h:153
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