![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2007 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtOsgChannel.h,v $ $Revision: 1.51 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 00015 #include <vrvOsg/vrvOsg.h> 00016 00017 #include <vrvCore/DtChannel.h> 00018 #include <vrvOsg/DtOsgRenderer.h> 00019 #include <osg/ref_ptr> 00020 #include <osg/Camera> 00021 #include <osgViewer/View> 00022 00023 namespace osg 00024 { 00025 class Matrixd; 00026 } 00027 00028 namespace makVrv 00029 { 00030 class DtChannelSpecificGroup; 00031 class DtOsgWindow; 00032 class DtChannelManager; 00033 class DtWindowConfiguration; 00034 00041 class DT_DLL_VRVOSG DtOsgChannel : public DtChannel 00042 { 00043 public: 00044 00046 DtOsgChannel(DtDe& de, DtWindow* window, DtChannelConfiguration& config); 00047 00049 virtual ~DtOsgChannel(); 00050 00052 virtual void setClearColor(float r,float g,float b, float a); 00053 00057 virtual void setWindow(DtWindow* view); 00058 00060 virtual const DtWindow* window() const; 00061 00063 virtual void setViewport(int x,int y,int width, int height); 00064 00066 virtual void getViewport(int& x,int& y, int& width,int& height) const; 00067 00069 virtual void setCameraPosition(double x, double y, double z); 00070 00072 virtual void setCameraOrientation( double psi, double theta, double phi ); 00073 00078 virtual void setCameraPositionAndOrientation( double x, double y, 00079 double z, double psi, double theta, double phi ); 00080 virtual void setCameraPositionAndOrientation( osg::Vec3d& pos, 00081 osg::Quat& orient ); 00082 00084 virtual void getCameraPositionAndOrientation( osg::Vec3d& position, 00085 osg::Quat& rotation ) const; 00086 00087 virtual void update(); 00088 00090 virtual void connectToObserver(); 00091 00093 virtual void setDynamicNearFar(bool enable); 00094 00097 virtual void setNearFarRatio(double ratio); 00098 00107 virtual void setCameraObject(DtCameraObject* cameraObject); 00108 00112 virtual void setParentCameraObject(DtCameraObject* cameraObject); 00113 00116 virtual void setProjectionMatrixAsPerspective(double fovy, 00117 double aspectRatio, double zNear, double zFar); 00118 00120 virtual void setProjectionMatrixAsFrustum (double left, double right, 00121 double bottom, double top, double zNear, double zFar); 00122 00124 virtual osgViewer::View& view(); 00125 00127 virtual osg::Camera* camera(); 00128 virtual const osg::Camera* camera() const; 00129 00131 virtual osg::Camera* overlayCamera(); 00132 00135 virtual void setProjectionResizePolicy( 00136 DtChannelConfiguration::ProjectionResizePolicy policy); 00137 00140 virtual void updateProjection(); 00141 00142 void projectionUnitsToFrustum( DtChannelConfiguration::ProjectionUnits units, 00143 double &left, double zNear, double &right, double &top, double &bottom ); 00144 00146 virtual void connectChannelToScene(); 00147 00149 virtual bool processMouseEvent( const DtMouseEvent& ev); 00150 00152 virtual bool processKeyboardEvent(const DtKeyEvent & ev); 00153 00155 //virtual DtDynamicOverlay* overlay(); 00156 00158 void getWorldToWindowMatrix( osg::Matrix& worldToWindowMatrix ) const; 00159 00160 virtual void projectToScreen( double dbX, double dbY, double dbZ, 00161 double& screenX, double& screenY, double& screenZ ); 00162 00164 virtual void projectToWorld( double screenX, double screenY, 00165 double& dbX, double& dbY, double& dbZ ); 00166 00167 virtual void warpMouse( float pixelX, float pixelY ); 00168 00170 virtual const std::string& name(); 00171 00172 protected: 00173 void makeObserverToCameraMatrix( osg::Vec3d& orient, 00174 osg::Matrixd& offsetObserverToCamera ); 00175 void makeObserverToCameraMatrix( osg::Quat& qObserverToWorld, 00176 osg::Matrixd& offsetObserverToCamera ); 00177 00179 virtual void calculateNearFar(double& zNear, double& zFar); 00180 00182 virtual void projectFor3D(); 00183 00185 virtual void projectFor2D(); 00186 00187 virtual void stopUsingModelSet( int modelSet ); 00188 virtual void startUsingModelSet( int modelSet ); 00189 00191 virtual void slot_visualizerRootAdded( int modelSet, int visualType ); 00192 00194 virtual void slot_observerModelSetChanged( DtObserverObject* observer, 00195 int modelSet ); 00196 00198 virtual void slot_observerSettingChanged( DtObserverObject* observer, 00199 int setting, bool value ); 00200 00202 virtual void slot_observerSettingRemoved( DtObserverObject* observer, 00203 int setting ); 00204 00206 virtual void slot_channelAdded(DtChannelManager* mgr, DtChannel* channel); 00207 00209 virtual void slot_channelDestroyed(DtChannelManager* mgr, DtChannel* channel); 00210 00212 virtual void slot_windowConfigurationModified( const std::string& deName, 00213 const std::string& oldWindowName, const DtWindowConfiguration& config); 00214 00216 void slot_onCoordinateSystemChanged(); 00217 00221 virtual void throttleDatabasePager(DtChannelManager* mgr, DtChannel* channel); 00222 00223 protected: 00224 typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap; 00225 00226 osg::ref_ptr<osgViewer::View> myView; 00227 DtOsgWindow* myOsgWindow; 00228 00229 //The 2D camera in screen space(0,0 - w,h) 00230 osg::ref_ptr<osg::Camera> my2DCamera; 00231 00232 //The 2D camera in normalize screen space (0,0 - 1,1) 00233 osg::ref_ptr<osg::Camera> myNormalized2DCamera; 00234 00235 bool myOverlayNeedsResize; 00236 bool myIsUsingTrackballManipulator; 00237 bool myCoordinateSystemChanged; 00238 }; 00239 00242 class DT_DLL_VRVOSG DtOsgChannelCreator : public DtChannelCreator 00243 { 00244 00245 public: 00247 virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config); 00248 00249 }; 00250 00251 } 00252