00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSG_NAVIGATOR_H_
00040 #define _OSG_NAVIGATOR_H_
00041
00042 #include <OSGConfig.h>
00043 #include <OSGSystemDef.h>
00044
00045 #include <OSGWindow.h>
00046 #include <OSGViewport.h>
00047 #include <OSGBaseTypes.h>
00048 #include <OSGLine.h>
00049 #include <OSGNode.h>
00050 #include <OSGVector.h>
00051 #include <OSGQuaternion.h>
00052 #include <OSGIntersectAction.h>
00053 #include <OSGTrackballNavigator.h>
00054 #include <OSGFlyNavigator.h>
00055 #include <OSGWalkNavigator.h>
00056
00057 OSG_BEGIN_NAMESPACE
00058
00062 class OSG_SYSTEMLIB_DLLMAPPING Navigator
00063 {
00064
00065 public:
00066
00067 enum Mode
00068 {
00069 TRACKBALL=0,
00070 FLY,
00071 WALK,
00072 NONE
00073 };
00074
00075 enum State
00076 {
00077 IDLE=0,
00078 ROTATING,
00079 TRANSLATING_XY,
00080 TRANSLATING_Z,
00081
00082 TRANSLATING_ZPLUS=10,
00083 TRANSLATING_ZMINUS
00084 };
00085
00086 enum MouseButton
00087 {
00088 LEFT_MOUSE=0,
00089 MIDDLE_MOUSE,
00090 RIGHT_MOUSE,
00091 UP_MOUSE,
00092 DOWN_MOUSE
00093 };
00094
00095 enum Key
00096 {
00097 LEFT=0,
00098 RIGHT,
00099 FORWARDS,
00100 BACKWARDS,
00101 LEFTROT,
00102 RIGHTROT
00103 };
00104
00105
00106
00110 Navigator();
00111
00113
00117 virtual ~Navigator();
00118
00120
00124 virtual void buttonPress (Int16 button, Int16 x, Int16 y);
00125 virtual void buttonRelease(Int16 button, Int16 x, Int16 y);
00126 virtual void keyPress (Int16 key , Int16 x, Int16 y);
00127 virtual void moveTo ( Int16 x, Int16 y);
00128 virtual void idle (Int16 buttons, Int16 x, Int16 y);
00129
00130 void updateCameraTransformation();
00131
00133
00137 void setMode (Mode new_mode );
00138 void setViewport (ViewportPtr new_viewport);
00139 void setRotationAngle(Real32 new_angle );
00140 void setMotionFactor (Real32 new_factor );
00141 void setFrom (Pnt3f new_from );
00142 void setAt (Pnt3f new_at );
00143 void setDistance (Real32 new_distance);
00144 void setUp (Vec3f new_up );
00145 void set (Pnt3f new_from, Pnt3f new_at, Vec3f new_up);
00146 void set (const Matrix &new_matrix );
00147 bool setAbsolute (bool state );
00148 bool setClickCenter (bool state );
00149
00150 bool setClickNoIntersect (bool state);
00151
00152 void setCameraTransformation(const NodePtr & new_cartn);
00153
00155
00159 const Matrix &getMatrix();
00160 const Pnt3f &getFrom();
00161 const Pnt3f &getAt();
00162 const Vec3f &getUp();
00163 Real32 getDistance();
00164 State getState();
00165 Mode getMode();
00166 Real32 getRotationAngle();
00167 Real32 getMotionFactor();
00168 bool getAbsolute();
00169 bool getClickCenter();
00170 bool getClickNoIntersect();
00171
00172 WalkNavigator* getWalkNavigator() { return &_walker; }
00173
00175
00176 private:
00177
00178
00182 TrackballNavigator _trackball;
00183 FlyNavigator _flyer;
00184 WalkNavigator _walker;
00185
00186 Real32 _rRotationAngle;
00187 Real32 _rMotionFactor;
00188 State _currentState;
00189 Mode _currentMode;
00190 bool _absolute;
00191
00192 ViewportPtr _vp;
00193 NodePtr _cartN;
00194
00195 bool _moved;
00196 bool _clickCenter;
00197 bool _clickNoIntersect;
00198 Real32 _lastX, _lastY;
00199 Pnt3f _ip;
00200 Vec3f _dir;
00201 Matrix theMatrix;
00202
00203 Matrix _NoneMatrix;
00204
00207 void setNoneMatrix(Pnt3f new_from, Pnt3f new_at, Vec3f new_up);
00208
00209 void getIntersectionPoint(Int16 x, Int16 y);
00210 void calcDeltas(Int16 fromX, Int16 fromY, Int16 toX, Int16 toY,
00211 Real32 &distanceX, Real32 &distanceY);
00212
00213 };
00214
00215 OSG_END_NAMESPACE
00216
00217 #define OSGNAVIGATOR_HEADER_CVSID "@(#)$Id: OSGNavigator.h,v 1.6 2002/06/26 16:43:44 istoynov Exp $"
00218
00219 #endif