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