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 #if 0
22  class DatabaseRequestHandlerCallback;
23 #endif
24 }
25 
26 namespace makVrv
27 {
28  class DtLight;
29  class DtChannelSpecificGroup;
30  class DtOsgWindow;
31  class DtOsgChannelCreator;
32  class DtChannelManager;
33  class DtWindowConfiguration;
34  class DtSensorModule;
35  class DtSensor;
36  class DtOsgObserverObject;
37  class DtOsgCullVisitorParameters;
38 
46  {
47  protected:
48  friend class DtOsgChannelCreator;
49 
53  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
54 
56 
57 
62  virtual bool initialize();
63 
65 
66  virtual void initializeNormalized2DCamera();
67  virtual void initialize2DCamera( int w, int h );
68  virtual void initializeSceneCamera( );
69  virtual void initializeRenderTexture( int format, int sourceFormat = GL_RGBA, int sourceType = GL_UNSIGNED_BYTE);
70  virtual void initializeRTTCamera( );
71 
72  void clearRttCamera();
73 
74  virtual void recreateRTTCamera( );
75 
77 
79  void setShadowState(bool enable);
80 
82  virtual void addOverlayDrawablesToCameras();
83 
89  virtual void initializeSignalConnections();
91 
92  public:
94  virtual ~DtOsgChannel();
95 
100  void setSensorName( const std::string& sensorName );
101 
103  virtual void setClearColor(float r,float g,float b, float a);
104 
108  virtual void setWindow(DtWindow* view);
109 
111  virtual const DtWindow* window() const;
112 
114  virtual void setViewport(int x,int y,int width, int height);
115 
117  virtual void getViewport(int& x,int& y, int& width,int& height) const;
118 
120  virtual void setCameraPosition(double x, double y, double z);
121 
123  virtual void setCameraOrientation( double psi, double theta, double phi );
124 
129  virtual void setCameraPositionAndOrientation( double x, double y,
130  double z, double psi, double theta, double phi );
131  virtual void setCameraPositionAndOrientation( osg::Vec3d& pos,
132  osg::Quat& orient );
133 
135  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
136  osg::Quat& rotation ) const;
137 
138  virtual void update();
139 
141  virtual void connectToObserver();
142 
145  virtual void setProjectionMatrixAsPerspective(double fovy,
146  double aspectRatio, double zNear, double zFar);
147 
149  virtual void setProjectionMatrixAsFrustum (double left, double right,
150  double bottom, double top, double zNear, double zFar);
151 
153  virtual osgViewer::View& view();
154 
156  virtual DtCameraNode* sceneCamera();
157  virtual const DtCameraNode* sceneCamera() const;
158 
160  virtual DtCameraNode* rttCamera() const;
161 
163  virtual DtCameraNode* overlayCamera();
164 
165 
167  virtual DtCameraNode* normalizedOverlayCamera();
168 
170  virtual void setRenderToTexture(bool enabled);
171 
175  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
176 
177 
180  virtual osg::ref_ptr<osg::Texture2D> getRenderTexture();
181 
183  virtual osg::ref_ptr<osg::Texture2D> getDepthTexture() const;
184 
186  int shadowQuality() const;
187 
191  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
192 
195  virtual void setProjectionResizePolicy(
197 
200  virtual void updateProjection();
201 
202  void projectionUnitsToFrustum( DtChannelConfiguration::ProjectionUnits units,
203  double &left, double zNear, double &right, double &top, double &bottom );
204 
206  virtual void connectChannelToScene();
207 
209  virtual bool processMouseEvent( const DtMouseEvent& ev);
210 
212  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
213 
215  //virtual DtDynamicOverlay* overlay();
216 
218  void getWorldToWindowMatrix( osg::Matrix& worldToWindowMatrix ) const;
219 
221  virtual void moveMouseToScreenLocation(float screenX, float screenY);
222 
226  virtual void projectToScreen( double dbX, double dbY, double dbZ,
227  double& screenX, double& screenY, double& screenZ );
228 
230  virtual void projectToWorld( double screenX, double screenY,
231  double& dbX, double& dbY, double& dbZ );
232 
234  virtual const std::string& name();
235 
240  boost::signal<void (int, int, int, int)> signal_viewportChanged;
241 
242  typedef std::list<std::string> PostProcessorEffectList;
243 
247  virtual void addPostProcessEffect(std::string postProcessorEffect);
248 
252  virtual void removePostProcessEffect(std::string postProcessorEffect);
253 
255  virtual void set3DCullVisitorParams( DtOsgCullVisitorParameters* params );
256  virtual void set2DCullVisitorParams( DtOsgCullVisitorParameters* params );
258 
259  virtual void setEnablePostProcessors(bool enable);
260 
261  virtual bool getEnablePostProcessors();
262 
263  //getter/setter for flag to use old (pre 2.1) channel offset calculation
264  virtual bool useOldChannelOffsetCalcuation() const;
265  virtual void setUseOldChannelOffsetCalcuation( bool enable );
266 
267 
268  protected:
269  //create observer to camera matricies both with and without
270  // channel offset applied.
271  // offsetObserverToCamera has channel offset applied and
272  // observerToCamera does not
273  void makeObserverToCameraMatrix( osg::Vec3d& orient,
274  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera );
275  void makeObserverToCameraMatrix( osg::Quat& qObserverToWorld,
276  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera );
277 
278 
280  virtual void calculateNearFar(double& zNear, double& zFar);
281 
285  virtual bool useAttachedForNearClip( double alt );
286 
288  virtual double calculateNearClip( double alt, double zFar );
289 
291  virtual double calculateFarClip( double alt );
292 
294  virtual void projectFor3D();
295 
297  virtual void projectFor2D();
298 
302  virtual void stopUsingModelSet( int modelSet );
303 
307  virtual void startUsingModelSet( int modelSet );
308 
310  virtual void stopUsingSensor( DtSensor* sensor );
311 
313  virtual void startUsingSensor( DtSensor* sensor );
314 
316  virtual void slot_sensorRemoved( DtSensor* sensor );
317 
319  virtual void slot_visualizerRootAdded( int modelSet, int visualType );
320 
322  virtual void slot_observerModelSetChanged( DtObserverObject* observer,
323  int modelSet );
324 
326  virtual void slot_observerSettingChanged( DtObserverObject* observer,
327  int setting, bool value );
328 
330  virtual void slot_observerSettingRemoved( DtObserverObject* observer,
331  int setting );
332 
334  virtual void slot_channelAdded(DtChannelManager* mgr, DtChannel* channel);
335 
337  virtual void slot_channelDestroyed(DtChannelManager* mgr, DtChannel* channel);
338 
340  virtual void slot_windowConfigurationModified( const std::string& deName,
341  const std::string& oldWindowName, const DtWindowConfiguration& config);
342 
344  virtual void slot_onCoordinateSystemChanged();
345 
349  virtual void throttleDatabasePager(DtChannelManager* mgr, DtChannel* channel);
350 
351  protected:
353  void stopUsingModelSetWork( int modelSet );
354 
356  void startUsingModelSetWork( int modelSet );
357 
359  void initializeRenderTextureColor(int format, int sourceFormat, int sourceType);
360 
362  void initializeRenderTextureDepth();
363 
364  void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
365 
366 
367 
368  protected:
369  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
370 
371  osg::ref_ptr<osgViewer::View> myView;
374 
376 
378 
380 
382 
384 
385  osg::ref_ptr<osg::Group> myRoot;
386 
387  //The master 3D camera
388  osg::ref_ptr<DtCameraNode> mySceneCamera;
389 
390  //The 2D camera in screen space(0,0 - w,h)
391  osg::ref_ptr<DtCameraNode> my2DCamera;
392 
393  //The 2D camera in normalize screen space (0,0 - 1,1)
394  osg::ref_ptr<DtCameraNode> myNormalized2DCamera;
395 
397  osg::ref_ptr<osg::Texture2D> myRenderTexture;
398  osg::ref_ptr<osg::Texture2D> myDepthTexture;
399 
401  osg::ref_ptr<DtCameraNode> myRTTCamera;
402 
407 
408  // ex. { "dof", "rainsplash", "oceanspray" }
409  // list of post processor effect names to enable on update
411 
412  osg::Node::NodeMask myOldSceneCameraNodeMask;
413 
415 
417 
418  //flag to use old (pre 2.1) channel offset calculation
419  // set by creating a signal_channelCreated callback and
420  // setting it in there
422 
423 #if 0
424  osg::ref_ptr<osg::DatabaseRequestHandlerCallback> myDatabasePagerCallback;
425 #endif
426  };
427 
431  {
432  public:
434  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
435  };
436 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)