VR-Forces 4.5 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 
13 
15 #include <boost/unordered_map.hpp>
16 
17 #include <osg/observer_ptr>
18 #include <osg/Node>
19 #include <osg/Light>
20 
21 #include <matrix/vlVector.h>
22 
23 namespace osg
24 {
25  class Light;
26  class LightSource;
27  class State;
28  class StateSet;
29  class Matrixd;
30 }
31 
32 namespace makVrv
33 {
34  // Implements GLSL lighting
35  class DtOsgLightingComponent;
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 
128 
132 
133  osg::ref_ptr<DtOsgLightingComponent> myLightingComponent;
134  osg::ref_ptr<osg::Uniform> myComponentDebugUniform;
136  osg::observer_ptr<osg::StateSet> myStateSet;
137  VectorLights myActiveLights;
138 
139  private:
141 
143 
144  typedef std::pair<const osg::LightSource*, const makVrv::DtLight*> LightSourceAndLight;
145 
146  typedef boost::unordered_map<size_t, LightSourceAndLight> MapLightSourceHashToLights;
148 
149  DtOsgLightsObserver* myOsgLightsObserver;
150 
151  bool existsInLightManager(const DtLight* light) const;
152  };
153 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)