VR-Forces 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) 2022 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 
109  virtual void applyMatrixToLightPoints(const osg::Matrix& adjustmentMatrix);
110 
113  virtual void applyMatrixToLightPointsIncremental(const osg::Matrix& adjustmentMatrix,
114  int firstNodeToChange);
115 
116  virtual void setFadeParameters(const DtIndirectFadeParameters& fadeParameters);
117 
118  virtual DtIndirectFadeParameters fadeParameters() const;
119 
120  // Return number of light points in this node
121  virtual int lightPointCount() const;
122 
123  // Get the light point position for a particular light point
124  virtual osg::Vec3d lightPointPosition(int index) const;
125 
126  // set the light point position for a particular light point requires setDynamicLightsMode
127  virtual void setLightPointPosition(int index, const osg::Vec3d & pos);
128 
129  // Get the light point type
130  virtual int lightPointType(int index) const;
131 
132  // Get the light point node id
133  virtual int lightPointNodeId() const;
134 
135  // Get the light point group id
136  virtual int lightPointGroupId(int index) const;
137 
138  // Get the light point phase
139  virtual float lightPointPhase(int index) const;
140 
141  // Get the light point sector direction
142  virtual osg::Vec3 lightPointSectorDir(int index) const;
143 
144  // Get the light point sector transform
145  virtual const osg::Matrix3& lightPointSectorLocalToLp(int index) const;
146 
149  virtual void setCameraRelativeLightsMode( bool mode = true);
150  virtual bool cameraRelativeLightsMode( );
151 
152  protected:
155  {
156  public:
158  LightPointInfo(int type, std::string group, const osg::Vec3d& pos, const osg::Vec3& sectorDir,
159  const osg::Matrix3& sectorLocalToLp, float phase)
160  : myLightPointType(type)
161  , myLightPointGroup(group)
162  , myPosition(pos)
163  , mySectorLocalToLp(sectorLocalToLp)
164  , mySectorDir(sectorDir)
165  , myPhaseShift(phase)
166  , myActive(true)
167  {
168  /*intentionally nop*/
169  }
170 
172  std::string myLightPointGroup;
173  osg::Vec3d myPosition;
174  osg::Matrix3 mySectorLocalToLp;
175  osg::Vec3 mySectorDir;
177  bool myActive;
178  };
179 
180  typedef std::vector< LightPointInfo > LightPointIntList;
181 
186  virtual osg::BoundingSphere computeBoundsIncremental(int firstNode) const;
187 
188  protected:
189  mutable osg::BoundingBox myMutableBoundingBox; // Bounding box for all the points in the node
190  mutable osg::Vec3 myMutableFurthestPoint; // Used for incremental bounds calculations.
191 
193 
195 
197 
198  std::vector<int> myNodeIds;
199 
200  const osg::Camera* myLastCamera;
202 
205 
207 
209 
211 
213 
215 
216  std::vector<int> myFreeList;
217 
218 
219  protected:
220 
221  mutable boost::recursive_mutex myMutableNodeIdMutex;
222 
223  static int theFrameNum;
224  static const osg::Camera* theLastCamera;
225  };
226 }
DtOsgLightPointManager * myLightPointManager
Definition: DtLightPointNode.h:194
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::vector< LightPointInfo > LightPointIntList
Definition: DtLightPointNode.h:180
Definition: featureContext.h:37
boost::recursive_mutex myMutableNodeIdMutex
Definition: DtLightPointNode.h:221
int myFrameNum
Definition: DtLightPointNode.h:201
osg::Vec3d myPosition
Definition: DtLightPointNode.h:173
osg::Matrix3 mySectorLocalToLp
Definition: DtLightPointNode.h:174
bool myActive
Definition: DtLightPointNode.h:177
osg::Vec3 myMutableFurthestPoint
Definition: DtLightPointNode.h:190
std::string myLightPointGroup
Definition: DtLightPointNode.h:172
DtIndirectFadeParameters myFadeParameters
Definition: DtLightPointNode.h:210
static int theFrameNum
Definition: DtLightPointNode.h:223
osg::BoundingBox myMutableBoundingBox
Definition: DtLightPointNode.h:189
DtOsgLightPointManager registers LightPoint nodes so their TBO can be created and updated in a single...
Definition: DtOsgLightPointManager.h:128
int myCurrentInstance
Definition: DtLightPointNode.h:203
osg::Vec3 mySectorDir
Definition: DtLightPointNode.h:175
LightPointIntList myLightPointTypeList
Definition: DtLightPointNode.h:192
Contains makVrv::DtLightPointDrawable class.
std::vector< int > myFreeList
Definition: DtLightPointNode.h:216
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:158
int myGroupId
Definition: DtLightPointNode.h:208
static const osg::Camera * theLastCamera
Definition: DtLightPointNode.h:224
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:176
float myFirstFrameTime
Definition: DtLightPointNode.h:212
std::vector< osg::Node * > DtNodePointerStack
Definition: DtLightPointNode.h:27
const char int mode
Definition: ioapi.h:38
bool myCameraRelativeLightsMode
Definition: DtLightPointNode.h:214
bool myLightPointsEnabled
Definition: DtLightPointNode.h:206
structure for holding all the information required to describe a single light point.
Definition: DtLightPointNode.h:154
Contains DLL export macros.
int myLightPointType
Definition: DtLightPointNode.h:171
int myAddedInstances
Definition: DtLightPointNode.h:204
osg::ref_ptr< DtLightPointDrawable > myLightPointDrawable
Definition: DtLightPointNode.h:196
const osg::Camera * myLastCamera
Definition: DtLightPointNode.h:200
Contains makVrv::DtIndirectFadeParameters class.
std::vector< int > myNodeIds
Definition: DtLightPointNode.h:198

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)