VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgCullVisitorParameters.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2020 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
13 
14 #pragma once
15 
16 #include <osg/BoundingBox>
17 #include <osg/BoundingSphere>
18 #include <osg/Vec2>
19 #include <osgUtil/CullVisitor>
20 
22 
23 #include <vrvOsg/DtModelScaler.h>
24 
25 #include <matrix/vlMath.h>
26 #include <algorithm>
27 #include <math.h>
28 
29 #ifdef min
30 #undef min
31 #endif
32 
33 namespace makVrv
34 {
38  class DT_DLL_VRVOSG DtOsgCullVisitorParameters : public osg::Referenced
39  {
40  public:
41 
44  : osg::Referenced()
45  , mySkyFlag(true)
46  , myDynamicLightsFlag(true)
47  , myDynamicOceanFlag(true)
48  , myOrthoFlag(false)
49  , myCameraResolution( 1.0 )
50  , myTerrainRadius( 1.0 )
51  , myScalingFlag( true )
52  , myClampedPixelSize( 1.0 )
53  , myLodScaleFactor( 1.0 )
54  , myCoordinateSystemChanged( false )
55  , myAltitude2D( 0. )
56  , myAltitude3D( 0. )
57  , myDynamicWaterVisibilityEnable(true)
58  , myDynamicWaterVisibilityMax(75.)
59  , myModelScaler( 0 )
60  , myTerrainMagnificationHighLodAngle(DtDeg2Rad(15))
61  , myTerrainMagnificationScaleFactor(1.)
62  , myCameraVelocity( 0, 0, 0 )
63  , myModelSet(0)
64  , myIncludeLightPoints(true)
65  , myCurrentScaleFactor(1.0)
66  , myIndirectDistScaleEnabled(false)
67  , myIndirectDistScale(1.0)
68  , myChannelLodScale(1.0)
69  , myFocusPointEnabled(false)
70  , myFocusPoints()
71  {
72 
73  //Intentional nop
74  }
75 
78  inline void setLodScaleFactor( double sf )
79  {
80  myLodScaleFactor = sf;
81  }
82 
84  inline double lodScaleFactor() const
85  {
86  return myLodScaleFactor;
87  }
88 
90  void setCameraResolution(double factor)
91  {
92  myCameraResolution = factor;
93  }
94 
96  inline double cameraResolution() const
97  {
98  return myCameraResolution;
99  }
101  void setCameraVelocity(double x, double y, double z)
102  {
103  myCameraVelocity = osg::Vec3d(x,y,z);
104  }
105 
107  inline const osg::Vec3d& cameraVelocity() const
108  {
109  return myCameraVelocity;
110  }
111 
113  void setTerrainRadius(double rad)
114  {
115  myTerrainRadius = rad;
116  }
117 
119  void setAltitude2D( double altitude )
120  {
121  myAltitude2D = altitude;
122  }
123 
125  double altitude2D() const
126  {
127  return myAltitude2D;
128  }
129 
131  inline unsigned int modelSet() const
132  {
133  return myModelSet;
134  }
135 
137  void setModelSet(unsigned int modelSet)
138  {
139  myModelSet = modelSet;
140  }
141 
143  inline double terrainRadius() const
144  {
145  return myTerrainRadius;
146  }
147 
149  void setOrthoCulling(bool ortho)
150  {
151  myOrthoFlag = ortho;
152  }
153 
155  inline bool orthoCulling() const
156  {
157  return myOrthoFlag;
158  }
159 
161  inline void setSkyRendering(bool renderSky)
162  {
163  mySkyFlag = renderSky;
164 
165  }
166 
168  inline bool skyRendering() const
169  {
170  return mySkyFlag;
171  }
172 
174  inline void setDynamicLights(bool enabled)
175  {
176  myDynamicLightsFlag = enabled;
177  }
178 
180  inline bool dynamicLights() const
181  {
182  return myDynamicLightsFlag;
183  }
184 
186  inline void setDynamicOcean(bool enabled)
187  {
188  myDynamicOceanFlag = enabled;
189  }
190 
192  inline bool dynamicOcean() const
193  {
194  return myDynamicOceanFlag;
195  }
196 
198  void setScaling( bool scaling )
199  {
200  myScalingFlag = scaling;
201  }
202 
204  inline bool scaling() const
205  {
206  return myScalingFlag;
207  }
208 
210  void setCoordinateSystemChanged( bool changed )
211  {
212  myCoordinateSystemChanged = changed;
213  }
214 
216  inline bool coordinateSystemChanged() const
217  {
218  return myCoordinateSystemChanged;
219  }
220 
223  inline void setModelScaler( DtModelScaler* scaler )
224  {
225  myModelScaler = scaler;
226  }
227 
229  {
230  return myModelScaler;
231  }
232 
234  inline double calculateModelScale( const osg::Camera& camera,
235  const osg::Node& node ) const
236  {
237  if ( myModelScaler.valid() )
238  {
239  return myModelScaler->calculateScale( *this, camera, node );
240  }
241  else
242  {
243  return 1.;
244  }
245  }
246 
247  // This form is used by the DtInstanceScalingProcessor
248  inline double calculateScale(const osg::Camera& camera, const osg::Vec3d& position,
249  double modelRadius, DtUniqueID objectElementId) const
250  {
251  if (myModelScaler.valid())
252  {
253  return myModelScaler->calculateScale(*this, camera, position, modelRadius, objectElementId);
254  }
255  else
256  {
257  return 1.;
258  }
259  }
260 
265  void setClampedPixelSize(double d)
266  {
267  myClampedPixelSize = d;
268  }
269 
271  double clampedPixelSize() const
272  {
273  return myClampedPixelSize;
274  }
275 
279  inline void setDynamicWaterVisibilityEnable( bool enable )
280  {
281  myDynamicWaterVisibilityEnable = enable;
282  }
283 
285  inline bool dynamicWaterVisibilityEnable() const
286  {
287  return myDynamicWaterVisibilityEnable;
288  }
289 
292  inline void setDynamicWaterVisibilityMax( double visMax )
293  {
294  myDynamicWaterVisibilityMax = visMax;
295  }
296 
299  inline double dynamicWaterVisibilityMax() const
300  {
301  return myDynamicWaterVisibilityMax;
302  }
303 
306  inline void setTerrainMagnificationScaleFactor(float factor)
307  {
308  myTerrainMagnificationScaleFactor = factor;
309  }
310 
313  inline float terrainMagnificationScaleFactor() const
314  {
315  return myTerrainMagnificationScaleFactor;
316  }
317 
324  inline void setTerrainMagnificationHighLodAngle(float radians)
325  {
326  myTerrainMagnificationHighLodAngle = radians;
327  }
328 
333  inline float terrainMagnificationHighLodAngle() const
334  {
335  return myTerrainMagnificationHighLodAngle;
336  }
337 
339  inline void setIncludeLightPoints(bool flag)
340  {
341  myIncludeLightPoints = flag;
342  }
343 
345  inline bool includeLightPoints() const
346  {
347  return myIncludeLightPoints;
348  }
349 
353  {
354  return myCurrentScaleFactor;
355  }
356 
359  inline void setCurrentTraversalScaleFactor(float currentScaleFactor)
360  {
361  myCurrentScaleFactor = currentScaleFactor;
362  }
363 
365  inline void setIndirectDistanceScaleEnabled(bool enabled)
366  {
367  myIndirectDistScaleEnabled = enabled;
368  }
369 
371  inline bool indirectDistanceScaleEnabled() const
372  {
373  return myIndirectDistScaleEnabled;
374  }
375 
377  inline void setIndirectDistanceScale(float scale)
378  {
379  myIndirectDistScale = scale;
380  }
381 
383  inline float indirectDistanceScale() const
384  {
385  return myIndirectDistScale;
386  }
387 
389  inline void setChannelLodScale(float scale)
390  {
391  myChannelLodScale = scale;
392  }
393 
395  inline float channelLodScale()
396  {
397  return myChannelLodScale;
398  }
399 
402  inline void setFocusPoints(std::vector<osg::Vec3d>& points)
403  {
404  myFocusPoints = points;
405  }
406 
409  inline std::vector<osg::Vec3d>& focusPoints()
410  {
411  return myFocusPoints;
412  }
413 
416  inline void setFocusPointEnabled(bool enable)
417  {
418  myFocusPointEnabled = enable;
419  }
420 
423  inline bool focusPointEnabled()
424  {
425  return myFocusPointEnabled;
426  }
427 
428  protected:
429 
433  double myAltitude2D;
434  double myAltitude3D;
435  bool mySkyFlag;
447  osg::Vec3d myCameraVelocity;
448  unsigned int myModelSet;
453  std::vector<osg::Vec3d> myFocusPoints;
454 
457  };
458 
461  class DT_DLL_VRVOSG DtOsgFixedScaleParameters : public osg::Referenced
462  {
463  public:
465  : myFixedPixelSize( 1.0 )
466  , myLength( 0.0 )
467  , myWidth( 0.0 )
468  , myHeight( 0.0 )
469  , myScaleX(true)
470  , myScaleY(true)
471  , myScaleZ(true)
472  {
473 }
474 
476  {
477  }
478 
479  void setFixedPixelSize(double d)
480  {
481  myFixedPixelSize = d;
482  }
483 
484  double fixedPixelSize() const
485  {
486  return myFixedPixelSize;
487  }
488 
489  void setDimensions(double length, double width, double height)
490  {
491  myLength = length; myWidth = width; myHeight = height;
492  }
493 
494  inline double length() const
495  {
496  return myLength;
497  }
498 
499  inline double width() const
500  {
501  return myWidth;
502  }
503 
504  inline double height() const
505  {
506  return myHeight;
507  }
508 
509  inline void calculateScaleFactors(const osgUtil::CullVisitor& visitor,
510  const osg::BoundingSphere& sphere, DtOsgCullVisitorParameters* info,
511  double& scaleFactorX, double& scaleFactorY, double& scaleFactorZ) const
512  {
513  double clampedSize =
514  visitor.clampedPixelSize( sphere.center(), info->terrainRadius() );
515  info->setClampedPixelSize(clampedSize);
516 
517  calculateScaleFactors( sphere, *info, scaleFactorX,
518  scaleFactorY, scaleFactorZ );
519  }
520 
521  inline void calculateScaleFactors(const osg::BoundingSphere& sphere, const DtOsgCullVisitorParameters& info,
522  double& scaleFactorX, double& scaleFactorY, double& scaleFactorZ) const
523  {
524  scaleFactorX = scaleFactorY = scaleFactorZ = 1.0;
525 
526  double metersPerPixel = info.terrainRadius() / info.clampedPixelSize(); // Meters per pixel
527  double curPixels = myWidth / metersPerPixel; // Pixels needed to draw
528 
529  if (myScaleX)
530  {
531  scaleFactorX = myFixedPixelSize / curPixels;
532  }
533 
534  if (myScaleY)
535  {
536  scaleFactorY = scaleFactorX;
537  }
538 
539  if (myScaleX)
540  {
541  scaleFactorZ = 1.0;
542  }
543  }
544 
545  void setScaleX(bool b)
546  {
547  myScaleX = b;
548  }
549 
550  inline bool scaleX() const
551  {
552  return myScaleX;
553  }
554 
555  void setScaleXY(bool b)
556  {
557  myScaleY = b;
558  }
559 
560  inline bool scaleY() const
561  {
562  return myScaleY;
563  }
564 
565  void setScaleZ(bool b)
566  {
567  myScaleZ = b;
568  }
569 
570  inline bool scaleZ() const
571  {
572  return myScaleZ;
573  }
574 
575  protected:
577  double myLength, myWidth, myHeight;
578  bool myScaleX, myScaleY, myScaleZ;
579  };
580 
581 }
582 
583 
double myAltitude2D
Definition: DtOsgCullVisitorParameters.h:433
std::vector< osg::Vec3d > & focusPoints()
get the focus points.
Definition: DtOsgCullVisitorParameters.h:409
void setDynamicWaterVisibilityMax(double visMax)
Set the maximum value to which water visibility will be set when dynamic water visibility is enabled...
Definition: DtOsgCullVisitorParameters.h:292
float myCurrentScaleFactor
Definition: DtOsgCullVisitorParameters.h:450
void setFocusPoints(std::vector< osg::Vec3d > &points)
set the focus points.
Definition: DtOsgCullVisitorParameters.h:402
bool myScaleZ
Definition: DtOsgCullVisitorParameters.h:578
bool myFocusPointEnabled
Definition: DtOsgCullVisitorParameters.h:456
Object used to calculate fixed scale of object based on how many pixels on screen it should take up...
Definition: DtOsgCullVisitorParameters.h:461
double fixedPixelSize() const
Definition: DtOsgCullVisitorParameters.h:484
void setModelScaler(DtModelScaler *scaler)
Set the XR scaler to use.
Definition: DtOsgCullVisitorParameters.h:223
double myLodScaleFactor
Definition: DtOsgCullVisitorParameters.h:430
bool myDynamicOceanFlag
Definition: DtOsgCullVisitorParameters.h:437
void setSkyRendering(bool renderSky)
Set whether the sky is being rendered.
Definition: DtOsgCullVisitorParameters.h:161
void setClampedPixelSize(double d)
Set the clamped pixel size calculated when using DtOsgFixedScaleParameters.
Definition: DtOsgCullVisitorParameters.h:265
double myTerrainRadius
Definition: DtOsgCullVisitorParameters.h:432
double altitude2D() const
Return the (implied) 2D altitude.
Definition: DtOsgCullVisitorParameters.h:125
double clampedPixelSize() const
Retrieve the clamped pixel size set in setClampedPixelSize.
Definition: DtOsgCullVisitorParameters.h:271
void setCameraResolution(double factor)
Set the zoom factor that effects LODing.
Definition: DtOsgCullVisitorParameters.h:90
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
The DtModelScaler prepares the data from the osg camera, osg node, and cull visitor parameters and th...
Definition: DtModelScaler.h:32
void setDynamicOcean(bool enabled)
Set whether a dynamic ocean rendering is enabled.
Definition: DtOsgCullVisitorParameters.h:186
Definition: featureContext.h:37
osg::ref_ptr< DtModelScaler > myModelScaler
Definition: DtOsgCullVisitorParameters.h:444
float myIndirectDistScale
Definition: DtOsgCullVisitorParameters.h:452
void setTerrainMagnificationScaleFactor(float factor)
Set the amount that any view magnification value is reduced by when determining the distance to a pag...
Definition: DtOsgCullVisitorParameters.h:306
void setIndirectDistanceScaleEnabled(bool enabled)
Set if the distance for culling instanced data is enabled.
Definition: DtOsgCullVisitorParameters.h:365
DtOsgCullVisitorParameters()
CTOR.
Definition: DtOsgCullVisitorParameters.h:43
void setCurrentTraversalScaleFactor(float currentScaleFactor)
set the scale factor for the current place in the cull visitor traversal.
Definition: DtOsgCullVisitorParameters.h:359
bool myIndirectDistScaleEnabled
Definition: DtOsgCullVisitorParameters.h:451
double length() const
Definition: DtOsgCullVisitorParameters.h:494
double terrainRadius() const
Get the terrain radius.
Definition: DtOsgCullVisitorParameters.h:143
double calculateModelScale(const osg::Camera &camera, const osg::Node &node) const
calculate the model scale using the registered XR scaler.
Definition: DtOsgCullVisitorParameters.h:234
void setLodScaleFactor(double sf)
Set the LOD scale factor that affects LODing and paging; this is the product of the channels LOD scal...
Definition: DtOsgCullVisitorParameters.h:78
DtOsgFixedScaleParameters()
Definition: DtOsgCullVisitorParameters.h:464
bool scaleZ() const
Definition: DtOsgCullVisitorParameters.h:570
osg::Vec3d myCameraVelocity
Definition: DtOsgCullVisitorParameters.h:447
double myCameraResolution
Definition: DtOsgCullVisitorParameters.h:431
void setFocusPointEnabled(bool enable)
set the focust point enabled flag.
Definition: DtOsgCullVisitorParameters.h:416
void setScaleX(bool b)
Definition: DtOsgCullVisitorParameters.h:545
void setCameraVelocity(double x, double y, double z)
Set the camera velocity.
Definition: DtOsgCullVisitorParameters.h:101
float myTerrainMagnificationScaleFactor
Definition: DtOsgCullVisitorParameters.h:445
void setTerrainRadius(double rad)
Set the terrain radius.
Definition: DtOsgCullVisitorParameters.h:113
virtual ~DtOsgFixedScaleParameters()
Definition: DtOsgCullVisitorParameters.h:475
DtModelScaler * findModelScaler() const
Definition: DtOsgCullVisitorParameters.h:228
void setDynamicLights(bool enabled)
Set whether dynamic lights are enabled.
Definition: DtOsgCullVisitorParameters.h:174
bool scaleX() const
Definition: DtOsgCullVisitorParameters.h:550
const osg::Vec3d & cameraVelocity() const
Get the camera velocity.
Definition: DtOsgCullVisitorParameters.h:107
bool scaling() const
Get whether scalable groups should be scaled by distance.
Definition: DtOsgCullVisitorParameters.h:204
unsigned int myModelSet
Definition: DtOsgCullVisitorParameters.h:448
double lodScaleFactor() const
Return the current LOD scale factor.
Definition: DtOsgCullVisitorParameters.h:84
void setDimensions(double length, double width, double height)
Definition: DtOsgCullVisitorParameters.h:489
void setTerrainMagnificationHighLodAngle(float radians)
Set the angle used when paging in high LOD tiles, the angle (radians) represents the half angle...
Definition: DtOsgCullVisitorParameters.h:324
Contains makVrv::DtObserverObject class.
void setCoordinateSystemChanged(bool changed)
Set whether the coordinate system changed this frame.
Definition: DtOsgCullVisitorParameters.h:210
unsigned int modelSet() const
Get the model set currently being rendered.
Definition: DtOsgCullVisitorParameters.h:131
bool dynamicLights() const
Get whether dynamic lights rendering is enabled.
Definition: DtOsgCullVisitorParameters.h:180
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:38
void setDynamicWaterVisibilityEnable(bool enable)
Set dynamic water visibility, based on altitude.
Definition: DtOsgCullVisitorParameters.h:279
float myChannelLodScale
Definition: DtOsgCullVisitorParameters.h:455
float indirectDistanceScale() const
Get the distance for culling instanced data.
Definition: DtOsgCullVisitorParameters.h:383
void setOrthoCulling(bool ortho)
Set whether the culling should be doing in orthographic mode.
Definition: DtOsgCullVisitorParameters.h:149
double cameraResolution() const
Get the zoom factor.
Definition: DtOsgCullVisitorParameters.h:96
bool myDynamicWaterVisibilityEnable
Definition: DtOsgCullVisitorParameters.h:442
Contains the declaration of the makVrv::DtModelScaler class.
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
bool myIncludeLightPoints
Definition: DtOsgCullVisitorParameters.h:449
double myClampedPixelSize
Definition: DtOsgCullVisitorParameters.h:440
bool includeLightPoints() const
get the flag for including light points in this cull visitor traversal. If false then light points wi...
Definition: DtOsgCullVisitorParameters.h:345
bool dynamicOcean() const
Get whether a dynamic ocean rendering is enabled.
Definition: DtOsgCullVisitorParameters.h:192
void setScaling(bool scaling)
Set whether scalable groups should be scaled by distance.
Definition: DtOsgCullVisitorParameters.h:198
bool mySkyFlag
Definition: DtOsgCullVisitorParameters.h:435
bool indirectDistanceScaleEnabled() const
True if the distance for culling instanced data is enabled.
Definition: DtOsgCullVisitorParameters.h:371
double myDynamicWaterVisibilityMax
Definition: DtOsgCullVisitorParameters.h:443
double height() const
Definition: DtOsgCullVisitorParameters.h:504
void calculateScaleFactors(const osg::BoundingSphere &sphere, const DtOsgCullVisitorParameters &info, double &scaleFactorX, double &scaleFactorY, double &scaleFactorZ) const
Definition: DtOsgCullVisitorParameters.h:521
double myAltitude3D
Definition: DtOsgCullVisitorParameters.h:434
bool coordinateSystemChanged() const
Get whether the coordinate system changed this frame.
Definition: DtOsgCullVisitorParameters.h:216
void setChannelLodScale(float scale)
set the channel lod scale. This is only the channel configuration value and not the view magnificatio...
Definition: DtOsgCullVisitorParameters.h:389
void calculateScaleFactors(const osgUtil::CullVisitor &visitor, const osg::BoundingSphere &sphere, DtOsgCullVisitorParameters *info, double &scaleFactorX, double &scaleFactorY, double &scaleFactorZ) const
Definition: DtOsgCullVisitorParameters.h:509
double myWidth
Definition: DtOsgCullVisitorParameters.h:577
bool scaleY() const
Definition: DtOsgCullVisitorParameters.h:560
bool orthoCulling() const
Get whether the culling is to be done in 2D orthographic mode.
Definition: DtOsgCullVisitorParameters.h:155
double calculateScale(const osg::Camera &camera, const osg::Vec3d &position, double modelRadius, DtUniqueID objectElementId) const
Definition: DtOsgCullVisitorParameters.h:248
bool myCoordinateSystemChanged
Definition: DtOsgCullVisitorParameters.h:441
float terrainMagnificationHighLodAngle() const
Get the viewing angle within which high LOD tiles will be used ex.
Definition: DtOsgCullVisitorParameters.h:333
bool myScalingFlag
Definition: DtOsgCullVisitorParameters.h:439
double dynamicWaterVisibilityMax() const
Get the maximum value to which water visibility will be set when dynamic water visibility is enabled...
Definition: DtOsgCullVisitorParameters.h:299
bool skyRendering() const
Get whether the sky is being rendered.
Definition: DtOsgCullVisitorParameters.h:168
bool dynamicWaterVisibilityEnable() const
Get whether dynamic water is enabled.
Definition: DtOsgCullVisitorParameters.h:285
void setModelSet(unsigned int modelSet)
Set the model set currently being rendered.
Definition: DtOsgCullVisitorParameters.h:137
std::vector< osg::Vec3d > myFocusPoints
Definition: DtOsgCullVisitorParameters.h:453
void setIncludeLightPoints(bool flag)
set the flag for including light points in this cull visitor traversal. If false then light points wi...
Definition: DtOsgCullVisitorParameters.h:339
void setFixedPixelSize(double d)
Definition: DtOsgCullVisitorParameters.h:479
void setScaleZ(bool b)
Definition: DtOsgCullVisitorParameters.h:565
bool myDynamicLightsFlag
Definition: DtOsgCullVisitorParameters.h:436
float channelLodScale()
get the channel lod scale. This is only the channel configuration value and not the view magnificatio...
Definition: DtOsgCullVisitorParameters.h:395
float myTerrainMagnificationHighLodAngle
Definition: DtOsgCullVisitorParameters.h:446
float terrainMagnificationScaleFactor() const
Get the amount that any view magnification value is reduced by when determining the distance to a pag...
Definition: DtOsgCullVisitorParameters.h:313
void setIndirectDistanceScale(float scale)
Set the distance for culling instanced data.
Definition: DtOsgCullVisitorParameters.h:377
double width() const
Definition: DtOsgCullVisitorParameters.h:499
void setScaleXY(bool b)
Definition: DtOsgCullVisitorParameters.h:555
bool focusPointEnabled()
get the focust point enabled flag.
Definition: DtOsgCullVisitorParameters.h:423
void setAltitude2D(double altitude)
Set the (implied) altitude when orthoCulling.
Definition: DtOsgCullVisitorParameters.h:119
bool myOrthoFlag
Definition: DtOsgCullVisitorParameters.h:438
float currentTraversalScaleFactor()
get the scale factor for the current place in the cull visitor traversal.
Definition: DtOsgCullVisitorParameters.h:352
double myFixedPixelSize
Definition: DtOsgCullVisitorParameters.h:576

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)