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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State 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"
46#include "gls_include.h"
47
48namespace disti
49{
50/**
51 LightType_e
52*/
53typedef enum
54{
55 LIGHT_LOCAL,
56 LIGHT_INFINITE
58
59/**
60 Light Source Initializers
61*/
62typedef 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
77class GlsGloFileAttribute;
78#endif
79
80/**
81 The GlsLightSource class. Implements Lights as objects
82*/
84{
85private:
86 /** Disabling the default implicit assignment and copy constructors */
87 GlsLightSource& operator=( const GlsLightSource& ) DISTI_SPECIAL_MEM_FUN_DELETE; // = delete
89
90public:
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 */
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
132 virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) 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 */
154
155 /** Get the diffuse color for this light
156 * \return The diffuse color
157 */
159
160 /** Get the specular color for this light
161 * \return The specular color
162 */
164
165 /** Get what type of light this is
166 * \return Tye type of light (\sa LightType_e)
167 */
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 */
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 */
194
195 /** Set the constant attenuation coefficient
196 * \param c New coefficient
197 */
199
200 /** Get the constant attenuation coefficient
201 * \return The coefficient
202 */
204
205 /** Set the linear attenuation coefficient
206 * \param c New coefficient
207 */
209
210 /** Get the linear attenuation coefficient
211 * \return The coefficient
212 */
214
215 /** Set the quadratic attenuation coefficient
216 * \param c New coefficient
217 */
219
220 /** Get the quadratic attenuation coefficient
221 * \return The coefficient
222 */
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
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>;
246class DistiAttributeLightTypeEnum : public DistiAttributeEnum<GlsLightSource, int, int>
247{
248public:
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.
255
257};
258
259} // namespace disti
260
261#endif
Definition: disti_metadata.h:87
Definition: cull.h:50
Definition: display.h:96
Definition: disti_metadata.h:1005
void(containerClass::* SetMethodType)(int)
Typedef for the set method function pointer.
Definition: disti_metadata.h:1007
int(containerClass::* GetMethodType)()
Typedef for the get method function pointer.
Definition: disti_metadata.h:1008
Definition: gls_light_source.h:247
DistiAttributeLightTypeEnum(GlsLightSource *frame, SetMethodType setMethod, GetMethodType getMethod, const AttributeName &name)
Definition: dynamic_array.h:79
Definition: gls_color.h:54
Definition: gls_glo_file.h:1243
Definition: gls_light_source.h:84
GlsColor _ambient
Definition: gls_light_source.h:99
virtual DisplayObject * CloneObject(bool generateNames=false) override
virtual void SetAvailableAttributes(unsigned int value) override
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) override
float _spotExponent
Definition: gls_light_source.h:104
virtual 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:103
float _quadraticAttenuation
Definition: gls_light_source.h:107
LightType_e _lightType
Definition: gls_light_source.h:102
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) override
virtual bool Hit(float x, float y, float z, float scale, const Vector &directionVector, Vector *collisionPoint) override
virtual void CopyProperties(DisplayObject *src) override
GlsColor _specular
Definition: gls_light_source.h:101
float _linearAttenuation
Definition: gls_light_source.h:106
GlsColor _diffuse
Definition: gls_light_source.h:100
virtual void Draw() override
void SetAmbient(const GlsColor &color)
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) override
void SetDiffuse(const GlsColor &color)
float _constantAttenuation
Definition: gls_light_source.h:105
void SetSpecular(const GlsColor &color)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: vertex.h:85
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:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
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:52
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
GLS_LightSource_Initializers
Definition: gls_light_source.h:63
LightType_e
Definition: gls_light_source.h:54