VR-Forces 4.3 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) 2014 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <vrvCore/DtChannel.h>
15 #include <vrvOsg/DtOsgRenderer.h>
16 #include <vrvOsg/DtCameraNode.h>
17 
18 #include <osg/ref_ptr>
19 #include <osgViewer/View>
20 
21 #include <boost/signals.hpp>
22 
23 namespace osg
24 {
25  class Matrixd;
26 }
27 
28 namespace makVrv
29 {
30  class DtChannelSpecificGroup;
31  class DtOsgWindow;
32  class DtOsgChannelCreator;
33  class DtChannelManager;
34  class DtWindowConfiguration;
35  class DtSensorModule;
36  class DtSensor;
37  class DtOsgObserverObject;
38  class DtOsgCullVisitorParameters;
39 
47  {
48  protected:
49  friend class DtOsgChannelCreator;
50 
54  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
55 
57 
58 
63  virtual bool initialize();
64 
66 
67  virtual void initializeNormalized2DCamera();
68  virtual void initialize2DCamera( int w, int h );
69  virtual void initializeSceneCamera( );
70  virtual void initializeRenderTexture( int format, int sourceFormat = GL_RGBA, int sourceType = GL_UNSIGNED_BYTE);
71  virtual void initializeRTTCamera( );
72 
73  void clearRttCamera();
74 
75  virtual void recreateRTTCamera( );
76 
78 
80  void setShadowState(bool enable);
81 
83  virtual void addOverlayDrawablesToCameras();
84 
86  virtual void initializeStatsHandler();
87 
93  virtual void initializeSignalConnections();
95 
96  public:
98  virtual ~DtOsgChannel();
99 
104  void setSensorName( const std::string& sensorName );
105 
107  virtual void setClearColor(float r,float g,float b, float a);
108 
112  virtual void setWindow(DtWindow* view);
113 
115  virtual const DtWindow* window() const;
116 
118  virtual void setViewport(int x,int y,int width, int height);
119 
121  virtual void getViewport(int& x,int& y, int& width,int& height) const;
122 
124  virtual void setCameraPosition(double x, double y, double z);
125 
127  virtual void setCameraOrientation( double psi, double theta, double phi );
128 
133  virtual void setCameraPositionAndOrientation( double x, double y,
134  double z, double psi, double theta, double phi );
135  virtual void setCameraPositionAndOrientation( osg::Vec3d& pos,
136  osg::Quat& orient );
137 
139  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
140  osg::Quat& rotation ) const;
141 
142  virtual void update();
143 
145  virtual void connectToObserver();
146 
149  virtual void setProjectionMatrixAsPerspective(double fovy,
150  double aspectRatio, double zNear, double zFar);
151 
153  virtual void setProjectionMatrixAsFrustum (double left, double right,
154  double bottom, double top, double zNear, double zFar);
155 
157  virtual osgViewer::View& view();
158 
160  virtual DtCameraNode* sceneCamera();
161  virtual const DtCameraNode* sceneCamera() const;
162 
164  virtual DtCameraNode* rttCamera();
165 
167  virtual DtCameraNode* overlayCamera();
168 
169 
171  virtual DtCameraNode* normalizedOverlayCamera();
172 
174  virtual void setRenderToTexture(bool enabled, int format = GL_RGBA, int sourceFormat = GL_RGBA, int sourceType = GL_UNSIGNED_BYTE);
175 
178  virtual osg::ref_ptr<osg::Texture2D> getRenderTexture();
179 
181  virtual osg::ref_ptr<osg::Texture2D> getDepthTexture() const;
182 
184  int shadowQuality() const;
185 
188  virtual void setProjectionResizePolicy(
190 
193  virtual void updateProjection();
194 
195  void projectionUnitsToFrustum( DtChannelConfiguration::ProjectionUnits units,
196  double &left, double zNear, double &right, double &top, double &bottom );
197 
199  virtual void connectChannelToScene();
200 
202  virtual bool processMouseEvent( const DtMouseEvent& ev);
203 
205  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
206 
208  //virtual DtDynamicOverlay* overlay();
209 
211  void getWorldToWindowMatrix( osg::Matrix& worldToWindowMatrix ) const;
212 
214  virtual void moveMouseToScreenLocation(float screenX, float screenY);
215 
219  virtual void projectToScreen( double dbX, double dbY, double dbZ,
220  double& screenX, double& screenY, double& screenZ );
221 
223  virtual void projectToWorld( double screenX, double screenY,
224  double& dbX, double& dbY, double& dbZ );
225 
227  virtual const std::string& name();
228 
233  boost::signal<void (int, int, int, int)> signal_viewportChanged;
234 
235  typedef std::list<std::string> PostProcessorEffectList;
236 
240  virtual void addPostProcessEffect(std::string postProcessorEffect);
241 
245  virtual void removePostProcessEffect(std::string postProcessorEffect);
246 
248  virtual void set3DCullVisitorParams( DtOsgCullVisitorParameters* params );
249  virtual void set2DCullVisitorParams( DtOsgCullVisitorParameters* params );
251 
252  protected:
253  void makeObserverToCameraMatrix( osg::Vec3d& orient,
254  osg::Matrixd& offsetObserverToCamera );
255  void makeObserverToCameraMatrix( osg::Quat& qObserverToWorld,
256  osg::Matrixd& offsetObserverToCamera );
257 
259  virtual void calculateNearFar(double& zNear, double& zFar);
260 
264  virtual bool useAttachedForNearClip( double alt );
265 
267  virtual double calculateNearClip( double alt, double zFar );
268 
270  virtual double calculateFarClip( double alt );
271 
273  virtual void projectFor3D();
274 
276  virtual void projectFor2D();
277 
281  virtual void stopUsingModelSet( int modelSet );
282 
286  virtual void startUsingModelSet( int modelSet );
287 
289  virtual void stopUsingSensor( DtSensor* sensor );
290 
292  virtual void startUsingSensor( DtSensor* sensor );
293 
295  virtual void slot_sensorRemoved( DtSensor* sensor );
296 
298  virtual void slot_visualizerRootAdded( int modelSet, int visualType );
299 
301  virtual void slot_observerModelSetChanged( DtObserverObject* observer,
302  int modelSet );
303 
305  virtual void slot_observerSettingChanged( DtObserverObject* observer,
306  int setting, bool value );
307 
309  virtual void slot_observerSettingRemoved( DtObserverObject* observer,
310  int setting );
311 
313  virtual void slot_channelAdded(DtChannelManager* mgr, DtChannel* channel);
314 
316  virtual void slot_channelDestroyed(DtChannelManager* mgr, DtChannel* channel);
317 
319  virtual void slot_windowConfigurationModified( const std::string& deName,
320  const std::string& oldWindowName, const DtWindowConfiguration& config);
321 
323  virtual void slot_onCoordinateSystemChanged();
324 
328  virtual void throttleDatabasePager(DtChannelManager* mgr, DtChannel* channel);
329 
330  protected:
332  void stopUsingModelSetWork( int modelSet );
333 
335  void startUsingModelSetWork( int modelSet );
336 
338  void initializeRenderTextureColor(int format, int sourceFormat, int sourceType);
339 
341  void initializeRenderTextureDepth();
342 
343  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
344 
345  protected:
346  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
347 
348  osg::ref_ptr<osgViewer::View> myView;
351 
353 
355 
357 
359 
360  osg::ref_ptr<osg::Group> myRoot;
361 
362  //The master 3D camera
363  osg::ref_ptr<DtCameraNode> mySceneCamera;
364 
365  //The 2D camera in screen space(0,0 - w,h)
366  osg::ref_ptr<DtCameraNode> my2DCamera;
367 
368  //The 2D camera in normalize screen space (0,0 - 1,1)
369  osg::ref_ptr<DtCameraNode> myNormalized2DCamera;
370 
372  osg::ref_ptr<osg::Texture2D> myRenderTexture;
373  osg::ref_ptr<osg::Texture2D> myDepthTexture;
374 
376  osg::ref_ptr<DtCameraNode> myRTTCamera;
377 
382 
383  // ex. { "dof", "rainsplash", "oceanspray" }
384  // list of post processor effect names to enable on update
386 
387  osg::Node::NodeMask myOldSceneCameraNodeMask;
388  };
389 
393  {
394  public:
396  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
397  };
398 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)