VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgLightingComponent.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
15 #include <osg/Uniform>
16 #include <vector>
17 
19 
20 namespace osg
21 {
22  class Matrixd;
23 }
24 
25 namespace makVrv
26 {
27  class DtLight;
28  class DtLightData;
29  class DtTileSpaceLightGrid;
30  class DtGLTexture;
31  class DtGLTextureBufferObject;
32 
33  class TextureApplyAttribute;
34  class TextureBufferObjectApplyAttribute;
35 
41  {
42  public:
44  DtOsgLightingComponent(int maxLights);
45 
47  virtual ~DtOsgLightingComponent();
48 
50  void update(const VectorLights& lights, const osg::State& state);
51 
53  void setMaxLights(int maxNumLights);
54 
55  static int getTextureStartOffset(void);
56 
57  const Vector2_uint32& GetTileSize(void) const;
58  const Vector2_uint32& GetGridMaxDims(void) const;
59 
60  public: // Access to internal uniforms
61 
63  osg::Uniform* getEnableLightingUniform() const;
64 
66  void setAmbientFactor(float ambientFactor);
67 
69  void setUseGlobalAmbient(bool useGlobalAmbient);
70 
72  void setDiffuseFactor(float diffuseFactor);
73 
75  void setUseGlobalDiffuse(bool useGlobalDiffuse);
76 
78  void setUseHDR(bool useHDR);
79 
81  void setDirty(bool isDirty) { myDirty = isDirty; }
82 
84  void setEmissionFactor(float emissionFactor);
85 
87  bool dirty() const { return myDirty; }
88 
89  void releaseGLObjects(void);
90 
91  public: // DtOsgStateComponent interface
92 
94  virtual bool install(osg::StateSet* stateset);
95 
97  virtual bool uninstall(osg::StateSet* stateset);
98 
99  protected:
100 
101  osg::ref_ptr<osg::Uniform> myEnableLightingUniform;
102 
103  std::vector<osg::Uniform*> myUniforms;
104 
105  // Parameters of lights are stored in this structure
107 
109  osg::ref_ptr<osg::Uniform> myLightTextureUniform;
110 
112 
114  osg::ref_ptr<osg::Uniform> myTileLightIndexListTextureUniform;
115 
117  osg::ref_ptr<osg::Uniform> myTileLightGridCountOffsetsTextureUniform;
118 
120  osg::ref_ptr<osg::Uniform> myColorRampTextureUniform;
121 
122  osg::ref_ptr<TextureApplyAttribute> myTextureApplyAttribute;
123  osg::ref_ptr<TextureBufferObjectApplyAttribute> myTextureBufferObjectApplyAttribute;
124 
125  osg::ref_ptr<osg::Uniform> myProjectionMatrixUniform;
126  osg::ref_ptr<osg::Uniform> myViewportSizeUniform;
127 
128  osg::ref_ptr<osg::Uniform> myLightGridTileDimUniform;
129  osg::ref_ptr<osg::Uniform> myLightGridMaxDimUniform;
130 
131  osg::ref_ptr<osg::Uniform> myAmbientFactorUniform;
133  osg::ref_ptr<osg::Uniform> myDiffuseFactorUniform;
135  bool myUseHDR;
136  bool myDirty;
137  osg::ref_ptr<osg::Uniform> myEmissionFactorUniform;
138 
139  osg::Uniform* createUniform(const std::string& name, osg::Uniform::Type type, int count=1);
140 
141  void PackLights(const VectorLights& lights
142  , const osg::State& state);
143  void UpdateTextureLightDataGrid(void);
144  void UpdateTiledShadingData(const VectorLights& lights
145  , const osg::State& state);
146 
147  void UpdateTileLightIndexListTexture();
148  void UpdateTileLightGridCountOffsetsTexture();
149 
151 
154 
156 
158  };
159 }

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)