VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtLightPointDrawable.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2019 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
15 #include <vrvCore/DtDe.h>
16 
18 
19 #include <osg/Drawable>
20 #include <osg/Vec3>
21 #include <osg/Vec4>
22 #include <osg/Depth>
23 #include <osg/BlendFunc>
24 #include <osg/BlendEquation>
25 #include <osg/ColorMask>
26 #include <osg/Point>
27 #include <osg/Endian>
28 #include <osg/Texture>
29 #include <osg/PointSprite>
30 #include <osgSim/Export>
31 
32 #include <vector>
33 
34 namespace makVrv
35 {
36 
37  class DtOsgLightPointManager;
38  class DtGlBuffer;
39 
52  class DT_DLL_VRVOSG DtLightPointDrawable : public osg::Drawable
53  {
54  public:
55 
62  {
63  int myType;
64  int myGroup;
65  int myNode;
66  float myPhase;
67  osg::Matrix3 mySectorLocalToLp;
68  osg::Vec3 myPos;
70  myType(-1),
71  myGroup(-1),
72  myNode(-1),
73  mySectorLocalToLp(),
74  myPhase(0.0),
75  myPos(0, 0, 0)
76  {
77  }
78 
79  LightPointVertexAttrib(int type, int groupId, int nodeId, const osg::Matrix3 &sectorLocalToLp, float phase, const osg::Vec3& pos) :
80  myType(type),
81  myGroup(groupId),
82  myNode(nodeId),
83  mySectorLocalToLp(sectorLocalToLp),
84  myPhase(phase),
85  myPos(pos)
86  {
87  }
88  };
89 
90  public:
91 
95 
97  DtLightPointDrawable(const DtLightPointDrawable&, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
98 
99  protected:
101  virtual ~DtLightPointDrawable();
102 
103  public:
106  virtual osg::Object* clone(const osg::CopyOp& copyop) const
107  {
108  return new DtLightPointDrawable(*this, copyop);
109  }
110  virtual osg::Object* cloneType() const
111  {
112  return NULL;
113  }
114  virtual bool isSameKindAs(const osg::Object* obj) const
115  {
116  return dynamic_cast<const DtLightPointDrawable *>(obj) != NULL;
117  }
118  virtual const char* className() const
119  {
120  return "DtLightPointDrawable";
121  }
122  virtual const char* libraryName() const
123  {
124  return "vrvOsg";
125  }
126  virtual void accept(osg::NodeVisitor& nv)
127  {
128  if (nv.validNodeMask(*this))
129  {
130  nv.pushOntoNodePath(this);
131  nv.apply(*this);
132  nv.popFromNodePath();
133  }
134  }
136 
137  public:
138 
140  virtual void releaseGLObjects(osg::State* state) const;
141 
143  virtual void accept(osg::PrimitiveFunctor &functor) const;
144 
148  virtual GLuint64 getTextureAddress(osg::Texture* myLightPointTexture);
149 
152  virtual void setLightPointManager(DtOsgLightPointManager *lpManager);
153 
155  virtual DtOsgLightPointManager *findLightPointManger();
156 
158  virtual void addLightPoint(const LightPointVertexAttrib& attribData);
159 
161  virtual void removeLightPoints(const std::vector<int>& nodeIds);
162 
164  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
166  virtual void setSimulationTime(double time);
167 
169  virtual double simulationTime() const;
170 
172  virtual osg::BoundingBox computeBoundingBox() const;
173 
174  protected:
175 
177  virtual void init();
178 
180  virtual void slot_reverseZChanged(bool flag);
181 
183  virtual void processTextureAddresses(osg::RenderInfo &renderInfo) const;
184 
185  // When we make a texture resident, add it to our map to make is non-resident
186  // when we releaseGLObjects
187  virtual void addTextureToGCMap(osg::GraphicsContext* gContext, osg::Texture::TextureObject* texObj) const;
188 
189  // Check if we have already added a texture id to our list of textures id index by graphics context
190  // if we have added already then return true
191  virtual bool inTextureToGCMap(osg::GraphicsContext* gContext, osg::Texture::TextureObject* texObj) const;
192 
193  protected:
194 
196 
197  typedef std::vector<LightPointVertexAttrib> LightPointList;
199 
203 
205 
206  //Texture for rendering the debug labels. Contains all 10 digits so that any number can be
207  // shown using the debug labels. The debug labels show the light point type for now.
209 
211 
213 
217 
219 
221 
222  //These need to be mutable so they can be upded in draw implementation.
223  typedef std::map< osg::ref_ptr<osg::Texture>, GLuint64> TextureToAddressMap;
225 
226  typedef std::set< osg::ref_ptr<osg::Texture> > TextureSet;
228 
229  // For keeping texture id's per context
230  typedef std::set<osg::ref_ptr<osg::Texture::TextureObject> > TexturesSet;
231  typedef std::map<osg::observer_ptr<const osg::GraphicsContext>, TexturesSet> MapGCToTexArray;
233 
235  };
236 
238  {
239  public:
242 
244  virtual ~DtLightPointDrawableCreator();
245 
247  virtual DtLightPointDrawable* create() const;
248 
251  static DtLightPointDrawableCreator& instance(DtDe& de);
252 
254  static const std::string& theClassName();
255  protected:
256 
258  };
259 
260 
261 }
262 
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
DtGLDeleteObjectManager & myGLManager
Definition: DtLightPointDrawable.h:234
Manager to delete GLBuffer in the main thread.
Definition: DtGlDeleteObjectManager.h:33
virtual const char * libraryName() const
Definition: DtLightPointDrawable.h:122
std::set< osg::ref_ptr< osg::Texture::TextureObject > > TexturesSet
Definition: DtLightPointDrawable.h:230
Virtual base class.
Definition: DtVirtualBaseClass.h:22
DtOsgLightPointManager * myLightPointManager
Definition: DtLightPointDrawable.h:204
DtDe & myDe
Definition: DtLightPointDrawable.h:210
virtual osg::Object * cloneType() const
Definition: DtLightPointDrawable.h:110
LightPointVertexAttrib()
Definition: DtLightPointDrawable.h:69
LightPointList myLightPointList
Definition: DtLightPointDrawable.h:198
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osg::Texture > myDigitTexture
Definition: DtLightPointDrawable.h:208
TextureSet myMutableTexturesToGetAddressesFor
Definition: DtLightPointDrawable.h:227
osg::Vec3 myPos
Definition: DtLightPointDrawable.h:68
Contains makVrv::DtDe class.
DtSignalConnectionManager mySignals
Definition: DtLightPointDrawable.h:214
std::map< osg::observer_ptr< const osg::GraphicsContext >, TexturesSet > MapGCToTexArray
Definition: DtLightPointDrawable.h:231
int myType
Definition: DtLightPointDrawable.h:63
double mySimulationTime
Definition: DtLightPointDrawable.h:195
osg::Matrix3 mySectorLocalToLp
Definition: DtLightPointDrawable.h:67
virtual void accept(osg::NodeVisitor &nv)
Definition: DtLightPointDrawable.h:126
DtOsgLightPointManager registers LightPoint nodes so their TBO can be created and updated in a single...
Definition: DtOsgLightPointManager.h:85
int myGroup
Definition: DtLightPointDrawable.h:64
osg::ref_ptr< osg::PointSprite > mySprite
Definition: DtLightPointDrawable.h:220
int myNode
Definition: DtLightPointDrawable.h:65
osg::ref_ptr< osg::BlendFunc > myBlendFunc
Definition: DtLightPointDrawable.h:201
Structure that matches the format of the data that is sent down as vertex attributes for the light po...
Definition: DtLightPointDrawable.h:61
std::map< osg::ref_ptr< osg::Texture >, GLuint64 > TextureToAddressMap
Definition: DtLightPointDrawable.h:223
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: DtLightPointDrawable.h:114
int myMutableLightPointListMinChanged
Definition: DtLightPointDrawable.h:215
osg::ref_ptr< osg::Depth > myDepthOn
Definition: DtLightPointDrawable.h:200
virtual osg::Object * clone(const osg::CopyOp &copyop) const
required functions for deriving from osg::Drawable couldn&#39;t use META_Node because it didn&#39;t compile ...
Definition: DtLightPointDrawable.h:106
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
LightPointVertexAttrib(int type, int groupId, int nodeId, const osg::Matrix3 &sectorLocalToLp, float phase, const osg::Vec3 &pos)
Definition: DtLightPointDrawable.h:79
float myPhase
Definition: DtLightPointDrawable.h:66
Class derived from osg::Drawable to handle all DtLightPointNode light points it gathers all the light...
Definition: DtLightPointDrawable.h:52
osg::ref_ptr< osg::Uniform > myTimeUniform
Definition: DtLightPointDrawable.h:212
Base class to provide boost signal/slot management.
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
MapGCToTexArray myMapGraphicsContextToTexturesArray
Definition: DtLightPointDrawable.h:232
Contains DLL export macros.
std::vector< LightPointVertexAttrib > LightPointList
Definition: DtLightPointDrawable.h:197
virtual const char * className() const
Definition: DtLightPointDrawable.h:118
std::set< osg::ref_ptr< osg::Texture > > TextureSet
Definition: DtLightPointDrawable.h:226
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
Definition: DtLightPointDrawable.h:237
DtDe & myDe
Definition: DtLightPointDrawable.h:257
int myMutableLightPointListMaxChanged
Definition: DtLightPointDrawable.h:216
TextureToAddressMap myMutableTextureToAddress
Definition: DtLightPointDrawable.h:224
bool myInitialized
Definition: DtLightPointDrawable.h:218
osg::ref_ptr< osg::BlendEquation > myBlendEquation
Definition: DtLightPointDrawable.h:202

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)