| GL Studio C++ Runtime API

gls_light_source.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsLightSource class.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<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*/
40#ifndef _GLS_LIGHT_SOURCE_H
41#define _GLS_LIGHT_SOURCE_H
42
43#include "display.h"
44#include "gls_color.h"
45#include "gls_cpp_lang_support.h"
46#include "gls_include.h"
47
48 namespace disti
49{
50/**
51 LightType_e
52*/
53 typedef enum
54{
55 LIGHT_LOCAL,
56 LIGHT_INFINITE
57} LightType_e;
58
59/**
60 Light Source Initializers
61*/
62 typedef enum
63{
64 GLS_LIGHT_SOURCE_AMBIENT = GLS_LAST_INITIALIZER + 1,
65 GLS_LIGHT_SOURCE_DIFFUSE,
66 GLS_LIGHT_SOURCE_SPECULAR,
67 GLS_LIGHT_SOURCE_SPOT_CUTOFF,
68 GLS_LIGHT_SOURCE_SPOT_EXPONENT,
69 GLS_LIGHT_SOURCE_CONSTANT_ATTENUATION,
70 GLS_LIGHT_SOURCE_LINEAR_ATTENUATION,
71 GLS_LIGHT_SOURCE_QUADRATIC_ATTENUATION,
72 GLS_LIGHT_SOURCE_LIGHT_TYPE
73} GLS_LightSource_Initializers;
74
75#ifdef GLES
76// Forward Declaration
77 class GlsGloFileAttribute;
78#endif
79
80/**
81 The GlsLightSource class. Implements Lights as objects
82*/
83 class GlsLightSource : public DisplayObject
84{
85 private:
86 /** Disabling the default implicit assignment and copy constructors */
87 GlsLightSource& operator=( const GlsLightSource& ) DISTI_SPECIAL_MEM_FUN_DELETE; // = delete
88 GlsLightSource( const GlsLightSource& ) DISTI_SPECIAL_MEM_FUN_DELETE;
89
90 public:
91 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
92 typedef DisplayObject _BaseClass; ///< Deprecated typedef for the base class.
93 typedef DisplayObject BaseClass; ///< Typedef for the base class.
94 friend class GlsLightSourceEditor;
95
96protected:
97 /// \note _visible determines if the light is on.
98
99 GlsColor _ambient; /**< Value for the ambient light component */
100 GlsColor _diffuse; /**< Value for the diffuse light component */
101 GlsColor _specular; /**< Value for the ambient light component */
102 LightType_e _lightType; /**< Value for the light type */
103 float _spotCutoff; /**< Value for the GL_SPOT_CUTOFF glLight() parameter */
104 float _spotExponent; /**< Value for the GL_SPOT_EXPONENT glLight() parameter */
105 float _constantAttenuation; /**< Value for GL_CONSTANT_ATTENUATION glLight() parameter */
106 float _linearAttenuation; /**< Value for GL_LINEAR_ATTENUATION glLight() parameter */
107 float _quadraticAttenuation; /**< Value for GL_QUADRATIC_ATTENUATION glLight() parameter */
108
109public:
110 virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
111
112 /// Allocate a (blank) LightSource object.
113 /// \param newGlLight Unused, kept for backward compatibility.
114 GLS_EXPORT GlsLightSource( bool newGlLight = true );
115
116 /// Copy constructor
117 /// \param that The object to copy from.
118 /// \param generateNames Whether or not to generate an instance name.
119 GLS_EXPORT GlsLightSource( const GlsLightSource& that, const bool generateNames );
120
121 /** Destroy a LightSource object */
122 virtual GLS_EXPORT ~GlsLightSource();
123
124 virtual GLS_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
125
126 /// Set up the given OpenGL light number with this light's properties.
127 /// \param light_number The OpenGL light index to set up.
128 /// \param alternateModelMatrix Optional additional transform to apply to the light.
129 virtual GLS_EXPORT void SetupLight( unsigned int light_number, GlsMatrixType* alternateModelMatrix = NULL );
130
131 virtual GLS_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
132 virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
133 virtual GLS_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
134
135 /** Set the ambient color for this light
136 * \param color The new ambient color
137 */
138 GLS_EXPORT void SetAmbient( const GlsColor& color );
139
140 /** Set the diffuse color for this light
141 * \param color The new diffuse color
142 */
143 GLS_EXPORT void SetDiffuse( const GlsColor& color );
144
145 /** Set the specular color for this light
146 * \param color The new specular color
147 */
148 GLS_EXPORT void SetSpecular( const GlsColor& color );
149
150 /** Get the ambient color for this light
151 * \return The ambient color
152 */
153 GLS_EXPORT GlsColor GetAmbient();
154
155 /** Get the diffuse color for this light
156 * \return The diffuse color
157 */
158 GLS_EXPORT GlsColor GetDiffuse();
159
160 /** Get the specular color for this light
161 * \return The specular color
162 */
163 GLS_EXPORT GlsColor GetSpecular();
164
165 /** Get what type of light this is
166 * \return Tye type of light (\sa LightType_e)
167 */
168 GLS_EXPORT int LightType();
169
170 /** Set what type of light this is
171 * \param type The type of light (\sa LightType_e)
172 */
173 GLS_EXPORT void LightType( int type );
174
175 /** Set the spot cutoff factor
176 * \param s New spot cutoff factor
177 */
178 GLS_EXPORT void SpotCutoff( float s );
179
180 /** Get the spot cutoff factor
181 * \return Spot cutoff factor
182 */
183 GLS_EXPORT float SpotCutoff();
184
185 /** Set the spot exponent
186 * \param s New spot exponent
187 */
188 GLS_EXPORT void SpotExponent( float s );
189
190 /** Get the spot exponent
191 * \return Spot exponent
192 */
193 GLS_EXPORT float SpotExponent();
194
195 /** Set the constant attenuation coefficient
196 * \param c New coefficient
197 */
198 GLS_EXPORT void ConstantAttenuation( float c );
199
200 /** Get the constant attenuation coefficient
201 * \return The coefficient
202 */
203 GLS_EXPORT float ConstantAttenuation();
204
205 /** Set the linear attenuation coefficient
206 * \param c New coefficient
207 */
208 GLS_EXPORT void LinearAttenuation( float c );
209
210 /** Get the linear attenuation coefficient
211 * \return The coefficient
212 */
213 GLS_EXPORT float LinearAttenuation();
214
215 /** Set the quadratic attenuation coefficient
216 * \param c New coefficient
217 */
218 GLS_EXPORT void QuadraticAttenuation( float c );
219
220 /** Get the quadratic attenuation coefficient
221 * \return The coefficient
222 */
223 GLS_EXPORT float QuadraticAttenuation();
224
225#ifdef GLES
226 /** Set a single attribute from the GLO file.
227 * \param data The attribute to set and its associated data.
228 */
229 virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
230#endif
231
232 virtual GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint ) DISTI_METHOD_OVERRIDE;
233 virtual GLS_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
234
235#ifndef GLES
236 virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
237 virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
238#endif
239};
240
241#define DEF_LIGHT_TYPE LIGHT_INFINITE ///< Unused, kept for backward compatibility.
242
243/** The DistiAttributeLightTypeEnum class
244 */
245//template class GLS_EXPORT DistiAttributeEnum<LightType_e>;
246 class DistiAttributeLightTypeEnum : public DistiAttributeEnum<GlsLightSource, int, int>
247{
248 public:
249 /// Constructor
250 /// \param frame The object containing this attribute.
251 /// \param setMethod The set method function pointer.
252 /// \param getMethod The get method function pointer.
253 /// \param name The name of the attribute.
254 GLS_EXPORT DistiAttributeLightTypeEnum( GlsLightSource* frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName& name );
255
256 virtual GLS_EXPORT ~DistiAttributeLightTypeEnum();
257
258 std::string Type() const DISTI_METHOD_OVERRIDE;
259};
260
261} // namespace disti
262
263#endif
disti::AttributeName
Definition: disti_metadata.h:87
disti::Culler
Definition: cull.h:50
disti::DisplayObject
Definition: display.h:96
disti::DistiAttributeEnum
Definition: disti_metadata.h:1021
disti::DistiAttributeEnum< GlsLightSource, int, int >::SetMethodType
void(containerClass::* SetMethodType)(int)
Typedef for the set method function pointer.
Definition: disti_metadata.h:1023
disti::DistiAttributeEnum< GlsLightSource, int, int >::GetMethodType
int(containerClass::* GetMethodType)()
Typedef for the get method function pointer.
Definition: disti_metadata.h:1024
disti::DistiAttributeLightTypeEnum
Definition: gls_light_source.h:247
disti::DistiAttributeLightTypeEnum::Type
std::string Type() const override
disti::DistiAttributeLightTypeEnum::DistiAttributeLightTypeEnum
DistiAttributeLightTypeEnum(GlsLightSource *frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName &name)
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsColor
Definition: gls_color.h:54
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsLightSource
Definition: gls_light_source.h:84
disti::GlsLightSource::_ambient
GlsColor _ambient
Definition: gls_light_source.h:99
disti::GlsLightSource::SpotExponent
float SpotExponent()
disti::GlsLightSource::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) override
disti::GlsLightSource::SetFromGloData
virtual void SetFromGloData(GlsGloFileAttribute &data) override
disti::GlsLightSource::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) override
disti::GlsLightSource::ConstantAttenuation
float ConstantAttenuation()
disti::GlsLightSource::LinearAttenuation
float LinearAttenuation()
disti::GlsLightSource::_spotExponent
float _spotExponent
Definition: gls_light_source.h:104
disti::GlsLightSource::GetDiffuse
GlsColor GetDiffuse()
disti::GlsLightSource::SetValue
virtual void SetValue(int spec, va_list &args) override
disti::GlsLightSource::QuadraticAttenuation
float QuadraticAttenuation()
disti::GlsLightSource::SetupLight
virtual void SetupLight(unsigned int light_number, GlsMatrixType *alternateModelMatrix=NULL)
disti::GlsLightSource::_spotCutoff
float _spotCutoff
Definition: gls_light_source.h:103
disti::GlsLightSource::_quadraticAttenuation
float _quadraticAttenuation
Definition: gls_light_source.h:107
disti::GlsLightSource::_lightType
LightType_e _lightType
Definition: gls_light_source.h:102
disti::GlsLightSource::Hit
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) override
disti::GlsLightSource::CopyProperties
virtual void CopyProperties(DisplayObject *src) override
disti::GlsLightSource::_specular
GlsColor _specular
Definition: gls_light_source.h:101
disti::GlsLightSource::GetSpecular
GlsColor GetSpecular()
disti::GlsLightSource::_linearAttenuation
float _linearAttenuation
Definition: gls_light_source.h:106
disti::GlsLightSource::_diffuse
GlsColor _diffuse
Definition: gls_light_source.h:100
disti::GlsLightSource::SpotCutoff
float SpotCutoff()
disti::GlsLightSource::Draw
virtual void Draw() override
disti::GlsLightSource::SetAmbient
void SetAmbient(const GlsColor &color)
disti::GlsLightSource::PreDraw
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) override
disti::GlsLightSource::SetDiffuse
void SetDiffuse(const GlsColor &color)
disti::GlsLightSource::GetAmbient
GlsColor GetAmbient()
disti::GlsLightSource::LightType
int LightType()
disti::GlsLightSource::_constantAttenuation
float _constantAttenuation
Definition: gls_light_source.h:105
disti::GlsLightSource::SetSpecular
void SetSpecular(const GlsColor &color)
disti::GlsMatrixAffine< double >
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
display.h
The disti::DisplayObject class and global enumerations.
gls_color.h
The Color class: Implements a 4 component RGBA color.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
gls_include.h
A file for all GL Studio files to include.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
disti
Definition: bmpimage.h:47
disti::GLS_LightSource_Initializers
GLS_LightSource_Initializers
Definition: gls_light_source.h:63
disti::LightType_e
LightType_e
Definition: gls_light_source.h:54