VR-Forces 4.7 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) 2013 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 
24 namespace osg
25 {
26  class Light;
27  class LightSource;
28  class State;
29  class StateSet;
30  class Matrixd;
31 }
32 
33 namespace makVrv
34 {
35  // Implements GLSL lighting
36  class DtOsgLightsObserver;
37  class DtLightManager;
39 
40  typedef std::vector<DtLight> VectorLightObjects;
41 
47  {
48  public:
50  static DtOsgLightManager& instance(DtDe& de);
51 
53  virtual ~DtOsgLightManager();
54 
56  static const std::string& theClassName();
57 
59  static LightType getLightType(const osg::Light* light);
60 
63  void attachToStateSet(osg::StateSet* stateSet);
64 
66  void setPerPixelLightingEnabled(bool enabled);
67 
69  bool getPerPixelLightingEnabled() const;
70 
72  DtLightManager& lightManager();
73 
75  void setReservedID(int id);
76 
78  int reservedID() const;
79 
82  void cullReset();
83 
85  bool registerLight(const osg::LightSource* light, const osg::NodePath& nodePath, const osg::Matrixd& modelingMatrix, bool globalLights);
86 
87  void deregisterLight(const osg::LightSource* light);
88 
89  // PPP: TO DO. How to deregister ligths?
90 
92  void update(const osg::State& state, DtDe& de);
93 
95  void deactivateLights();
96 
97  int getTextureStartOffset(void) const;
98  const Vector2_uint32& GetTileSize(void) const;
99  const Vector2_uint32& GetGridMaxDims(void) const;
100 
101  void releaseGLObjects(void);
102 
103  protected:
104  DtOsgLightManager( DtDe& de );
105 
106  void updateLightOnOffStatus(DtDe& de, const VectorLights& lights);
107 
109  bool computeLightStatusForTime(DtDe& de, DtLight* pDtLight, DtOsgSkyObject* skyObject);
110 
111  void updateFixedFunctionLights(const osg::State& state);
112 
113  void updateShaderBasedLights(const osg::State& state, const VectorLights& lights);
114 
115  const VectorLights& computeFrustumLights(const osg::State &state);
116 
117  void proccessLightPath(DtLight* inLight, const osg::NodePath& nodePath);
118 
119  protected:
120  void configurePerPixelLighting(osg::StateSet*);
121  void setComponentVisualizationMode(int mode);
122 
123  void slot_reloadShader();
124 
125  protected:
126 
130 
131  osg::ref_ptr<DtOsgLightingComponent> myLightingComponent;
132  osg::ref_ptr<osg::Uniform> myComponentDebugUniform;
134  osg::observer_ptr<osg::StateSet> myStateSet;
135  VectorLights myActiveLights;
136 
137  private:
139 
141 
142  typedef std::pair<const osg::LightSource*, const makVrv::DtLight*> LightSourceAndLight;
143 
144  typedef boost::unordered_map<size_t, LightSourceAndLight> MapLightSourceHashToLights;
146 
147  DtOsgLightsObserver* myOsgLightsObserver;
148 
149  bool existsInLightManager(const DtLight* light) const;
150  };
151 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)