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
74 
75 #ifdef GLES
76 // Forward Declaration
77 class GlsGloFileAttribute;
78 #endif
79 
80 /**
81  The GlsLightSource class. Implements Lights as objects
82 */
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;
93  typedef DisplayObject BaseClass;
94  friend class GlsLightSourceEditor;
95 
96 protected:
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 
109 public:
110  /* See base class */
111  virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
112 
113  /** Allocate a (blank) LightSource object */
114  GLS_EXPORT GlsLightSource( bool newGlLight = true );
115 
116  GLS_EXPORT GlsLightSource( const GlsLightSource& that, const bool generateNames );
117 
118  /** Destroy a LightSource object */
119  virtual GLS_EXPORT ~GlsLightSource( void );
120 
121  virtual GLS_EXPORT void SetAvailableAttributes( unsigned int value );
122 
123  /** Setup the given OpenGL light number with this light's properties */
124  virtual GLS_EXPORT void SetupLight( unsigned int light_number, GlsMatrixType* alternateModelMatrix = NULL );
125 
126  /* See base class */
127  virtual GLS_EXPORT void Draw( void );
128 
129  /* See base class */
130  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
131 
132  /* See base class */
133  virtual GLS_EXPORT void CopyProperties( DisplayObject* src );
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( void );
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 );
230 #endif
231 
232  /* See base class */
233  virtual GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
234 
235  /* See base class */
236  virtual GLS_EXPORT void SetValue( int spec, va_list& args );
237 
238 #ifndef GLES
239  /* See base class */
240  virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
241 
242  /* See base class */
243  virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
244 #endif
245 };
246 
247 #define DEF_LIGHT_TYPE LIGHT_INFINITE
248 /** The DistiAttributeLightTypeEnum class
249  */
250 //template class GLS_EXPORT DistiAttributeEnum<LightType_e>;
251 class DistiAttributeLightTypeEnum : public DistiAttributeEnum<GlsLightSource, int, int>
252 {
253 public:
254  GLS_EXPORT DistiAttributeLightTypeEnum( GlsLightSource* frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName& name );
255  virtual GLS_EXPORT ~DistiAttributeLightTypeEnum();
256 };
257 
258 } // namespace disti
259 
260 #endif
Definition: cull.h:49
void SetSpecular(const GlsColor &color)
void SetAmbient(const GlsColor &color)
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
virtual void CopyProperties(DisplayObject *src)
virtual void SetupLight(unsigned int light_number, GlsMatrixType *alternateModelMatrix=NULL)
Definition: dynamic_array.h:66
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:296
float _spotCutoff
Definition: gls_light_source.h:103
GlsColor _diffuse
Definition: gls_light_source.h:100
Definition: display.h:98
float _quadraticAttenuation
Definition: gls_light_source.h:107
virtual void SetValue(int spec, va_list &args)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
float _constantAttenuation
Definition: gls_light_source.h:105
LightType_e _lightType
Definition: gls_light_source.h:102
The Color class: Implements a 4 component RGBA color.
A file for all GL Studio files to include.
Definition: gls_glo_file.h:988
The disti::DisplayObject class and global enumerations.
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
Definition: disti_metadata.h:894
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual DisplayObject * CloneObject(bool generateNames=false)
GlsColor _specular
Definition: gls_light_source.h:101
virtual void SetAvailableAttributes(unsigned int value)
Definition: gls_light_source.h:251
GLS_LightSource_Initializers
Definition: gls_light_source.h:62
LightType_e
Definition: gls_light_source.h:53
Definition: gls_color.h:53
float _linearAttenuation
Definition: gls_light_source.h:106
void SetDiffuse(const GlsColor &color)
GlsColor _ambient
Definition: gls_light_source.h:99
Definition: vertex.h:84
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
virtual void Draw(void)
Macros and helper code to determine what subset of C++11/14/17 is available.
float _spotExponent
Definition: gls_light_source.h:104
Definition: disti_metadata.h:85
virtual ~GlsLightSource(void)
Definition: gls_light_source.h:83
Definition: bmpimage.h:46