| 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 */
55 class ComponentLightMgr
56{
57 protected:
58 /** List of active lights in the component. This list is reset and populated during the PreDraw() traversal */
59 DynamicArray<GlsLightSource*> _registeredLights;
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.*/
64 bool _useParentsLighting;
65
66 GLS_EXPORT ComponentLightMgr();
67
68 public:
69 /// \return A pointer to a new ComponentLightMgr instance.
70 static GLS_EXPORT ComponentLightMgr* CreateInstance();
71
72 virtual GLS_EXPORT ~ComponentLightMgr();
73
74 /** Accessor method to set whether or not to inherit lighting from the component's parent
75 * \param useParentsLighting Whether or not to inherit lighting from the component's parent
76 */
77 void GLS_EXPORT UseParentsLighting( bool useParentsLighting );
78
79 /** Accessor method to get whether or not to inherit lighting from the component's parent
80 * \return Whether or not to inherit lighting from the component's parent
81 */
82 bool GLS_EXPORT UseParentsLighting();
83
84 /** Sets whether GL_NORMALIZE is enabled. Default value is true.
85 * \param enableNormalize Set GL_NORMALIZE to true or false
86 */
87 void GLS_EXPORT EnableNormalize( bool enableNormalize );
88
89 /// Accessor method to get whether or not GL_NORMALIZE is enabled
90 /// \return Whether or not GL_NORMALIZE is enabled.
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();
102
103 /** Called by the the parent of the component to initialize lighting prior to drawing the component
104 */
105 void GLS_EXPORT TopFrameInitialize();
106
107 /** Called by the the parent of the component to restore lighting after drawing the component
108 */
109 void GLS_EXPORT TopFrameRestore();
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();
115
116 /** Called at the end of DisplayFrame::Draw() to restore the original lighting state
117 */
118 void GLS_EXPORT CleanupComponentLighting();
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, reapplies the lights with their original modelview.
128 /// \param eyePoint The new GlsEyePoint to use, or NULL.
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();
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();
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();
156};
157
158} // namespace disti
159
160#endif
disti::ComponentLightMgr
Definition: component_light_mgr.h:56
disti::ComponentLightMgr::EnableNormalize
void EnableNormalize(bool enableNormalize)
disti::ComponentLightMgr::ClearRegisteredLights
void ClearRegisteredLights()
disti::ComponentLightMgr::UseParentsLighting
bool UseParentsLighting()
disti::ComponentLightMgr::TopFrameInitialize
void TopFrameInitialize()
disti::ComponentLightMgr::CleanupComponentLighting
void CleanupComponentLighting()
disti::ComponentLightMgr::SetupComponentLighting
void SetupComponentLighting()
disti::ComponentLightMgr::_registeredLights
DynamicArray< GlsLightSource * > _registeredLights
Definition: component_light_mgr.h:59
disti::ComponentLightMgr::EnableNormalize
bool EnableNormalize()
disti::ComponentLightMgr::GetActiveLightsMask
bool * GetActiveLightsMask()
disti::ComponentLightMgr::ReapplyLights
void ReapplyLights()
disti::ComponentLightMgr::GetNumActiveLights
unsigned int GetNumActiveLights()
disti::ComponentLightMgr::CreateInstance
static ComponentLightMgr * CreateInstance()
disti::ComponentLightMgr::SetupLighting
void SetupLighting(DisplayObject *object)
disti::ComponentLightMgr::ReapplyLightsForEyePoint
void ReapplyLightsForEyePoint(GlsEyePoint *eyePoint)
disti::ComponentLightMgr::TopFrameRestore
void TopFrameRestore()
disti::ComponentLightMgr::_useParentsLighting
bool _useParentsLighting
Definition: component_light_mgr.h:64
disti::ComponentLightMgr::UseParentsLighting
void UseParentsLighting(bool useParentsLighting)
disti::ComponentLightMgr::GetActiveLightsBitMask
unsigned int GetActiveLightsBitMask()
disti::ComponentLightMgr::RegisterLight
void RegisterLight(GlsLightSource *light)
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray< GlsLightSource * >
disti::GlsEyePoint
Definition: gls_eyepoint.h:117
disti::GlsLightSource
Definition: gls_light_source.h:84
dynamic_array.h
The disti::DynamicArray class. A templated array of objects capable of dynamically growing.
gls_include.h
A file for all GL Studio files to include.
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
disti
Definition: bmpimage.h:47