VR-Forces 4.3 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 setUseMaterialAmbient(bool useMaterialAmbient);
70 
72  void setDiffuseFactor(float diffuseFactor);
73 
75  void setUseMaterialDiffuse(bool useMaterialDiffuse);
76 
78  void setUseHDR(bool useHDR);
79 
81  void setDirty(bool isDirty) { myDirty = isDirty; }
82 
84  bool dirty() const { return myDirty; }
85 
86  void releaseGLObjects(void);
87 
88  public: // DtOsgStateComponent interface
89 
91  virtual bool install(osg::StateSet* stateset);
92 
94  virtual bool uninstall(osg::StateSet* stateset);
95 
96  protected:
97 
98  osg::ref_ptr<osg::Uniform> myEnableLightingUniform;
99 
100  std::vector<osg::Uniform*> myUniforms;
101 
102  // Parameters of lights are stored in this structure
104 
106  osg::ref_ptr<osg::Uniform> myLightTextureUniform;
107 
109 
111  osg::ref_ptr<osg::Uniform> myTileLightIndexListTextureUniform;
112 
114  osg::ref_ptr<osg::Uniform> myTileLightGridCountOffsetsTextureUniform;
115 
117  osg::ref_ptr<osg::Uniform> myColorRampTextureUniform;
118 
119  osg::ref_ptr<TextureApplyAttribute> myTextureApplyAttribute;
120  osg::ref_ptr<TextureBufferObjectApplyAttribute> myTextureBufferObjectApplyAttribute;
121 
122  osg::ref_ptr<osg::Uniform> myProjectionMatrixUniform;
123  osg::ref_ptr<osg::Uniform> myViewportSizeUniform;
124 
125  osg::ref_ptr<osg::Uniform> myLightGridTileDimUniform;
126  osg::ref_ptr<osg::Uniform> myLightGridMaxDimUniform;
127 
128  osg::ref_ptr<osg::Uniform> myAmbientFactorUniform;
130  osg::ref_ptr<osg::Uniform> myDiffuseFactorUniform;
132  bool myUseHDR;
133  bool myDirty;
134 
135  osg::Uniform* createUniform(const std::string& name, osg::Uniform::Type type, int count=1);
136 
137  void PackLights(const VectorLights& lights
138  , const osg::State& state);
139  void UpdateTextureLightDataGrid(void);
140  void UpdateTiledShadingData(const VectorLights& lights
141  , const osg::State& state);
142 
143  void UpdateTileLightIndexListTexture();
144  void UpdateTileLightGridCountOffsetsTexture();
145 
147 
150 
152 
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)