VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
15 
17 
19 #include <boost/unordered_map.hpp>
20 #include <boost/unordered_set.hpp>
21 
22 #include <osg/ref_ptr>
23 #include <osg/observer_ptr>
24 #include <osg/Node>
25 #include <osg/Light>
26 
27 class DtVector;
28 
29 namespace osg
30 {
31  class Light;
32  class LightSource;
33  class State;
34  class StateSet;
35  class Matrixd;
36 }
37 
38 namespace makVrv
39 {
40  // Implements GLSL lighting
41  class DtOsgLightingComponent;
42  class DtOsgLightsObserver;
43  class DtLightManager;
45 
46  typedef std::vector<DtLight> VectorLightObjects;
47 
53  {
54  public:
56  static DtOsgLightManager& instance(DtDe& de);
57 
59  virtual ~DtOsgLightManager();
60 
62  static std::string theClassName();
63 
65  static LightType getLightType(const osg::Light* light);
66 
69  void attachToStateSet(osg::StateSet* stateSet);
70 
72  void setPerPixelLightingEnabled(bool enabled);
73 
75  bool getPerPixelLightingEnabled() const;
76 
78  DtLightManager& lightManager();
79 
81  void setReservedID(int id);
82 
84  int reservedID() const;
85 
88  void cullReset();
89 
91  bool registerLight(const osg::LightSource* light, const osg::NodePath& nodePath, const osg::Matrixd& modelingMatrix, bool globalLights);
92 
93  void deregisterLight(const osg::LightSource* light);
94 
95  // PPP: TO DO. How to deregister ligths?
96 
98  void update(const osg::State& state, DtDe& de);
99 
101  void deactivateLights();
102 
103  int getTextureStartOffset(void) const;
104  const Vector2_uint32& GetTileSize(void) const;
105  const Vector2_uint32& GetGridMaxDims(void) const;
106 
107  void releaseGLObjects(void);
108 
109  protected:
110  DtOsgLightManager( DtDe& de );
111 
112  void updateLightOnOffStatus(DtDe& de, const VectorLights& lights);
113 
115  bool computeLightStatusForTime(DtDe& de, DtLight* pDtLight, DtOsgSkyObject* skyObject);
116 
117  void updateFixedFunctionLights(const osg::State& state);
118 
119  void updateShaderBasedLights(const osg::State& state, const VectorLights& lights);
120 
121  const VectorLights& computeFrustumLights(const osg::State &state);
122 
123  void proccessLightPath(DtLight* inLight, const osg::NodePath& nodePath);
124 
125  protected:
126  void configurePerPixelLighting(osg::StateSet*);
127  void setComponentVisualizationMode(int mode);
128 
129  void slot_reloadShader();
130 
131  protected:
132 
134 
138 
139  osg::ref_ptr<DtOsgLightingComponent> myLightingComponent;
140  osg::ref_ptr<osg::Uniform> myComponentDebugUniform;
142  osg::observer_ptr<osg::StateSet> myStateSet;
143  VectorLights myActiveLights;
144 
145  private:
147 
148 
149 
151 
152  typedef std::pair<const osg::LightSource*, const makVrv::DtLight*> LightSourceAndLight;
153 
154  typedef boost::unordered_map<size_t, LightSourceAndLight> MapLightSourceHashToLights;
156 
157  DtOsgLightsObserver* myOsgLightsObserver;
158 
159  bool existsInLightManager(const DtLight* light) const;
160  };
161 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)