VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgLightManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
14 
16 #include <boost/unordered_map.hpp>
17 
18 #include <osg/observer_ptr>
19 #include <osg/Node>
20 #include <osg/Light>
21 
22 #include <matrix/vlVector.h>
23 
26 
27 namespace osg
28 {
29  class Light;
30  class LightSource;
31  class State;
32  class StateSet;
33  class Matrixd;
34 }
35 
36 namespace makVrv
37 {
38  // Implements GLSL lighting
39  class DtOsgLightsObserver;
40  class DtLightManager;
41  class DtOsgSkyObject;
42 
43 
44 
50  {
51  public:
53  virtual ~DtOsgLightManager();
54 
55  protected:
58 
59  private:
61  DtOsgLightManager() = delete;
62 
64  DtOsgLightManager(const DtOsgLightManager& rhs) = delete;
65 
67  DtOsgLightManager& operator=(const DtOsgLightManager& rhs) = delete;
68 
69  public:
70 
72  virtual void initialize();
73 
76  virtual void attachToStateSet(osg::StateSet* stateSet);
77 
79  virtual void setPerPixelLightingEnabled(bool enabled);
80 
82  virtual bool perPixelLightingEnabled() const;
83 
85  virtual DtLightManager& lightManager();
86 
88  virtual void setReservedID(int id);
89 
91  virtual int reservedID() const;
92 
95  virtual void cullReset();
96 
98  virtual bool registerLight(const osg::LightSource* light, const osg::NodePath& nodePath, const osg::Matrixd& modelingMatrix, bool globalLights);
99 
102  virtual DtLight* createDtLight(const osg::Light* osgLight);
103 
105  virtual void convertOsgLightToDtLight(const osg::LightSource& lightSource, DtLight* pDtLight, const osg::Matrixd& modelingMatrix);
106 
107  // PPP: TO DO. How to deregister ligths?
108  virtual void deregisterLight(const osg::LightSource* light);
109 
111  virtual void getWorldPositionAndDirection(const osg::LightSource& lightSource, const osg::Matrixd& modelingMatrix, osg::Vec3d& vWorldPos, osg::Vec3d& vWorldDir) const;
112 
114  virtual void update(osg::State& state, DtDe& de, const osg::Camera* camera);
115 
117  virtual int getTextureStartOffset(void) const;
118 
120  virtual const Vector2_uint32& tileSize(void) const;
121 
123  virtual const Vector2_uint32& gridMaxDims(void) const;
124 
126  virtual void releaseGLObjects(void);
127 
129  virtual unsigned int getOrCreateLightSourceTypeId(DtLight* pDtLight);
130 
132  virtual unsigned int getOrCreateLightSourceTypeId(const osg::LightSource& lightSource);
133 
136  virtual unsigned int getOrCreateDynamicLightSourceTypeId(const DtLight* pDtLight);
137 
139  virtual void deleteDynamicLightSourceTypeId(const DtLight* pDtLight);
140 
143  virtual LightReusableVector lightSourceTypeLightVector() const;
144 
146  virtual void updateLightSourceType(unsigned int id, const DtLight* light);
147 
149  virtual const DtOsgLightingComponent* lightingComponent() const;
150 
152  virtual DtOsgLightingComponent* lightingComponent();
153 
154  public:
156  static DtOsgLightManager& instance(DtDe& de);
157 
159  static const std::string& theClassName();
160 
162  static LightType lightType(const osg::Light* light);
163 
164  protected:
166  virtual void updateLightOnOffStatus(const VectorLights& lights);
167 
169  virtual bool computeLightStatusForTime(const DtLight* pDtLight, DtOsgSkyObject* skyObject);
170 
171  virtual void updateFixedFunctionLights(const osg::State& state);
172 
177  virtual void updateShaderBasedLights(const osg::State& state, const VectorLights& lights, const osg::Camera* camera);
178 
179  virtual const VectorLights& computeFrustumLights(const osg::State &state, const osg::Camera* camera);
180 
181  virtual void proccessLightPath(DtLight* inLight, const osg::NodePath& nodePath);
182 
183  virtual void configurePerPixelLighting(osg::StateSet*);
184 
185  virtual void slot_reloadShader();
186 
187  virtual bool existsInLightManager(const DtLight* light) const;
188 
189  protected:
190 
195 
197 
199 
200 
201  osg::observer_ptr<osg::StateSet> myStateSet;
202  VectorLights myActiveLights;
203 
205 
206  typedef std::pair<const osg::LightSource*, const makVrv::DtLight*> LightSourceAndLight;
207 
208  typedef boost::unordered_map<size_t, LightSourceAndLight> MapLightSourceHashToLights;
210 
211  DtOsgLightsObserver* myOsgLightsObserver;
212 
213  typedef std::map<size_t, unsigned int> MapLightSourceTypeToLightID;
216 
217  //Mutable so it can protect const functions
218  mutable boost::mutex myMutableLightSourceTypeMutex;
219  };
220 }
DtLightManager * myLightManager
Definition: DtOsgLightManager.h:204
LightManager class which allows creation/deletion of lights.
Definition: DtLightManager.h:30
Virtual base class.
Definition: DtVirtualBaseClass.h:19
DtDe & myDe
Definition: DtOsgLightManager.h:191
MapLightSourceHashToLights myMapLightSourceHashToLights
Definition: DtOsgLightManager.h:209
DtOsgLightsObserver * myOsgLightsObserver
Definition: DtOsgLightManager.h:211
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Definition: featureContext.h:37
bool myPerPixelLightingEnabled
Definition: DtOsgLightManager.h:196
An OSG implementation of the sky.
Definition: DtOsgSkyObject.h:28
boost::unordered_map< size_t, LightSourceAndLight > MapLightSourceHashToLights
Definition: DtOsgLightManager.h:208
bool myInitialized
Definition: DtOsgLightManager.h:192
osg::observer_ptr< osg::StateSet > myStateSet
Definition: DtOsgLightManager.h:201
MapLightSourceTypeToLightID myLightSourceTypeMap
Definition: DtOsgLightManager.h:214
Light class.
LightType
Definition: DtLight.h:34
VectorLights myActiveLights
Definition: DtOsgLightManager.h:202
DtOsgLightManager receives LightSource nodes from the DtOsgCullVisitor, and collects them all here wh...
Definition: DtOsgLightManager.h:49
int myReservedID
Definition: DtOsgLightManager.h:194
bool myDebugCallbackInitialized
Definition: DtOsgLightManager.h:193
boost::mutex myMutableLightSourceTypeMutex
Definition: DtOsgLightManager.h:218
LightReusableVector myLightSourceTypeLightVector
Definition: DtOsgLightManager.h:215
Contains the DtOsgLightingComponent class.
Contains makVrv::DtReusableMemoryVector class.
Class for generic lights This holds per-light data such as range, attenuation factors, colors, etc.
Definition: DtLight.h:52
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
std::map< size_t, unsigned int > MapLightSourceTypeToLightID
Definition: DtOsgLightManager.h:213
Contains makVrv::DtOsgShaderManager class.
osg::ref_ptr< DtOsgLightingComponent > myLightingComponent
Definition: DtOsgLightManager.h:198
std::pair< const osg::LightSource *, const makVrv::DtLight * > LightSourceAndLight
Definition: DtOsgLightManager.h:206
State component that injects lighting shaders and uniforms into a state set.
Definition: DtOsgLightingComponent.h:62

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)