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  typedef DisplayObject _BaseClass;
92  friend class GlsLightSourceEditor;
93 
94 protected:
95  /** NOTE: _visible determines if the light is on */
96 
97  GlsColor _ambient; /**< Value for the ambient light component */
98  GlsColor _diffuse; /**< Value for the diffuse light component */
99  GlsColor _specular; /**< Value for the ambient light component */
100  LightType_e _lightType; /**< Value for the light type */
101  float _spotCutoff; /**< Value for the GL_SPOT_CUTOFF glLight() parameter */
102  float _spotExponent; /**< Value for the GL_SPOT_EXPONENT glLight() parameter */
103  float _constantAttenuation; /**< Value for GL_CONSTANT_ATTENUATION glLight() parameter */
104  float _linearAttenuation; /**< Value for GL_LINEAR_ATTENUATION glLight() parameter */
105  float _quadraticAttenuation; /**< Value for GL_QUADRATIC_ATTENUATION glLight() parameter */
106 
107 public:
108  /* See base class */
109  virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
110 
111  /** Allocate a (blank) LightSource object */
112  GLS_EXPORT GlsLightSource( bool newGlLight = true );
113 
114  GLS_EXPORT GlsLightSource( const GlsLightSource& that, const bool generateNames );
115 
116  /** Destroy a LightSource object */
117  virtual GLS_EXPORT ~GlsLightSource( void );
118 
119  virtual GLS_EXPORT void SetAvailableAttributes( unsigned int value );
120 
121  /** Setup the given OpenGL light number with this light's properties */
122  virtual GLS_EXPORT void SetupLight( unsigned int light_number, GlsMatrixType* alternateModelMatrix = NULL );
123 
124  /* See base class */
125  virtual GLS_EXPORT void Draw( void );
126 
127  /* See base class */
128  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
129 
130  /* See base class */
131  virtual GLS_EXPORT void CopyProperties( DisplayObject* src );
132 
133  /** Set the ambient color for this light
134  * \param color The new ambient color
135  */
136  GLS_EXPORT void SetAmbient( const GlsColor& color );
137 
138  /** Set the diffuse color for this light
139  * \param color The new diffuse color
140  */
141  GLS_EXPORT void SetDiffuse( const GlsColor& color );
142 
143  /** Set the specular color for this light
144  * \param color The new specular color
145  */
146  GLS_EXPORT void SetSpecular( const GlsColor& color );
147 
148  /** Get the ambient color for this light
149  * \return The ambient color
150  */
151  GLS_EXPORT GlsColor GetAmbient();
152 
153  /** Get the diffuse color for this light
154  * \return The diffuse color
155  */
156  GLS_EXPORT GlsColor GetDiffuse();
157 
158  /** Get the specular color for this light
159  * \return The specular color
160  */
161  GLS_EXPORT GlsColor GetSpecular();
162 
163  /** Get what type of light this is
164  * \return Tye type of light (\sa LightType_e)
165  */
166  GLS_EXPORT int LightType( void );
167 
168  /** Set what type of light this is
169  * \param type The type of light (\sa LightType_e)
170  */
171  GLS_EXPORT void LightType( int type );
172 
173  /** Set the spot cutoff factor
174  * \param s New spot cutoff factor
175  */
176  GLS_EXPORT void SpotCutoff( float s );
177 
178  /** Get the spot cutoff factor
179  * \return Spot cutoff factor
180  */
181  GLS_EXPORT float SpotCutoff();
182 
183  /** Set the spot exponent
184  * \param s New spot exponent
185  */
186  GLS_EXPORT void SpotExponent( float s );
187 
188  /** Get the spot exponent
189  * \return Spot exponent
190  */
191  GLS_EXPORT float SpotExponent();
192 
193  /** Set the constant attenuation coefficient
194  * \param c New coefficient
195  */
196  GLS_EXPORT void ConstantAttenuation( float c );
197 
198  /** Get the constant attenuation coefficient
199  * \return The coefficient
200  */
201  GLS_EXPORT float ConstantAttenuation();
202 
203  /** Set the linear attenuation coefficient
204  * \param c New coefficient
205  */
206  GLS_EXPORT void LinearAttenuation( float c );
207 
208  /** Get the linear attenuation coefficient
209  * \return The coefficient
210  */
211  GLS_EXPORT float LinearAttenuation();
212 
213  /** Set the quadratic attenuation coefficient
214  * \param c New coefficient
215  */
216  GLS_EXPORT void QuadraticAttenuation( float c );
217 
218  /** Get the quadratic attenuation coefficient
219  * \return The coefficient
220  */
221  GLS_EXPORT float QuadraticAttenuation();
222 
223 #ifdef GLES
224  /** Set a single attribute from the GLO file.
225  * \param data The attribute to set and its associated data.
226  */
227  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
228 #endif
229 
230  /* See base class */
231  virtual GLS_EXPORT bool Hit( float x, float y, float z, float scale, const Vector& directionVector, Vector* collisionPoint );
232 
233  /* See base class */
234  virtual GLS_EXPORT void SetValue( int spec, va_list& args );
235 
236 #ifndef GLES
237  /* See base class */
238  virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
239 
240  /* See base class */
241  virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
242 #endif
243 };
244 
245 #define DEF_LIGHT_TYPE LIGHT_INFINITE
246 /** The DistiAttributeLightTypeEnum class
247  */
248 //template class GLS_EXPORT DistiAttributeEnum<LightType_e>;
249 class DistiAttributeLightTypeEnum : public DistiAttributeEnum<GlsLightSource, int, int>
250 {
251 public:
252  GLS_EXPORT DistiAttributeLightTypeEnum( GlsLightSource* frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName& name );
253  virtual GLS_EXPORT ~DistiAttributeLightTypeEnum();
254 };
255 
256 } // namespace disti
257 
258 #endif
Definition: cull.h:49
void SetSpecular(const GlsColor &color)
void SetAmbient(const GlsColor &color)
virtual void CopyProperties(DisplayObject *src)
virtual void SetupLight(unsigned int light_number, GlsMatrixType *alternateModelMatrix=NULL)
Definition: dynamic_array.h:62
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:276
float _spotCutoff
Definition: gls_light_source.h:101
GlsColor _diffuse
Definition: gls_light_source.h:98
Definition: display.h:98
float _quadraticAttenuation
Definition: gls_light_source.h:105
virtual void SetValue(int spec, va_list &args)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
float _constantAttenuation
Definition: gls_light_source.h:103
LightType_e _lightType
Definition: gls_light_source.h:100
The Color class: Implements a 4 component RGBA color.
A file for all GL Studio files to include.
Definition: gls_glo_file.h:982
The disti::DisplayObject class and global enumerations.
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
Definition: disti_metadata.h:904
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual DisplayObject * CloneObject(bool generateNames=false)
GlsColor _specular
Definition: gls_light_source.h:99
virtual void SetAvailableAttributes(unsigned int value)
Definition: gls_light_source.h:249
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:104
void SetDiffuse(const GlsColor &color)
GlsColor _ambient
Definition: gls_light_source.h:97
Definition: vertex.h:83
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:102
Definition: disti_metadata.h:79
virtual ~GlsLightSource(void)
Definition: gls_light_source.h:83
Definition: bmpimage.h:46