VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgCullVisitorParameters.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2014 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  {
67  }
68 
70  inline void setCameraMagnification( double mag )
71  {
72  myCameraMagnification = mag;
73  }
74 
76  inline double cameraMagnification() const
77  {
78  return myCameraMagnification;
79  }
80 
82  void setCameraResolution(double factor)
83  {
84  myCameraResolution = factor;
85  }
86 
88  inline double cameraResolution() const
89  {
90  return myCameraResolution;
91  }
93  void setCameraVelocity(double velocity)
94  {
95  myCameraVelocity = velocity;
96  }
97 
99  inline double cameraVelocity() const
100  {
101  return myCameraVelocity;
102  }
103 
105  void setTerrainRadius(double rad)
106  {
107  myTerrainRadius = rad;
108  }
109 
111  void setAltitude2D( double altitude )
112  {
113  myAltitude2D = altitude;
114  }
115 
117  double altitude2D() const
118  {
119  return myAltitude2D;
120  }
121 
123  inline unsigned int modelSet() const
124  {
125  return myModelSet;
126  }
127 
129  void setModelSet(unsigned int modelSet)
130  {
131  myModelSet = modelSet;
132  }
133 
135  inline double terrainRadius() const
136  {
137  return myTerrainRadius;
138  }
139 
141  void setOrthoCulling(bool ortho)
142  {
143  myOrthoFlag = ortho;
144  }
145 
147  inline bool orthoCulling() const
148  {
149  return myOrthoFlag;
150  }
151 
153  inline void setSkyRendering(bool renderSky)
154  {
155  mySkyFlag = renderSky;
156 
157  }
158 
160  inline bool skyRendering() const
161  {
162  return mySkyFlag;
163  }
164 
166  inline void setDynamicLights(bool enabled)
167  {
168  myDynamicLightsFlag = enabled;
169  }
170 
172  inline bool dynamicLights() const
173  {
174  return myDynamicLightsFlag;
175  }
176 
178  inline void setDynamicOcean(bool enabled)
179  {
180  myDynamicOceanFlag = enabled;
181  }
182 
184  inline bool dynamicOcean() const
185  {
186  return myDynamicOceanFlag;
187  }
188 
190  void setScaling( bool scaling )
191  {
192  myScalingFlag = scaling;
193  }
194 
196  inline bool scaling() const
197  {
198  return myScalingFlag;
199  }
200 
202  void setScaleFactor( double scaleFactor )
203  {
204  myScaleFactor = scaleFactor;
205  }
206 
208  inline double scaleFactor() const
209  {
210  return myScaleFactor;
211  }
212 
214  void setCoordinateSystemChanged( bool changed )
215  {
216  myCoordinateSystemChanged = changed;
217  }
218 
220  inline bool coordinateSystemChanged() const
221  {
222  return myCoordinateSystemChanged;
223  }
224 
227  inline void setNodeXRScaler( DtOsgNodeXRScaler* scaler )
228  {
229  myNodeXRScaler = scaler;
230  }
231 
233  inline double calculateXRScale( const osg::Camera& camera,
234  const osg::Node& node )
235  {
236  if ( myNodeXRScaler.valid() )
237  {
238  return myNodeXRScaler->calculateXRScale( *this, camera, node );
239  }
240  else
241  {
242  return 1.;
243  }
244  }
245 
247  void setScaleType( DtObserverObject::ScaleType scaleType )
248  {
249  myScaleType = scaleType;
250  }
251 
253  inline DtObserverObject::ScaleType scaleType() const
254  {
255  return myScaleType;
256  }
257 
262  void setClampedPixelSize(double d)
263  {
264  myClampedPixelSize = d;
265  }
266 
268  double clampedPixelSize() const
269  {
270  return myClampedPixelSize;
271  }
272 
276  inline void setDynamicWaterVisibilityEnable( bool enable )
277  {
278  myDynamicWaterVisibilityEnable = enable;
279  }
280 
282  inline bool dynamicWaterVisibilityEnable() const
283  {
284  return myDynamicWaterVisibilityEnable;
285  }
286 
289  inline void setDynamicWaterVisibilityMax( double visMax )
290  {
291  myDynamicWaterVisibilityMax = visMax;
292  }
293 
296  inline double dynamicWaterVisibilityMax() const
297  {
298  return myDynamicWaterVisibilityMax;
299  }
300 
303  inline void setPagedLodMagnificationScaleFactor(float factor)
304  {
305  myPagedLodMagnificationScaleFactor = factor;
306  }
307 
310  inline float pagedLodMagnificationScaleFactor() const
311  {
312  return myPagedLodMagnificationScaleFactor;
313  }
314 
321  inline void setPagedLodMagnificationHighLodAngle(float angle)
322  {
323  myPagedLodMagnificationHighLodAngle = angle;
324  }
325 
329  inline float pagedLodMagnificationHighLodAngle() const
330  {
331  return myPagedLodMagnificationHighLodAngle;
332  }
333 
334  protected:
335 
339  double myAltitude2D;
340  double myAltitude3D;
341  bool mySkyFlag;
352  osg::ref_ptr<DtOsgNodeXRScaler> myNodeXRScaler;
356  unsigned int myModelSet;
357  };
358 
361  class DT_DLL_VRVOSG DtOsgFixedScaleParameters : public osg::Referenced
362  {
363  public:
365  : myFixedPixelSize( 1.0 )
366  , myLength( 0.0 )
367  , myWidth( 0.0 )
368  , myHeight( 0.0 )
369  , myScaleX(true)
370  , myScaleY(true)
371  , myScaleZ(true)
372  {
373 }
374 
376  {
377  }
378 
379  void setFixedPixelSize(double d)
380  {
381  myFixedPixelSize = d;
382  }
383 
384  double fixedPixelSize() const
385  {
386  return myFixedPixelSize;
387  }
388 
389  void setDimensions(double length, double width, double height)
390  {
391  myLength = length; myWidth = width; myHeight = height;
392  }
393 
394  inline double length() const
395  {
396  return myLength;
397  }
398 
399  inline double width() const
400  {
401  return myWidth;
402  }
403 
404  inline double height() const
405  {
406  return myHeight;
407  }
408 
409  inline void calculateScaleFactors(const osgUtil::CullVisitor& visitor,
410  const osg::BoundingSphere& sphere, DtOsgCullVisitorParameters* info,
411  double& scaleFactorX, double& scaleFactorY, double& scaleFactorZ) const
412  {
413  double clampedSize =
414  visitor.clampedPixelSize( sphere.center(), info->terrainRadius() );
415  info->setClampedPixelSize(clampedSize);
416 
417  calculateScaleFactors( sphere, *info, scaleFactorX,
418  scaleFactorY, scaleFactorZ );
419  }
420 
421  inline void calculateScaleFactors(const osg::BoundingSphere& sphere, const DtOsgCullVisitorParameters& info,
422  double& scaleFactorX, double& scaleFactorY, double& scaleFactorZ) const
423  {
424  scaleFactorX = scaleFactorY = scaleFactorZ = 1.0;
425 
426  double metersPerPixel = info.terrainRadius() / info.clampedPixelSize(); // Meters per pixel
427  double curPixels = myWidth / metersPerPixel; // Pixels needed to draw
428 
429  if (myScaleX)
430  {
431  scaleFactorX = myFixedPixelSize / curPixels;
432  }
433 
434  if (myScaleY)
435  {
436  scaleFactorY = scaleFactorX;
437  }
438 
439  if (myScaleX)
440  {
441  scaleFactorZ = 1.0;
442  }
443  }
444 
445  void setScaleX(bool b)
446  {
447  myScaleX = b;
448  }
449 
450  inline bool scaleX() const
451  {
452  return myScaleX;
453  }
454 
455  void setScaleXY(bool b)
456  {
457  myScaleY = b;
458  }
459 
460  inline bool scaleY() const
461  {
462  return myScaleY;
463  }
464 
465  void setScaleZ(bool b)
466  {
467  myScaleZ = b;
468  }
469 
470  inline bool scaleZ() const
471  {
472  return myScaleZ;
473  }
474 
475  protected:
477  double myLength, myWidth, myHeight;
478  bool myScaleX, myScaleY, myScaleZ;
479  };
480 
481 }
482 
483 

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)