VR-Forces 4.6.1 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) 2018 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 
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  , myScaleFactor( 1.0 )
53  , myClampedPixelSize( 1.0 )
54  , myCameraMagnification( 1.0 )
55  , myScaleType( DtObserverObject::XRScale )
56  , myCoordinateSystemChanged( false )
57  , myAltitude2D( 0. )
58  , myAltitude3D( 0. )
59  , myDynamicWaterVisibilityEnable(true)
60  , myDynamicWaterVisibilityMax(75.)
61  , myNodeXRScaler( 0 )
62  , myPagedLodMagnificationHighLodAngle(DtDeg2Rad(15))
63  , myPagedLodMagnificationScaleFactor(1.)
64  , myCameraVelocity( 0 )
65  , myModelSet(0)
66  , myIncludeLightPoints(true)
67  , myCurrentScaleFactor(1.0)
68  {
69  }
70 
72  inline void setCameraMagnification( double mag )
73  {
74  myCameraMagnification = mag;
75  }
76 
78  inline double cameraMagnification() const
79  {
80  return myCameraMagnification;
81  }
82 
84  void setCameraResolution(double factor)
85  {
86  myCameraResolution = factor;
87  }
88 
90  inline double cameraResolution() const
91  {
92  return myCameraResolution;
93  }
95  void setCameraVelocity(double velocity)
96  {
97  myCameraVelocity = velocity;
98  }
99 
101  inline double cameraVelocity() const
102  {
103  return myCameraVelocity;
104  }
105 
107  void setTerrainRadius(double rad)
108  {
109  myTerrainRadius = rad;
110  }
111 
113  void setAltitude2D( double altitude )
114  {
115  myAltitude2D = altitude;
116  }
117 
119  double altitude2D() const
120  {
121  return myAltitude2D;
122  }
123 
125  inline unsigned int modelSet() const
126  {
127  return myModelSet;
128  }
129 
131  void setModelSet(unsigned int modelSet)
132  {
133  myModelSet = modelSet;
134  }
135 
137  inline double terrainRadius() const
138  {
139  return myTerrainRadius;
140  }
141 
143  void setOrthoCulling(bool ortho)
144  {
145  myOrthoFlag = ortho;
146  }
147 
149  inline bool orthoCulling() const
150  {
151  return myOrthoFlag;
152  }
153 
155  inline void setSkyRendering(bool renderSky)
156  {
157  mySkyFlag = renderSky;
158 
159  }
160 
162  inline bool skyRendering() const
163  {
164  return mySkyFlag;
165  }
166 
168  inline void setDynamicLights(bool enabled)
169  {
170  myDynamicLightsFlag = enabled;
171  }
172 
174  inline bool dynamicLights() const
175  {
176  return myDynamicLightsFlag;
177  }
178 
180  inline void setDynamicOcean(bool enabled)
181  {
182  myDynamicOceanFlag = enabled;
183  }
184 
186  inline bool dynamicOcean() const
187  {
188  return myDynamicOceanFlag;
189  }
190 
192  void setScaling( bool scaling )
193  {
194  myScalingFlag = scaling;
195  }
196 
198  inline bool scaling() const
199  {
200  return myScalingFlag;
201  }
202 
204  void setScaleFactor( double scaleFactor )
205  {
206  myScaleFactor = scaleFactor;
207  }
208 
210  inline double scaleFactor() const
211  {
212  return myScaleFactor;
213  }
214 
216  void setCoordinateSystemChanged( bool changed )
217  {
218  myCoordinateSystemChanged = changed;
219  }
220 
222  inline bool coordinateSystemChanged() const
223  {
224  return myCoordinateSystemChanged;
225  }
226 
229  inline void setNodeXRScaler( DtOsgNodeXRScaler* scaler )
230  {
231  myNodeXRScaler = scaler;
232  }
233 
235  inline double calculateXRScale( const osg::Camera& camera,
236  const osg::Node& node )
237  {
238  if ( myNodeXRScaler.valid() )
239  {
240  return myNodeXRScaler->calculateXRScale( *this, camera, node );
241  }
242  else
243  {
244  return 1.;
245  }
246  }
247 
249  void setScaleType( DtObserverObject::ScaleType scaleType )
250  {
251  myScaleType = scaleType;
252  }
253 
255  inline DtObserverObject::ScaleType scaleType() const
256  {
257  return myScaleType;
258  }
259 
264  void setClampedPixelSize(double d)
265  {
266  myClampedPixelSize = d;
267  }
268 
270  double clampedPixelSize() const
271  {
272  return myClampedPixelSize;
273  }
274 
278  inline void setDynamicWaterVisibilityEnable( bool enable )
279  {
280  myDynamicWaterVisibilityEnable = enable;
281  }
282 
284  inline bool dynamicWaterVisibilityEnable() const
285  {
286  return myDynamicWaterVisibilityEnable;
287  }
288 
291  inline void setDynamicWaterVisibilityMax( double visMax )
292  {
293  myDynamicWaterVisibilityMax = visMax;
294  }
295 
298  inline double dynamicWaterVisibilityMax() const
299  {
300  return myDynamicWaterVisibilityMax;
301  }
302 
305  inline void setPagedLodMagnificationScaleFactor(float factor)
306  {
307  myPagedLodMagnificationScaleFactor = factor;
308  }
309 
312  inline float pagedLodMagnificationScaleFactor() const
313  {
314  return myPagedLodMagnificationScaleFactor;
315  }
316 
323  inline void setPagedLodMagnificationHighLodAngle(float radians)
324  {
325  myPagedLodMagnificationHighLodAngle = radians;
326  }
327 
332  inline float pagedLodMagnificationHighLodAngle() const
333  {
334  return myPagedLodMagnificationHighLodAngle;
335  }
336 
338  inline void setIncludeLightPoints(bool flag)
339  {
340  myIncludeLightPoints = flag;
341  }
342 
344  inline bool includeLightPoints() const
345  {
346  return myIncludeLightPoints;
347  }
348 
351  inline float currentTraversalScaleFactor()
352  {
353  return myCurrentScaleFactor;
354  }
355 
358  inline void setCurrentTraversalScaleFactor(float currentScaleFactor)
359  {
360  myCurrentScaleFactor = currentScaleFactor;
361  }
362 
363 
364  protected:
365 
369  double myAltitude2D;
370  double myAltitude3D;
371  bool mySkyFlag;
382  osg::ref_ptr<DtOsgNodeXRScaler> myNodeXRScaler;
386  unsigned int myModelSet;
389  };
390 
393  class DT_DLL_VRVOSG DtOsgFixedScaleParameters : public osg::Referenced
394  {
395  public:
397  : myFixedPixelSize( 1.0 )
398  , myLength( 0.0 )
399  , myWidth( 0.0 )
400  , myHeight( 0.0 )
401  , myScaleX(true)
402  , myScaleY(true)
403  , myScaleZ(true)
404  {
405 }
406 
408  {
409  }
410 
411  void setFixedPixelSize(double d)
412  {
413  myFixedPixelSize = d;
414  }
415 
416  double fixedPixelSize() const
417  {
418  return myFixedPixelSize;
419  }
420 
421  void setDimensions(double length, double width, double height)
422  {
423  myLength = length; myWidth = width; myHeight = height;
424  }
425 
426  inline double length() const
427  {
428  return myLength;
429  }
430 
431  inline double width() const
432  {
433  return myWidth;
434  }
435 
436  inline double height() const
437  {
438  return myHeight;
439  }
440 
441  inline void calculateScaleFactors(const osgUtil::CullVisitor& visitor,
442  const osg::BoundingSphere& sphere, DtOsgCullVisitorParameters* info,
443  double& scaleFactorX, double& scaleFactorY, double& scaleFactorZ) const
444  {
445  double clampedSize =
446  visitor.clampedPixelSize( sphere.center(), info->terrainRadius() );
447  info->setClampedPixelSize(clampedSize);
448 
449  calculateScaleFactors( sphere, *info, scaleFactorX,
450  scaleFactorY, scaleFactorZ );
451  }
452 
453  inline void calculateScaleFactors(const osg::BoundingSphere& sphere, const DtOsgCullVisitorParameters& info,
454  double& scaleFactorX, double& scaleFactorY, double& scaleFactorZ) const
455  {
456  scaleFactorX = scaleFactorY = scaleFactorZ = 1.0;
457 
458  double metersPerPixel = info.terrainRadius() / info.clampedPixelSize(); // Meters per pixel
459  double curPixels = myWidth / metersPerPixel; // Pixels needed to draw
460 
461  if (myScaleX)
462  {
463  scaleFactorX = myFixedPixelSize / curPixels;
464  }
465 
466  if (myScaleY)
467  {
468  scaleFactorY = scaleFactorX;
469  }
470 
471  if (myScaleX)
472  {
473  scaleFactorZ = 1.0;
474  }
475  }
476 
477  void setScaleX(bool b)
478  {
479  myScaleX = b;
480  }
481 
482  inline bool scaleX() const
483  {
484  return myScaleX;
485  }
486 
487  void setScaleXY(bool b)
488  {
489  myScaleY = b;
490  }
491 
492  inline bool scaleY() const
493  {
494  return myScaleY;
495  }
496 
497  void setScaleZ(bool b)
498  {
499  myScaleZ = b;
500  }
501 
502  inline bool scaleZ() const
503  {
504  return myScaleZ;
505  }
506 
507  protected:
509  double myLength, myWidth, myHeight;
510  bool myScaleX, myScaleY, myScaleZ;
511  };
512 
513 }
514 
515 

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)