GL Studio 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) 2015 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_include.h"
46 #include "gls_cpp_lang_support.h"
47 
48 namespace disti
49 {
50 
51 /**
52  LightType_e
53 */
54 typedef enum
55 {
56  LIGHT_LOCAL,
57  LIGHT_INFINITE
58 } LightType_e;
59 
60 /**
61  Light Source Initializers
62 */
63 typedef enum
64 {
65  GLS_LIGHT_SOURCE_AMBIENT=GLS_LAST_INITIALIZER+1,
66  GLS_LIGHT_SOURCE_DIFFUSE,
67  GLS_LIGHT_SOURCE_SPECULAR,
68  GLS_LIGHT_SOURCE_SPOT_CUTOFF,
69  GLS_LIGHT_SOURCE_SPOT_EXPONENT,
70  GLS_LIGHT_SOURCE_CONSTANT_ATTENUATION,
71  GLS_LIGHT_SOURCE_LINEAR_ATTENUATION,
72  GLS_LIGHT_SOURCE_QUADRATIC_ATTENUATION,
73  GLS_LIGHT_SOURCE_LIGHT_TYPE
75 
76 #ifdef GLES
77  // Forward Declaration
78  class GlsGloFileAttribute;
79 #endif
80 
81 /**
82  The GlsLightSource class. Implements Lights as objects
83 */
85 {
86 private:
87  /** Disabling the default implicit assignment and copy constructors */
88  GlsLightSource& operator=( const GlsLightSource& ) DISTI_SPECIAL_MEM_FUN_DELETE; // = delete
89  GlsLightSource( const GlsLightSource& ) DISTI_SPECIAL_MEM_FUN_DELETE;
90 
91 public:
92  typedef DisplayObject _BaseClass;
93  friend class GlsLightSourceEditor;
94 
95 protected:
96 
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 
111  /* See base class */
112  virtual GLS_EXPORT DisplayObject *CloneObject(bool generateNames = false);
113 
114  /** Allocate a (blank) LightSource object */
115  GLS_EXPORT GlsLightSource(bool newGlLight = true);
116 
117  GLS_EXPORT GlsLightSource( const GlsLightSource& that, const bool generateNames );
118 
119  /** Destroy a LightSource object */
120  virtual GLS_EXPORT ~GlsLightSource(void);
121 
122  virtual GLS_EXPORT void SetAvailableAttributes(unsigned int value);
123 
124  /** Setup the given OpenGL light number with this light's properties */
125  virtual GLS_EXPORT void SetupLight(unsigned int light_number, GlsMatrixType* alternateModelMatrix=NULL);
126 
127  /* See base class */
128  virtual GLS_EXPORT void Draw(void);
129 
130  /* See base class */
131  virtual GLS_EXPORT void PreDraw(const OpenGLMatrices& current, Culler& culler);
132 
133  /* See base class */
134  virtual GLS_EXPORT void CopyProperties(DisplayObject *src);
135 
136  /** Set the ambient color for this light
137  * \param color The new ambient color
138  */
139  GLS_EXPORT void SetAmbient(const glsColor &color);
140 
141  /** Set the diffuse color for this light
142  * \param color The new diffuse color
143  */
144  GLS_EXPORT void SetDiffuse(const glsColor &color);
145 
146  /** Set the specular color for this light
147  * \param color The new specular color
148  */
149  GLS_EXPORT void SetSpecular(const glsColor &color);
150 
151  /** Get the ambient color for this light
152  * \return The ambient color
153  */
154  GLS_EXPORT glsColor GetAmbient();
155 
156  /** Get the diffuse color for this light
157  * \return The diffuse color
158  */
159  GLS_EXPORT glsColor GetDiffuse();
160 
161  /** Get the specular color for this light
162  * \return The specular color
163  */
164  GLS_EXPORT glsColor GetSpecular();
165 
166  /** Get what type of light this is
167  * \return Tye type of light (\sa LightType_e)
168  */
169  GLS_EXPORT int LightType(void);
170 
171  /** Set what type of light this is
172  * \param type The type of light (\sa LightType_e)
173  */
174  GLS_EXPORT void LightType(int type);
175 
176  /** Set the spot cutoff factor
177  * \param s New spot cutoff factor
178  */
179  GLS_EXPORT void SpotCutoff(float s);
180 
181  /** Get the spot cutoff factor
182  * \return Spot cutoff factor
183  */
184  GLS_EXPORT float SpotCutoff();
185 
186  /** Set the spot exponent
187  * \param s New spot exponent
188  */
189  GLS_EXPORT void SpotExponent(float s);
190 
191  /** Get the spot exponent
192  * \return Spot exponent
193  */
194  GLS_EXPORT float SpotExponent();
195 
196  /** Set the constant attenuation coefficient
197  * \param c New coefficient
198  */
199  GLS_EXPORT void ConstantAttenuation(float c);
200 
201  /** Get the constant attenuation coefficient
202  * \return The coefficient
203  */
204  GLS_EXPORT float ConstantAttenuation();
205 
206  /** Set the linear attenuation coefficient
207  * \param c New coefficient
208  */
209  GLS_EXPORT void LinearAttenuation(float c);
210 
211  /** Get the linear attenuation coefficient
212  * \return The coefficient
213  */
214  GLS_EXPORT float LinearAttenuation();
215 
216  /** Set the quadratic attenuation coefficient
217  * \param c New coefficient
218  */
219  GLS_EXPORT void QuadraticAttenuation(float c);
220 
221  /** Get the quadratic attenuation coefficient
222  * \return The coefficient
223  */
224  GLS_EXPORT float QuadraticAttenuation();
225 
226 #ifdef GLES
227  /** Set a single attribute from the GLO file.
228  * \param data The attribute to set and its associated data.
229  */
230  virtual GLS_EXPORT void SetFromGloData(GlsGloFileAttribute &data);
231 #endif
232 
233  /* See base class */
234  virtual GLS_EXPORT bool Hit(float x,float y,float z,float scale, const Vector& directionVector,Vector *collisionPoint);
235 
236  /* See base class */
237  virtual GLS_EXPORT void SetValue(int spec,va_list &args);
238 
239 #ifndef GLES
240  /* See base class */
241  virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription(InterfaceListType* addToThisList= NULL );
242 
243  /* See base class */
244  virtual GLS_EXPORT void GetCppInterfaceDescriptionFree(InterfaceListType* array);
245 #endif
246 };
247 
248 
249 #define DEF_LIGHT_TYPE LIGHT_INFINITE
250 /** The DistiAttributeLightTypeEnum class
251  */
252 //template class GLS_EXPORT DistiAttributeEnum<LightType_e>;
253 class DistiAttributeLightTypeEnum : public DistiAttributeEnum<GlsLightSource,int,int>
254 {
255 public:
256  GLS_EXPORT DistiAttributeLightTypeEnum(GlsLightSource* frame,SetMethodType setMethod, GetMethodType getMethod,const AttributeName &name);
257  virtual GLS_EXPORT ~DistiAttributeLightTypeEnum();
258 };
259 
260 } // namespace disti
261 
262 #endif
Definition: cull.h:50
void SetAmbient(const glsColor &color)
virtual void CopyProperties(DisplayObject *src)
virtual void SetupLight(unsigned int light_number, GlsMatrixType *alternateModelMatrix=NULL)
Definition: dynamic_array.h:63
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:289
void SetSpecular(const glsColor &color)
float _spotCutoff
Definition: gls_light_source.h:103
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)
glsColor _specular
Definition: gls_light_source.h:101
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.
The disti::DisplayObject class and global enumerations.
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
Definition: disti_metadata.h:881
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual void SetAvailableAttributes(unsigned int value)
glsColor _diffuse
Definition: gls_light_source.h:100
Definition: gls_light_source.h:253
GLS_LightSource_Initializers
Definition: gls_light_source.h:63
LightType_e
Definition: gls_light_source.h:54
float _linearAttenuation
Definition: gls_light_source.h:106
Definition: gls_color.h:54
Definition: vertex.h:84
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint)
glsColor _ambient
Definition: gls_light_source.h:99
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:83
virtual ~GlsLightSource(void)
Definition: gls_light_source.h:84
Definition: bmpimage.h:46
void SetDiffuse(const glsColor &color)