cameramanipulator.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __CAMERAMANIPULATOR_H
00025 #define __CAMERAMANIPULATOR_H
00026
00027 #include "osgforwarddecl.h"
00028
00029 #include <osg/Version>
00030 #if OPENSCENEGRAPH_MAJOR_VERSION >= 3
00031 #include <osgGA/CameraManipulator>
00032 #define OSGCameraManipulator osgGA::CameraManipulator
00033 #else
00034 #include <osgGA/MatrixManipulator>
00035 #define OSGCameraManipulator osgGA::MatrixManipulator
00036 #endif
00037 #include "globaldata.h"
00038 #include <selforg/position.h>
00039 #include <selforg/callbackable.h>
00040 #include "camerahandle.h"
00041
00042 namespace lpzrobots {
00043
00044 class OSGPrimitive;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 class CameraManipulator : public OSGCameraManipulator, public Callbackable
00056 {
00057 public:
00058
00059 CameraManipulator(osg::Node* node, GlobalData& global, CameraHandle& cameraHandle);
00060
00061
00062
00063
00064
00065
00066 virtual const char* className() const { return "Default Camera"; }
00067
00068
00069 virtual void setByMatrix(const osg::Matrixd& matrix);
00070
00071
00072 virtual void setByInverseMatrix(const osg::Matrixd& matrix) {
00073 setByMatrix(osg::Matrixd::inverse(matrix));
00074 }
00075
00076
00077 virtual osg::Matrixd getMatrix() const;
00078
00079
00080
00081 virtual osg::Matrixd getInverseMatrix() const;
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 virtual void setNode(osg::Node*);
00093
00094 virtual const osg::Node* getNode() const;
00095
00096 virtual osg::Node* getNode();
00097
00098
00099 virtual void setHome(const osg::Vec3& eye, const osg::Vec3& view);
00100
00101
00102 virtual void home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
00103
00104 virtual void init(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
00105
00106 virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
00107
00108
00109 virtual void getUsage(osg::ApplicationUsage& usage) const;
00110
00111
00112
00113
00114 virtual void update();
00115
00116
00117
00118
00119 virtual void manipulateAgent( OsgHandle& osgHandle);
00120
00121
00122
00123
00124
00125 virtual void setWatchedAgent(OdeAgent* agent);
00126
00127
00128 virtual OdeAgent* getWatchedAgent();
00129
00130
00131 virtual void doOnCallBack(BackCaller* source, BackCaller::CallbackableType type
00132 = BackCaller::DEFAULT_CALLBACKABLE_TYPE);
00133
00134 protected:
00135
00136 virtual ~CameraManipulator();
00137
00138
00139 virtual void flushMouseEventStack();
00140
00141 virtual void addMouseEvent(const osgGA::GUIEventAdapter& ea);
00142
00143 virtual void computeMatrix();
00144
00145
00146
00147 virtual bool calcMovement();
00148
00149
00150
00151
00152
00153
00154 virtual bool isWatchingAgentDefined();
00155
00156
00157 osg::ref_ptr<const osgGA::GUIEventAdapter> event_old;
00158 osg::ref_ptr<const osgGA::GUIEventAdapter> event;
00159
00160 osg::ref_ptr<osg::Node> node;
00161
00162 float modelScale;
00163 osg::Matrixd pose;
00164
00165 CameraHandle& camHandle;
00166
00167 GlobalData& globalData;
00168
00169
00170 double degreeSmoothness;
00171 double lengthSmoothness;
00172 double degreeAccuracy;
00173 double lengthAccuracy;
00174
00175
00176
00177
00178
00179 virtual void manageAgents(const int& fkey);
00180
00181
00182
00183
00184
00185 virtual void calcMovementByAgent();
00186
00187
00188
00189
00190
00191
00192 virtual void setHomeViewByAgent();
00193 virtual void setHomeEyeByAgent();
00194
00195
00196
00197
00198 virtual void moveBehindAgent();
00199
00200
00201
00202 virtual void centerOnAgent();
00203
00204
00205
00206 virtual void calcManipulationPointHorizontal(float x, float y);
00207
00208 virtual void calcManipulationPointVertical(float x, float y);
00209
00210 virtual void calcManipulationPoint(float x, float y);
00211
00212
00213 };
00214
00215 }
00216
00217 #endif