GL Studio C++ Runtime API
component_light_mgr.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::ComponentLightMgr 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 _COMPONENT_LIGHT_MGR_H
41 #define _COMPONENT_LIGHT_MGR_H
42 
43 #include "dynamic_array.h"
44 #include "gls_include.h"
45 
46 namespace disti
47 {
48 class GlsLightSource;
49 class GlsEyePoint;
50 class DisplayObject;
51 
52 /** This class is responsible for keeping track of the lights in a component
53  * and setting up lighting for the objects of the component.
54  */
56 {
57 protected:
58  DynamicArray<GlsLightSource*> _registeredLights; /** List of active lights in the component
59  This list is reset and populated during the PreDraw() traversal */
60 
61  bool _useParentsLighting; /** If UseParentsLighting is true, the component will add
62  its lights to those already set by it's parent.
63  If false, the component will only use it's own lights.*/
64 
65  GLS_EXPORT ComponentLightMgr( void );
66 
67 public:
68  static GLS_EXPORT ComponentLightMgr* CreateInstance( void );
69 
70  virtual GLS_EXPORT ~ComponentLightMgr( void );
71 
72  /** Accessor method to set whether or not to inherit lighting from the component's parent
73  * \param useParentsLighting Whether or not to inherit lighting from the component's parent
74  */
75  void GLS_EXPORT UseParentsLighting( bool useParentsLighting );
76 
77  /** Accessor method to get whether or not to inherit lighting from the component's parent
78  * \return Whether or not to inherit lighting from the component's parent
79  */
80  bool GLS_EXPORT UseParentsLighting( void );
81 
82  /** Sets whether GL_NORMALIZE is enabled. Default value is true.
83  * \param enableNormalize Set GL_NORMALIZE to true or false
84  */
85  void GLS_EXPORT EnableNormalize( bool enableNormalize );
86 
87  /* Accessor method to get whether or not GL_NORMALIZE is enabled
88  * \return Whether or not GL_NORMALIZE is enabled
89  */
90  bool GLS_EXPORT EnableNormalize();
91 
92  /** Any light source in the component that wants to be enabled
93  * must call this during PreDraw().
94  * \param light The light to be enabled
95  */
96  void GLS_EXPORT RegisterLight( GlsLightSource* light );
97 
98  /** Called before PreDraw() to clear the light list
99  */
100  void GLS_EXPORT ClearRegisteredLights( void );
101 
102  /** Called by the the parent of the component to initialize lighting prior to drawing the component
103  */
104  void GLS_EXPORT TopFrameInitialize( void );
105 
106  /** Called by the the parent of the component to restore lighting after drawing the component
107  */
108  void GLS_EXPORT TopFrameRestore( void );
109 
110  /** Detemine the OpenGL lighting state for this component and push it
111  * onto the global lighting stack (called from DisplayFrame::Draw())
112  */
113  void GLS_EXPORT SetupComponentLighting( void );
114 
115  /** Called at the end of DisplayFrame::Draw() to restore the original lighting state
116  */
117  void GLS_EXPORT CleanupComponentLighting( void );
118 
119  /** Called by lit objects to setup lights
120  * \param object The object to setup lighting for
121  */
122  void GLS_EXPORT SetupLighting( DisplayObject* object );
123 
124  /** Called to force all lights to be reapplied based on
125  * the modelview specified by the eyePoint.
126  * A value of NULL, reapplys the lights with their original
127  * modelview.
128  */
129  void GLS_EXPORT ReapplyLightsForEyePoint( GlsEyePoint* eyePoint );
130 
131  /** Sets a flag to cause the lights to be reapplied when the next lit object
132  * draws. This may be necessary for special cases where the OpenGL matrices
133  * have changed during a traversel. This can
134  * happen when drawing multiple views of the same
135  * geometry.
136  */
137  void GLS_EXPORT ReapplyLights();
138 
139  /** Get a boolean mask of the active lights
140  * \return A boolean array with a bitmask of the currently active lights
141  */
142  GLS_EXPORT bool* GetActiveLightsMask( void );
143 
144  /** Get a bitmask of the active lights
145  * \return An unsigned integer with each bit representing a light turned on/off
146  */
147  GLS_EXPORT unsigned int GetActiveLightsBitMask( void );
148 
149  /** Get the number of active lights for this component. Will include parent lights.
150  * Really is the max index(+1) of lights that you need to cycle through to have
151  * taken all of them into account (in case of holes in the list created by an
152  * outside party).
153  * \return An integer representing the number of currently active lights
154  */
155  GLS_EXPORT unsigned int GetNumActiveLights( void );
156 };
157 
158 } // namespace disti
159 
160 #endif
void SetupComponentLighting(void)
void EnableNormalize(bool enableNormalize)
The disti::DynamicArray class. A templated array of objects capable of dynamically growing...
unsigned int GetNumActiveLights(void)
bool * GetActiveLightsMask(void)
Definition: display.h:97
void RegisterLight(GlsLightSource *light)
unsigned int GetActiveLightsBitMask(void)
Definition: component_light_mgr.h:55
A file for all GL Studio files to include.
void CleanupComponentLighting(void)
void SetupLighting(DisplayObject *object)
void ClearRegisteredLights(void)
Definition: gls_eyepoint.h:115
void ReapplyLightsForEyePoint(GlsEyePoint *eyePoint)
Definition: gls_light_source.h:83
Definition: bmpimage.h:46
bool _useParentsLighting
Definition: component_light_mgr.h:61