VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgChannel.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2017 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtChannel.h>
13 #include <vrvOsg/DtOsgRenderer.h>
14 #include <vrvOsg/DtCameraNode.h>
15 
16 #include <osgViewer/View>
17 
18 namespace osg
19 {
20  class Matrixd;
21 }
22 
23 namespace makVrv
24 {
25  class DtLight;
26  class DtChannelSpecificGroup;
27  class DtOsgWindow;
28  class DtOsgChannelCreator;
29  class DtChannelManager;
30  class DtWindowConfiguration;
31  class DtSensorModule;
32  class DtSensor;
33  class DtOsgObserverObject;
34  class DtOsgCullVisitorParameters;
35 
37  class DtDatabasePagerCallback : public osg::DatabaseRequestHandlerCallback
38  {
39 
40  public:
42 
43  /* child under parent was loaded and added to the scenegraph */
44  virtual void childPagedIn(const osg::NodeVisitor::DatabaseRequestHandler*, osg::PagedLOD* page, osg::Node* child) const;
45 
46  /* child under parent was un-loaded and removed from the scenegraph */
47  virtual void childAboutToPageOut(const osg::NodeVisitor::DatabaseRequestHandler*, osg::PagedLOD* page, osg::Node* child) const;
48 
49  virtual osg::DatabaseRequestHandlerCallback* clone() const;
50 
52 
53  private:
54 
56  };
57 
65  {
66  protected:
67  friend class DtOsgChannelCreator;
68 
72  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
73 
75 
76 
81  virtual bool initialize();
82 
84 
85  virtual void initializeNormalized2DCamera();
86  virtual void initialize2DCamera( int w, int h );
87  virtual void initializeSceneCamera( );
88  virtual void initializeRenderTexture( int format, int sourceFormat = GL_RGBA, int sourceType = GL_UNSIGNED_BYTE);
89  virtual void initializeRTTCamera( );
90 
91  void clearRttCamera();
92 
93  virtual void recreateRTTCamera( );
94 
96 
98  void setShadowState(bool enable);
99 
101  virtual void addOverlayDrawablesToCameras();
102 
108  virtual void initializeSignalConnections();
110 
111 
112  public:
114  virtual ~DtOsgChannel();
115 
120  void setSensorName( const std::string& sensorName );
121 
123  virtual void setClearColor(float r,float g,float b, float a);
124 
128  virtual void setWindow(DtWindow* view);
129 
131  virtual const DtWindow* window() const;
132 
134  virtual void setViewport(int x,int y,int width, int height);
135 
137  virtual void getViewport(int& x,int& y, int& width,int& height) const;
138 
140  virtual void setCameraPosition(double x, double y, double z);
141 
143  virtual void setCameraOrientation( double psi, double theta, double phi );
144 
149  virtual void setCameraPositionAndOrientation( double x, double y,
150  double z, double psi, double theta, double phi );
151  virtual void setCameraPositionAndOrientation( osg::Vec3d& pos,
152  osg::Quat& orient );
153 
155  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
156  osg::Quat& rotation ) const;
157 
158  virtual void update();
159 
161  virtual void connectToObserver();
162 
165  virtual void setProjectionMatrixAsPerspective(double fovy,
166  double aspectRatio, double zNear, double zFar);
167 
169  virtual void setProjectionMatrixAsFrustum (double left, double right,
170  double bottom, double top, double zNear, double zFar);
171 
173  virtual void setProjectionMatrix(const osg::Matrix& matrix);
174 
176  virtual osgViewer::View& view();
177 
179  virtual DtCameraNode* sceneCamera();
180  virtual const DtCameraNode* sceneCamera() const;
181 
183  virtual DtCameraNode* rttCamera() const;
184 
186  virtual DtCameraNode* overlayCamera();
187 
188 
190  virtual DtCameraNode* normalizedOverlayCamera();
191 
193  virtual void setRenderToTexture(bool enabled);
194 
198  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
199 
200 
203  virtual osg::ref_ptr<osg::Texture2D> getRenderTexture();
204 
206  virtual osg::ref_ptr<osg::Texture2D> getDepthTexture() const;
207 
209  int shadowQuality() const;
210 
214  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
215 
218  virtual void setProjectionResizePolicy(
220 
223  virtual void updateProjection();
224 
225  void projectionUnitsToFrustum( DtChannelConfiguration::ProjectionUnits units,
226  double &left, double zNear, double &right, double &top, double &bottom );
227 
229  virtual void connectChannelToScene();
230 
232  virtual bool processMouseEvent( const DtMouseEvent& ev);
233 
235  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
236 
238  //virtual DtDynamicOverlay* overlay();
239 
241  void getWorldToWindowMatrix( osg::Matrix& worldToWindowMatrix ) const;
242 
244  virtual void moveMouseToScreenLocation(float screenX, float screenY);
245 
249  virtual void projectToScreen( double dbX, double dbY, double dbZ,
250  double& screenX, double& screenY, double& screenZ );
251 
253  virtual void projectToWorld( double screenX, double screenY,
254  double& dbX, double& dbY, double& dbZ );
255 
257  virtual const std::string& name();
258 
263  boost::signal<void (int, int, int, int)> signal_viewportChanged;
264 
265  typedef std::list<std::string> PostProcessorEffectList;
266 
270  virtual void addPostProcessEffect(const std::string& postProcessorEffect);
271 
275  virtual void removePostProcessEffect(const std::string& postProcessorEffect);
276 
278  virtual void set3DCullVisitorParams( DtOsgCullVisitorParameters* params );
279  virtual void set2DCullVisitorParams( DtOsgCullVisitorParameters* params );
281 
282  virtual void setEnablePostProcessors(bool enable);
283 
284  virtual bool getEnablePostProcessors();
285 
286  //getter/setter for flag to use old (pre 2.1) channel offset calculation
287  virtual bool useOldChannelOffsetCalcuation() const;
288  virtual void setUseOldChannelOffsetCalcuation( bool enable );
289 
292  virtual bool forceHdrLuminanceOverride();
293 
295  // structure to expedite culling. We need to clear any memory
296  // that this structure caches to decrement reference count of
297  // StateSets (and hence drawables, textures, etc) when scene
298  // changes completely (e.g. on post processor turned off/on)
299  // so that memory can be reclaimed
300  // This helper function accomplishes that
301  virtual void clearStateGraph(void);
302 
304  // should just pass through without applying any effects
305  // used by SensorFX to turn off HDR on a per channel basis.
306  virtual void setEnableHdrPassthrough(bool flag);
307  virtual bool enableHdrPassthrough();
308 
309  protected:
310  //create observer to camera matricies both with and without
311  // channel offset applied.
312  // offsetObserverToCamera has channel offset applied and
313  // observerToCamera does not
314  virtual void makeObserverToCameraMatrix( osg::Vec3d& orient,
315  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera );
316  virtual void makeObserverToCameraMatrix( osg::Quat& qObserverToWorld,
317  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera );
318 
319 
321  virtual void calculateNearFar(double& zNear, double& zFar);
322 
326  virtual bool useAttachedForNearClip( double alt );
327 
329  virtual double calculateNearClip( double alt, double zFar );
330 
332  virtual double calculateFarClip( double alt );
333 
335  virtual void projectFor3D();
336 
338  virtual void projectFor2D();
339 
343  virtual void stopUsingModelSet( int modelSet );
344 
348  virtual void startUsingModelSet( int modelSet );
349 
351  virtual void stopUsingSensor( DtSensor* sensor );
352 
354  virtual void startUsingSensor( DtSensor* sensor );
355 
357  virtual void slot_sensorRemoved( DtSensor* sensor );
358 
360  virtual void slot_visualizerRootAdded( int modelSet, int visualType );
361 
363  virtual void slot_observerModelSetChanged( DtObserverObject* observer,
364  int modelSet );
365 
367  virtual void slot_observerSettingChanged( DtObserverObject* observer,
368  int setting, bool value );
369 
371  virtual void slot_observerSettingRemoved( DtObserverObject* observer,
372  int setting );
373 
375  virtual void slot_channelAdded(DtChannelManager* mgr, DtChannel* channel);
376 
378  virtual void slot_channelDestroyed(DtChannelManager* mgr, DtChannel* channel);
379 
381  virtual void slot_windowConfigurationModified( const std::string& deName,
382  const std::string& oldWindowName, const DtWindowConfiguration& config);
383 
385  virtual void slot_onCoordinateSystemChanged();
386 
390  virtual void throttleDatabasePager(DtChannelManager* mgr, DtChannel* channel);
391 
392 
393  protected:
395  void stopUsingModelSetWork( int modelSet );
396 
398  void startUsingModelSetWork( int modelSet );
399 
401  void initializeRenderTextureColor(int format, int sourceFormat, int sourceType);
402 
404  void initializeRenderTextureDepth();
405 
406  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
407 
408 
409 
410 
411  protected:
412  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
413 
414  osg::ref_ptr<osgViewer::View> myView;
417 
419 
421 
423 
425 
427 
428  osg::ref_ptr<osg::Group> myRoot;
429 
430  //The master 3D camera
431  osg::ref_ptr<DtCameraNode> mySceneCamera;
432 
433  //The 2D camera in screen space(0,0 - w,h)
434  osg::ref_ptr<DtCameraNode> my2DCamera;
435 
436  //The 2D camera in normalize screen space (0,0 - 1,1)
437  osg::ref_ptr<DtCameraNode> myNormalized2DCamera;
438 
440  osg::ref_ptr<osg::Texture2D> myRenderTexture;
441  osg::ref_ptr<osg::Texture2D> myDepthTexture;
442 
444  osg::ref_ptr<DtCameraNode> myRTTCamera;
445 
450 
451  // ex. { "dof", "rainsplash", "oceanspray" }
452  // list of post processor effect names to enable on update
454 
455  osg::Node::NodeMask myOldSceneCameraNodeMask;
456 
458 
460 
461  //flag to use old (pre 2.1) channel offset calculation
462  // set by creating a signal_channelCreated callback and
463  // setting it in there
465 
466  osg::ref_ptr<osg::DatabaseRequestHandlerCallback> myDatabasePagerCallback;
467 
469  };
470 
474  {
475  public:
477  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
478  };
479 }

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)