VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtLightPointNode.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 
11 #include <vrvOsg/vrvOsg.h>
12 
14 
16 
17 #include <boost/thread/recursive_mutex.hpp>
18 
19 namespace osgUtil
20 {
21  class CullVisitor;
22 }
23 
24 namespace makVrv
25 {
26  class DtDe;
28 
29  typedef std::vector<osg::Node*> DtNodePointerStack;
30 
37  class DT_DLL_VRVOSG DtLightPointNode : public osg::Node
38  {
39  public:
40 
43 
45  DtLightPointNode(const DtLightPointNode& lpn, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
46 
48  virtual ~DtLightPointNode();
49 
50  META_Node(vrvOsg, DtLightPointNode);
51 
52  private:
54  DtLightPointNode& operator=(const DtLightPointNode& other) = delete;
55 
56  public:
58  virtual void traverse(osg::NodeVisitor& nv);
59 
63  virtual void updateDrawable(const osg::Camera* camera, int frameNum, double simTime, const osg::Matrixd &modelViewMatrix,
64  osgUtil::CullVisitor* cv, int groupId, bool shouldCull, const DtIndirectFadeParameters& fadeParameters, float posScale, float radiusScale, bool isInstancedReflection = false);
65 
67  virtual void updateNodeInfo(bool isInstancedReflection = false, bool isForcedAdd = false);
68 
74  virtual int addTypedLightPoint(const osg::Vec3d& pos, int type, const std::string& id,
75  const osg::Vec3& rotation, float phaseShift);
76 
79  virtual void removeTypedLightPoint(int index);
80 
82  virtual void setLightPointManager(DtOsgLightPointManager *lightPointManager);
83 
85  virtual DtOsgLightPointManager *findLightPointManager();
86 
88  virtual void setLightPointsEnabled(bool enabled);
89 
91  virtual bool lightPointsEnabled();
92 
94  virtual void setGroupId(int id);
95 
97  virtual int groupId();
98 
102  virtual void freeNodeIdIfNecessary(unsigned int maxNodeIds);
103 
105  virtual osg::BoundingSphere computeBound() const;
106 
108  virtual void setLightPointTexture(osg::Texture* texture);
109 
111  virtual void releaseGLObjects(osg::State* state = 0) const;
112 
115  virtual void applyMatrixToLightPoints(const osg::Matrix& adjustmentMatrix);
116 
119  virtual void applyMatrixToLightPointsIncremental(const osg::Matrix& adjustmentMatrix,
120  int firstNodeToChange);
121 
122  virtual void setFadeParameters(const DtIndirectFadeParameters& fadeParameters);
123 
124  virtual DtIndirectFadeParameters fadeParameters() const;
125 
126  // Return number of light points in this node
127  virtual int lightPointCount() const;
128 
129  // Get the light point position for a particular light point
130  virtual osg::Vec3d lightPointPosition(int index) const;
131 
132  // set the light point position for a particular light point requires setDynamicLightsMode
133  virtual void setLightPointPosition(int index, const osg::Vec3d & pos);
134 
135  // Get the light point type
136  virtual int lightPointType(int index) const;
137 
138  // Get the light point node id
139  virtual int lightPointNodeId() const;
140 
141  // Get the light point group id
142  virtual int lightPointGroupId(int index) const;
143 
144  // Get the light point phase
145  virtual float lightPointPhase(int index) const;
146 
147  // Get the light point sector direction
148  virtual osg::Vec3 lightPointSectorDir(int index) const;
149 
150  // Get the light point sector transform
151  virtual const osg::Matrix3& lightPointSectorLocalToLp(int index) const;
152 
155  virtual void setCameraRelativeLightsMode( bool mode = true);
156  virtual bool cameraRelativeLightsMode( );
157 
158  protected:
161  {
162  public:
164  LightPointInfo(int type, std::string group, const osg::Vec3d& pos, const osg::Vec3& sectorDir,
165  const osg::Matrix3& sectorLocalToLp, float phase)
166  : myLightPointType(type)
167  , myLightPointGroup(group)
168  , myPosition(pos)
169  , mySectorLocalToLp(sectorLocalToLp)
170  , mySectorDir(sectorDir)
171  , myPhaseShift(phase)
172  , myActive(true)
173  {
174  /*intentionally nop*/
175  }
176 
178  std::string myLightPointGroup;
179  osg::Vec3d myPosition;
180  osg::Matrix3 mySectorLocalToLp;
181  osg::Vec3 mySectorDir;
183  bool myActive;
184  };
185 
186  typedef std::vector< LightPointInfo > LightPointIntList;
187 
192  virtual osg::BoundingSphere computeBoundsIncremental(int firstNode) const;
193 
194  protected:
195  mutable osg::BoundingBox myMutableBoundingBox; // Bounding box for all the points in the node
196  mutable osg::Vec3 myMutableFurthestPoint; // Used for incremental bounds calculations.
197 
199 
201 
203 
204  std::vector<int> myNodeIds;
205 
206  const osg::Camera* myLastCamera;
208 
211 
213 
215 
217  //needs to be mutable so that the texture id can be cleared in release gl objects.
218  mutable GLuint64 myMutableTextureId;
219 
221 
223 
225 
226  std::vector<int> myFreeList;
227 
228 
229  protected:
230 
231  mutable boost::recursive_mutex myMutableNodeIdMutex;
232 
233  static int theFrameNum;
234  static const osg::Camera* theLastCamera;
235  };
236 }
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
GLuint64 myMutableTextureId
Definition: DtLightPointNode.h:218
DtOsgLightPointManager * myLightPointManager
Definition: DtLightPointNode.h:200
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::vector< LightPointInfo > LightPointIntList
Definition: DtLightPointNode.h:186
Definition: featureContext.h:37
boost::recursive_mutex myMutableNodeIdMutex
Definition: DtLightPointNode.h:231
int myFrameNum
Definition: DtLightPointNode.h:207
osg::Vec3d myPosition
Definition: DtLightPointNode.h:179
osg::Matrix3 mySectorLocalToLp
Definition: DtLightPointNode.h:180
bool myActive
Definition: DtLightPointNode.h:183
osg::Vec3 myMutableFurthestPoint
Definition: DtLightPointNode.h:196
std::string myLightPointGroup
Definition: DtLightPointNode.h:178
DtIndirectFadeParameters myFadeParameters
Definition: DtLightPointNode.h:220
static int theFrameNum
Definition: DtLightPointNode.h:233
osg::BoundingBox myMutableBoundingBox
Definition: DtLightPointNode.h:195
DtOsgLightPointManager registers LightPoint nodes so their TBO can be created and updated in a single...
Definition: DtOsgLightPointManager.h:106
int myCurrentInstance
Definition: DtLightPointNode.h:209
osg::Vec3 mySectorDir
Definition: DtLightPointNode.h:181
LightPointIntList myLightPointTypeList
Definition: DtLightPointNode.h:198
Contains makVrv::DtLightPointDrawable class.
std::vector< int > myFreeList
Definition: DtLightPointNode.h:226
LightPointInfo(int type, std::string group, const osg::Vec3d &pos, const osg::Vec3 &sectorDir, const osg::Matrix3 &sectorLocalToLp, float phase)
constructor for filling the structure with data
Definition: DtLightPointNode.h:164
osg::ref_ptr< osg::Texture > myLightPointTexture
Definition: DtLightPointNode.h:216
int myGroupId
Definition: DtLightPointNode.h:214
static const osg::Camera * theLastCamera
Definition: DtLightPointNode.h:234
struct for holding the fade parameters used by the indirect rendering cull compute shader ...
Definition: DtIndirectFadeParameters.h:17
Derived from osg::Node and is a replacement for the osgSim::LightPointNode represents a group of ligh...
Definition: DtLightPointNode.h:37
float myPhaseShift
Definition: DtLightPointNode.h:182
float myFirstFrameTime
Definition: DtLightPointNode.h:222
std::vector< osg::Node * > DtNodePointerStack
Definition: DtLightPointNode.h:27
const char int mode
Definition: ioapi.h:38
bool myCameraRelativeLightsMode
Definition: DtLightPointNode.h:224
bool myLightPointsEnabled
Definition: DtLightPointNode.h:212
structure for holding all the information required to describe a single light point.
Definition: DtLightPointNode.h:160
Contains DLL export macros.
int myLightPointType
Definition: DtLightPointNode.h:177
int myAddedInstances
Definition: DtLightPointNode.h:210
osg::ref_ptr< DtLightPointDrawable > myLightPointDrawable
Definition: DtLightPointNode.h:202
const osg::Camera * myLastCamera
Definition: DtLightPointNode.h:206
Contains makVrv::DtIndirectFadeParameters class.
std::vector< int > myNodeIds
Definition: DtLightPointNode.h:204

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)