VR-Forces 5.0.1 Developer's Guide
 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) 2022 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 
163 
165  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
167  virtual void setSimulationTime(double time);
168 
170  virtual double simulationTime() const;
171 
173  virtual osg::BoundingBox computeBoundingBox() const;
174 
175  protected:
176 
178  virtual void init();
179 
181  virtual void setUpReverseZ(bool flag);
182 
184  virtual void processTextureAddresses(osg::RenderInfo &renderInfo) const;
185 
186  // When we make a texture resident, add it to our map to make is non-resident
187  // when we releaseGLObjects
188  virtual void addTextureToGCMap(osg::GraphicsContext* gContext, osg::Texture::TextureObject* texObj) const;
189 
190  // Check if we have already added a texture id to our list of textures id index by graphics context
191  // if we have added already then return true
192  virtual bool inTextureToGCMap(osg::GraphicsContext* gContext, osg::Texture::TextureObject* texObj) const;
193 
194  protected:
195 
197 
198  typedef std::vector<LightPointVertexAttrib> LightPointList;
200 
204 
206 
207  //Texture for rendering the debug labels. Contains all 10 digits so that any number can be
208  // shown using the debug labels. The debug labels show the light point type for now.
210 
212 
214 
218 
220 
222 
223  //These need to be mutable so they can be upded in draw implementation.
224  typedef std::map< osg::ref_ptr<osg::Texture>, GLuint64> TextureToAddressMap;
226 
227  typedef std::set< osg::ref_ptr<osg::Texture> > TextureSet;
229 
230  // For keeping texture id's per context
231  typedef std::set<osg::ref_ptr<osg::Texture::TextureObject> > SetOsgTextureObjects;
232  typedef std::map<osg::observer_ptr<const osg::GraphicsContext>, SetOsgTextureObjects> MapGraphicsContextsToSetOsgTextureObjects;
234 
236  };
237 
239  {
240  public:
243 
245  virtual ~DtLightPointDrawableCreator();
246 
248  virtual DtLightPointDrawable* create() const;
249 
252  static DtLightPointDrawableCreator& instance(DtDe& de);
253 
255  static const std::string& theClassName();
256  protected:
257 
259  };
260 
261 
262 }
263 
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
virtual const char * libraryName() const
Definition: DtLightPointDrawable.h:122
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
DtOsgLightPointManager * myLightPointManager
Definition: DtLightPointDrawable.h:205
DtDe & myDe
Definition: DtLightPointDrawable.h:211
virtual osg::Object * cloneType() const
Definition: DtLightPointDrawable.h:110
LightPointVertexAttrib()
Definition: DtLightPointDrawable.h:69
LightPointList myLightPointList
Definition: DtLightPointDrawable.h:199
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osg::Texture > myDigitTexture
Definition: DtLightPointDrawable.h:209
TextureSet myMutableTexturesToGetAddressesFor
Definition: DtLightPointDrawable.h:228
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtLightPointDrawable.h:235
osg::Vec3 myPos
Definition: DtLightPointDrawable.h:68
Contains makVrv::DtDe class.
DtSignalConnectionManager mySignals
Definition: DtLightPointDrawable.h:215
MapGraphicsContextsToSetOsgTextureObjects myMapGraphicsContextToTexturesArray
Definition: DtLightPointDrawable.h:233
int myType
Definition: DtLightPointDrawable.h:63
double mySimulationTime
Definition: DtLightPointDrawable.h:196
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:106
int myGroup
Definition: DtLightPointDrawable.h:64
osg::ref_ptr< osg::PointSprite > mySprite
Definition: DtLightPointDrawable.h:221
int myNode
Definition: DtLightPointDrawable.h:65
osg::ref_ptr< osg::BlendFunc > myBlendFunc
Definition: DtLightPointDrawable.h:202
std::set< osg::ref_ptr< osg::Texture::TextureObject > > SetOsgTextureObjects
Definition: DtLightPointDrawable.h:231
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:224
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: DtLightPointDrawable.h:114
int myMutableLightPointListMinChanged
Definition: DtLightPointDrawable.h:216
osg::ref_ptr< osg::Depth > myDepthOn
Definition: DtLightPointDrawable.h:201
Manager to delete GL object in the main thread.
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:20
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
std::map< osg::observer_ptr< const osg::GraphicsContext >, SetOsgTextureObjects > MapGraphicsContextsToSetOsgTextureObjects
Definition: DtLightPointDrawable.h:232
osg::ref_ptr< osg::Uniform > myTimeUniform
Definition: DtLightPointDrawable.h:213
Base class to provide boost signal/slot management.
Manager to delete GLBuffer in the main thread.
Definition: DtGlDeleteObjectManager.h:44
Contains DLL export macros.
std::vector< LightPointVertexAttrib > LightPointList
Definition: DtLightPointDrawable.h:198
virtual const char * className() const
Definition: DtLightPointDrawable.h:118
std::set< osg::ref_ptr< osg::Texture > > TextureSet
Definition: DtLightPointDrawable.h:227
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
Definition: DtLightPointDrawable.h:238
DtDe & myDe
Definition: DtLightPointDrawable.h:258
int myMutableLightPointListMaxChanged
Definition: DtLightPointDrawable.h:217
TextureToAddressMap myMutableTextureToAddress
Definition: DtLightPointDrawable.h:225
bool myInitialized
Definition: DtLightPointDrawable.h:219
osg::ref_ptr< osg::BlendEquation > myBlendEquation
Definition: DtLightPointDrawable.h:203

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)