VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometryRegistrar.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
17 
19 
21 
22 #include <osg/Node>
23 #include <osg/Geometry>
24 #include <osg/Texture>
25 #include <osg/Referenced>
26 
27 #include <tbb/concurrent_queue.h>
28 
29 #include <boost/signals.hpp>
30 
31 #include <string>
32 #include <vector>
33 
34 #define INDIRECTGEOMETRYREGISTRAR_DEBUG 0
35 
36 namespace osgEarth {
37  class VirtualProgram;
38 };
39 
40 namespace makVrv
41 {
42  class DtGlBuffer;
43 
44  class DtIndirectGeometryRegistrar;
45 
46  class DtIndirectTextureCollectionPolicy;
47 
48  class DtAggregatedGeometry;
49 
62 
66 
75 
88  {
89  public:
91  DtIndirectGeometryRegistrar(const DtIndirectTextureCollectionPolicy& textureCollectionPolicy);
92 
94  virtual ~DtIndirectGeometryRegistrar();
95 
96  // ! Thread safe methods
97  // ! This needs to be 'queued' up because the actual registration can happen when rebuild rebuildIfNeeded
98  // ! is called from somewhere in the main thread (e.g. via the drawImplementation of DtIndirectGeometry)
99  // \param modelId: The model id
100  // \param lodId: The lod id for the given model, with id as modelId (a model can have multiple lods)
101  // \param modelFileName is used only for debugging messages for the aggregator
102  virtual void queueUpRegisterModelLod(int modelId, int lodId, const DtLodInfo& lodInfo, osg::ref_ptr<const osg::Node> model, const std::string& modelFileName);
103 
105  virtual void rebuildIfNeeded(unsigned int contextID);
106 
108  virtual int numModels(void) const;
109 
111  virtual int modelId(int index) const;
112 
114  virtual const VectorGeometryLocations& getVectorGeometryLocations(int modelId) const;
115 
117  virtual bool hasVectorGeometryLocations(int modelId) const;
118 
120  virtual const VectorMaterials& getVectorMaterials(int modelId) const;
121 
123  virtual const VectorOsgTextures& getVectorOsgTextures(const int modelId) const;
124 
126 
127 
128 
129  virtual void bindBuffers();
130 
131  virtual void unbindBuffers();
133 
135  virtual const DtIndirectTextureCollectionPolicy& textureCollectionPolicy(void) const;
136 
138  virtual DtIndirectTextureProcessor &textureProcessor();
139 
140  virtual void releaseGLObjects(osg::State* state) const;
141 
143  static osgEarth::VirtualProgram * findCachedVirtualProgram(const std::string & vp_hash);
144  static void cacheVirtualProgram(const std::string & vp_hash, osgEarth::VirtualProgram * virtualProgram);
145 
146  public:
149  {
152  unsigned int contextID;
154  };
155 
157  typedef boost::signal< void(const RebuildResult& result) > RebuildSignal;
158 
162  protected:
165  virtual void registerModelLod(int modelId, int lodId, const DtLodInfo& lodInfo, osg::ref_ptr<const osg::Node> model, const std::string& modelFileName, VectorOsgTextures& newTexturesFound);
166 
168  virtual void deleteGpuData() const;
169 
171 
172  virtual void bindVAO();
173  virtual void unbindVAO();
175 
179  virtual bool allTexturesReady(const int modelId, unsigned int contextID) const;
180 
181 #if INDIRECTGEOMETRYREGISTRAR_DEBUG
182 
183  virtual void testDrawUsingDrawElements();
184 #endif
185 
186 
187 protected:
188  mutable GLuint myVAO;
189 
192 
194 
196  {
197  public:
198  RegisterModelLodOp() : myLodInfo(0, 0, 0), myModelId(0), myLodId(0)
199  {
200 
201  }
203  RegisterModelLodOp& operator=(const RegisterModelLodOp& rhs);
204  public:
206  int myLodId;
208  osg::ref_ptr<const osg::Node> myModel;
209  // used only for debugging messages
210  std::string myModelFileName;
211  };
212 
213  typedef tbb::concurrent_queue<RegisterModelLodOp> QueueRegisterModelLodOps;
215 
217 
218  typedef osg::ref_ptr<osgEarth::VirtualProgram> VirtualProgramRef;
219  typedef std::map<std::string, VirtualProgramRef> StringVpMap;
221 
223 
224 
225  private:
228  };
229 
232  {
233  public:
236 
239 
241  virtual DtIndirectGeometryRegistrar* create(DtIndirectTextureCollectionPolicy& textureCollectionPolicy) const;
242 
245  static DtIndirectGeometryRegistrarCreator& instance(DtDe& de);
246 
248  static const std::string& theClassName();
249  protected:
251  };
252 }

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)