VR-Forces Development_Version 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) 2016 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 
43  {
44  protected:
45  friend class DtOsgChannelCreator;
46 
50  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
51 
53 
54 
59  virtual bool initialize();
60 
62 
63  virtual void initializeNormalized2DCamera();
64  virtual void initialize2DCamera( int w, int h );
65  virtual void initializeSceneCamera( );
66  virtual void initializeRenderTexture( int format, int sourceFormat = GL_RGBA, int sourceType = GL_UNSIGNED_BYTE);
67  virtual void initializeRTTCamera( );
68 
69  void clearRttCamera();
70 
71  virtual void recreateRTTCamera( );
72 
74 
76  void setShadowState(bool enable);
77 
79  virtual void addOverlayDrawablesToCameras();
80 
86  virtual void initializeSignalConnections();
88 
89  public:
91  virtual ~DtOsgChannel();
92 
97  void setSensorName( const std::string& sensorName );
98 
100  virtual void setClearColor(float r,float g,float b, float a);
101 
105  virtual void setWindow(DtWindow* view);
106 
108  virtual const DtWindow* window() const;
109 
111  virtual void setViewport(int x,int y,int width, int height);
112 
114  virtual void getViewport(int& x,int& y, int& width,int& height) const;
115 
117  virtual void setCameraPosition(double x, double y, double z);
118 
120  virtual void setCameraOrientation( double psi, double theta, double phi );
121 
126  virtual void setCameraPositionAndOrientation( double x, double y,
127  double z, double psi, double theta, double phi );
128  virtual void setCameraPositionAndOrientation( osg::Vec3d& pos,
129  osg::Quat& orient );
130 
132  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
133  osg::Quat& rotation ) const;
134 
135  virtual void update();
136 
138  virtual void connectToObserver();
139 
142  virtual void setProjectionMatrixAsPerspective(double fovy,
143  double aspectRatio, double zNear, double zFar);
144 
146  virtual void setProjectionMatrixAsFrustum (double left, double right,
147  double bottom, double top, double zNear, double zFar);
148 
150  virtual osgViewer::View& view();
151 
153  virtual DtCameraNode* sceneCamera();
154  virtual const DtCameraNode* sceneCamera() const;
155 
157  virtual DtCameraNode* rttCamera() const;
158 
160  virtual DtCameraNode* overlayCamera();
161 
162 
164  virtual DtCameraNode* normalizedOverlayCamera();
165 
167  virtual void setRenderToTexture(bool enabled);
168 
172  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
173 
174 
177  virtual osg::ref_ptr<osg::Texture2D> getRenderTexture();
178 
180  virtual osg::ref_ptr<osg::Texture2D> getDepthTexture() const;
181 
183  int shadowQuality() const;
184 
188  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
189 
192  virtual void setProjectionResizePolicy(
194 
197  virtual void updateProjection();
198 
199  void projectionUnitsToFrustum( DtChannelConfiguration::ProjectionUnits units,
200  double &left, double zNear, double &right, double &top, double &bottom );
201 
203  virtual void connectChannelToScene();
204 
206  virtual bool processMouseEvent( const DtMouseEvent& ev);
207 
209  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
210 
212  //virtual DtDynamicOverlay* overlay();
213 
215  void getWorldToWindowMatrix( osg::Matrix& worldToWindowMatrix ) const;
216 
218  virtual void moveMouseToScreenLocation(float screenX, float screenY);
219 
223  virtual void projectToScreen( double dbX, double dbY, double dbZ,
224  double& screenX, double& screenY, double& screenZ );
225 
227  virtual void projectToWorld( double screenX, double screenY,
228  double& dbX, double& dbY, double& dbZ );
229 
231  virtual const std::string& name();
232 
237  boost::signal<void (int, int, int, int)> signal_viewportChanged;
238 
239  typedef std::list<std::string> PostProcessorEffectList;
240 
244  virtual void addPostProcessEffect(std::string postProcessorEffect);
245 
249  virtual void removePostProcessEffect(std::string postProcessorEffect);
250 
252  virtual void set3DCullVisitorParams( DtOsgCullVisitorParameters* params );
253  virtual void set2DCullVisitorParams( DtOsgCullVisitorParameters* params );
255 
256  virtual void setEnablePostProcessors(bool enable);
257 
258  virtual bool getEnablePostProcessors();
259 
260  //getter/setter for flag to use old (pre 2.1) channel offset calculation
261  virtual bool useOldChannelOffsetCalcuation() const;
262  virtual void setUseOldChannelOffsetCalcuation( bool enable );
263 
264 
265  protected:
266  //create observer to camera matricies both with and without
267  // channel offset applied.
268  // offsetObserverToCamera has channel offset applied and
269  // observerToCamera does not
270  void makeObserverToCameraMatrix( osg::Vec3d& orient,
271  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera );
272  void makeObserverToCameraMatrix( osg::Quat& qObserverToWorld,
273  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera );
274 
275 
277  virtual void calculateNearFar(double& zNear, double& zFar);
278 
282  virtual bool useAttachedForNearClip( double alt );
283 
285  virtual double calculateNearClip( double alt, double zFar );
286 
288  virtual double calculateFarClip( double alt );
289 
291  virtual void projectFor3D();
292 
294  virtual void projectFor2D();
295 
299  virtual void stopUsingModelSet( int modelSet );
300 
304  virtual void startUsingModelSet( int modelSet );
305 
307  virtual void stopUsingSensor( DtSensor* sensor );
308 
310  virtual void startUsingSensor( DtSensor* sensor );
311 
313  virtual void slot_sensorRemoved( DtSensor* sensor );
314 
316  virtual void slot_visualizerRootAdded( int modelSet, int visualType );
317 
319  virtual void slot_observerModelSetChanged( DtObserverObject* observer,
320  int modelSet );
321 
323  virtual void slot_observerSettingChanged( DtObserverObject* observer,
324  int setting, bool value );
325 
327  virtual void slot_observerSettingRemoved( DtObserverObject* observer,
328  int setting );
329 
331  virtual void slot_channelAdded(DtChannelManager* mgr, DtChannel* channel);
332 
334  virtual void slot_channelDestroyed(DtChannelManager* mgr, DtChannel* channel);
335 
337  virtual void slot_windowConfigurationModified( const std::string& deName,
338  const std::string& oldWindowName, const DtWindowConfiguration& config);
339 
341  virtual void slot_onCoordinateSystemChanged();
342 
346  virtual void throttleDatabasePager(DtChannelManager* mgr, DtChannel* channel);
347 
348  protected:
350  void stopUsingModelSetWork( int modelSet );
351 
353  void startUsingModelSetWork( int modelSet );
354 
356  void initializeRenderTextureColor(int format, int sourceFormat, int sourceType);
357 
359  void initializeRenderTextureDepth();
360 
361  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
362 
363 
364 
365  protected:
366  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
367 
368  osg::ref_ptr<osgViewer::View> myView;
371 
373 
375 
377 
379 
381 
382  osg::ref_ptr<osg::Group> myRoot;
383 
384  //The master 3D camera
385  osg::ref_ptr<DtCameraNode> mySceneCamera;
386 
387  //The 2D camera in screen space(0,0 - w,h)
388  osg::ref_ptr<DtCameraNode> my2DCamera;
389 
390  //The 2D camera in normalize screen space (0,0 - 1,1)
391  osg::ref_ptr<DtCameraNode> myNormalized2DCamera;
392 
394  osg::ref_ptr<osg::Texture2D> myRenderTexture;
395  osg::ref_ptr<osg::Texture2D> myDepthTexture;
396 
398  osg::ref_ptr<DtCameraNode> myRTTCamera;
399 
404 
405  // ex. { "dof", "rainsplash", "oceanspray" }
406  // list of post processor effect names to enable on update
408 
409  osg::Node::NodeMask myOldSceneCameraNodeMask;
410 
412 
414 
415  //flag to use old (pre 2.1) channel offset calculation
416  // set by creating a signal_channelCreated callback and
417  // setting it in there
419 
420  };
421 
425  {
426  public:
428  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
429  };
430 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)