VR-Forces 4.3 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 
43  class DtOsgLightsObserver;
44 
46 
47  typedef std::vector<DtLight> VectorLightObjects;
48 
54  {
55  public:
57  static DtOsgLightManager& instance(DtDe& de);
58 
60  virtual ~DtOsgLightManager();
61 
63  static std::string theClassName();
64 
66  static LightType getLightType(const osg::Light* light);
67 
70  void attachToStateSet(osg::StateSet* stateSet);
71 
73  void setPerPixelLightingEnabled(bool enabled);
74 
76  bool getPerPixelLightingEnabled() const;
77 
79  DtLightManager& lightManager();
80 
82  void setReservedID(int id);
83 
85  int reservedID() const;
86 
89  void cullReset();
90 
92  bool registerLight(const osg::LightSource* light, const osg::NodePath& nodePath, const osg::Matrixd& modelingMatrix, bool globalLights);
93 
94  void deregisterLight(const osg::LightSource* light);
95 
96  // PPP: TO DO. How to deregister ligths?
97 
99  void update(const osg::State& state, DtDe& de);
100 
102  void deactivateLights();
103 
104  int getTextureStartOffset(void) const;
105  const Vector2_uint32& GetTileSize(void) const;
106  const Vector2_uint32& GetGridMaxDims(void) const;
107 
108  void releaseGLObjects(void);
109 
110  protected:
111  DtOsgLightManager( DtDe& de );
112 
113  void updateLightOnOffStatus(void);
114 
115  void updateFixedFunctionLights(const osg::State& state);
116 
117  void updateShaderBasedLights(const osg::State& state);
118 
119  protected:
120  void configurePerPixelLighting(osg::StateSet*);
121  void setComponentVisualizationMode(int mode);
122 
123  void slot_reloadShader();
124 
125  protected:
126 
128 
132 
133  osg::ref_ptr<DtOsgLightingComponent> myLightingComponent;
134  osg::ref_ptr<osg::Uniform> myComponentDebugUniform;
136  osg::observer_ptr<osg::StateSet> myStateSet;
137 
138  private:
140 
142 
143  typedef std::pair<const osg::LightSource*, const makVrv::DtLight*> LightSourceAndLight;
144 
145  typedef boost::unordered_map<size_t, LightSourceAndLight> MapLightSourceHashToLights;
147 
148  // All lights encountered in the current cull pass
150 
151  DtOsgLightsObserver* myOsgLightsObserver;
152 
153  bool existsInLightManager(const DtLight* light) const;
154  };
155 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)