GL Studio C++ Runtime API
gls_light_source.h
Go to the documentation of this file.
1/// \file gls_light_source.h
2/// \brief The disti::GlsLightSource class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<br>
9/// USA<br>
10/// <br>
11/// All rights reserved.<br>
12///
13/// This Software contains proprietary trade secrets of DiSTI and may not be
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef DISTI_INCLUDED_GLS_LIGHT_SOURCE_H
40#define DISTI_INCLUDED_GLS_LIGHT_SOURCE_H
41
42#include "display.h"
43#include "gls_color.h"
45#include "gls_include.h"
46
47namespace disti
48{
49/**
50 LightType_e
51*/
52typedef enum
53{
54 LIGHT_LOCAL,
55 LIGHT_INFINITE
57
58/**
59 Light Source Initializers
60*/
61typedef enum
62{
63 GLS_LIGHT_SOURCE_AMBIENT = GLS_LAST_INITIALIZER + 1,
64 GLS_LIGHT_SOURCE_DIFFUSE,
65 GLS_LIGHT_SOURCE_SPECULAR,
66 GLS_LIGHT_SOURCE_SPOT_CUTOFF,
67 GLS_LIGHT_SOURCE_SPOT_EXPONENT,
68 GLS_LIGHT_SOURCE_CONSTANT_ATTENUATION,
69 GLS_LIGHT_SOURCE_LINEAR_ATTENUATION,
70 GLS_LIGHT_SOURCE_QUADRATIC_ATTENUATION,
71 GLS_LIGHT_SOURCE_LIGHT_TYPE
73
74#ifdef GLES
75// Forward Declaration
76class GlsGloFileAttribute;
77#endif
78
79/**
80 The GlsLightSource class. Implements Lights as objects
81*/
83{
84private:
85 /** Disabling the default implicit assignment and copy constructors */
86 GlsLightSource& operator=( const GlsLightSource& ) DISTI_SPECIAL_MEM_FUN_DELETE; // = delete
88
89public:
90 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
91 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
92 typedef DisplayObject BaseClass; ///< Typedef for the base class.
93 friend class GlsLightSourceEditor;
94
95protected:
96 /// \note _visible determines if the light is on.
97
98 GlsColor _ambient; /**< Value for the ambient light component */
99 GlsColor _diffuse; /**< Value for the diffuse light component */
100 GlsColor _specular; /**< Value for the ambient light component */
101 LightType_e _lightType; /**< Value for the light type */
102 float _spotCutoff; /**< Value for the GL_SPOT_CUTOFF glLight() parameter */
103 float _spotExponent; /**< Value for the GL_SPOT_EXPONENT glLight() parameter */
104 float _constantAttenuation; /**< Value for GL_CONSTANT_ATTENUATION glLight() parameter */
105 float _linearAttenuation; /**< Value for GL_LINEAR_ATTENUATION glLight() parameter */
106 float _quadraticAttenuation; /**< Value for GL_QUADRATIC_ATTENUATION glLight() parameter */
107
108public:
110
111 /// Allocate a (blank) LightSource object.
112 /// \param newGlLight Unused, kept for backward compatibility.
113 GLS_EXPORT GlsLightSource( bool newGlLight = true );
114
115 /// Copy constructor
116 /// \param that The object to copy from.
117 /// \param generateNames Whether or not to generate an instance name.
118 GLS_EXPORT GlsLightSource( const GlsLightSource& that, const bool generateNames );
119
120 /** Destroy a LightSource object */
122
124
125 /// Set up the given OpenGL light number with this light's properties.
126 /// \param light_number The OpenGL light index to set up.
127 /// \param alternateModelMatrix Optional additional transform to apply to the light.
128 virtual GLS_EXPORT void SetupLight( unsigned int light_number, GlsMatrixType* alternateModelMatrix = NULL );
129
133
134 /** Set the ambient color for this light
135 * \param color The new ambient color
136 */
137 GLS_EXPORT void SetAmbient( const GlsColor& color );
138
139 /** Set the diffuse color for this light
140 * \param color The new diffuse color
141 */
142 GLS_EXPORT void SetDiffuse( const GlsColor& color );
143
144 /** Set the specular color for this light
145 * \param color The new specular color
146 */
147 GLS_EXPORT void SetSpecular( const GlsColor& color );
148
149 /** Get the ambient color for this light
150 * \return The ambient color
151 */
153
154 /** Get the diffuse color for this light
155 * \return The diffuse color
156 */
158
159 /** Get the specular color for this light
160 * \return The specular color
161 */
163
164 /** Get what type of light this is
165 * \return Tye type of light (\sa LightType_e)
166 */
168
169 /** Set what type of light this is
170 * \param type The type of light (\sa LightType_e)
171 */
172 GLS_EXPORT void LightType( int type );
173
174 /** Set the spot cutoff factor
175 * \param s New spot cutoff factor
176 */
177 GLS_EXPORT void SpotCutoff( float s );
178
179 /** Get the spot cutoff factor
180 * \return Spot cutoff factor
181 */
183
184 /** Set the spot exponent
185 * \param s New spot exponent
186 */
187 GLS_EXPORT void SpotExponent( float s );
188
189 /** Get the spot exponent
190 * \return Spot exponent
191 */
193
194 /** Set the constant attenuation coefficient
195 * \param c New coefficient
196 */
198
199 /** Get the constant attenuation coefficient
200 * \return The coefficient
201 */
203
204 /** Set the linear attenuation coefficient
205 * \param c New coefficient
206 */
208
209 /** Get the linear attenuation coefficient
210 * \return The coefficient
211 */
213
214 /** Set the quadratic attenuation coefficient
215 * \param c New coefficient
216 */
218
219 /** Get the quadratic attenuation coefficient
220 * \return The coefficient
221 */
223
224#ifdef GLES
225 /** Set a single attribute from the GLO file.
226 * \param data The attribute to set and its associated data.
227 */
228 GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
229#endif
230
231 GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
232 GLS_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
233
234#ifndef GLES
237#endif
238};
239
240#define DEF_LIGHT_TYPE LIGHT_INFINITE ///< Unused, kept for backward compatibility.
241
242/** The DistiAttributeLightTypeEnum class
243 */
244//template class GLS_EXPORT DistiAttributeEnum<LightType_e>;
245class DistiAttributeLightTypeEnum : public DistiAttributeEnum<GlsLightSource, int, int>
246{
247public:
248 /// Constructor
249 /// \param frame The object containing this attribute.
250 /// \param setMethod The set method function pointer.
251 /// \param getMethod The get method function pointer.
252 /// \param name The name of the attribute.
254
256
257 std::string Type() const DISTI_METHOD_OVERRIDE;
258};
259
260} // namespace disti
261
262#endif
Definition: disti_metadata.h:87
Definition: cull.h:49
Definition: display.h:95
Definition: disti_metadata.h:1021
void(containerClass::* SetMethodType)(int)
Typedef for the set method function pointer.
Definition: disti_metadata.h:1023
int(containerClass::* GetMethodType)()
Typedef for the get method function pointer.
Definition: disti_metadata.h:1024
Definition: gls_light_source.h:246
std::string Type() const override
DistiAttributeLightTypeEnum(GlsLightSource *frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName &name)
Definition: dynamic_array.h:79
Definition: gls_color.h:53
Definition: gls_glo_file.h:1241
Definition: gls_light_source.h:83
GlsColor _ambient
Definition: gls_light_source.h:98
void SetAvailableAttributes(unsigned int value) override
void PreDraw(const OpenGLMatrices &current, Culler &culler) override
bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) override
void CopyProperties(DisplayObject *src) override
float _spotExponent
Definition: gls_light_source.h:103
void SetValue(int spec, va_list &args) override
virtual void SetupLight(unsigned int light_number, GlsMatrixType *alternateModelMatrix=NULL)
float _spotCutoff
Definition: gls_light_source.h:102
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) override
float _quadraticAttenuation
Definition: gls_light_source.h:106
LightType_e _lightType
Definition: gls_light_source.h:101
DisplayObject * CloneObject(bool generateNames=false) override
GlsColor _specular
Definition: gls_light_source.h:100
float _linearAttenuation
Definition: gls_light_source.h:105
GlsColor _diffuse
Definition: gls_light_source.h:99
void SetAmbient(const GlsColor &color)
void GetCppInterfaceDescriptionFree(InterfaceListType *array) override
void SetDiffuse(const GlsColor &color)
float _constantAttenuation
Definition: gls_light_source.h:104
void SetSpecular(const GlsColor &color)
void Draw() override
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:84
The disti::DisplayObject class and global enumerations.
The Color class: Implements a 4 component RGBA color.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:245
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
A file for all GL Studio files to include.
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
Definition: bmpimage.h:46
GLS_LightSource_Initializers
Definition: gls_light_source.h:62
LightType_e
Definition: gls_light_source.h:53