- Timestamp:
- 11/26/07 22:53:32 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/System/Window/Utilities/OSGTrackballEngine.h
r785 r1021 37 37 \*---------------------------------------------------------------------------*/ 38 38 39 #ifndef _OSG_TRACKBALL NAVIGATOR_H_40 #define _OSG_TRACKBALL NAVIGATOR_H_39 #ifndef _OSG_TRACKBALLENGINE_H_ 40 #define _OSG_TRACKBALLENGINE_H_ 41 41 42 #include "OSGConfig.h" 43 #include "OSGUtilDef.h" 44 45 #include "OSGVector.h" 46 #include "OSGQuaternion.h" 47 #include "OSGViewport.h" 42 #include "OSGNavigatorEngine.h" 48 43 49 44 OSG_BEGIN_NAMESPACE 50 45 51 /*! \brief Navigator for trackball model. See \ref 52 PageSystemWindowNavigatorsTrackball for a description. 46 /*! \brief TrackballEngine provides the trackball navigator functionality. 53 47 */ 54 class OSG_UTIL_DLLMAPPING Trackball Navigator48 class OSG_UTIL_DLLMAPPING TrackballEngine : public NavigatorEngine 55 49 { 50 typedef NavigatorEngine Inherited; 51 56 52 /*========================== PUBLIC =================================*/ 57 53 public: 58 54 59 enum State60 {61 IDLE=0,62 ROTATING,63 TRANSLATING_XY,64 TRANSLATING_Z65 };66 55 67 56 … … 70 59 /*! \{ */ 71 60 72 Trackball Navigator(Real32 rSize=0.8);61 TrackballEngine(Real32 rSize=0.8); 73 62 74 63 /*! \} */ … … 77 66 /*! \{ */ 78 67 79 ~Trackball Navigator();68 ~TrackballEngine(); 80 69 81 70 /*! \} */ … … 84 73 /*! \{ */ 85 74 86 const char *getClassname(void) { return "Trackball Navigator"; }75 const char *getClassname(void) { return "TrackballEngine"; } 87 76 88 77 /*! \} */ … … 91 80 /*! \{ */ 92 81 93 Matrix &getMatrix();94 Pnt3f &getFrom();95 Pnt3f &getAt();96 Vec3f &getUp();97 Real32 getDistance();82 virtual const Pnt3f &getFrom(void); 83 virtual const Pnt3f &getAt(void); 84 virtual const Vec3f &getUp(void); 85 virtual const Matrix &getMatrix(void); 86 virtual Real32 getDistance(void); 98 87 99 88 /*! \} */ … … 102 91 /*! \{ */ 103 92 104 void setAt (Pnt3f new_at); 105 void setFrom (Pnt3f new_from); 106 void setDistance (Real32 new_distance); 107 void setUp (Vec3f new_up); 108 void set (Pnt3f new_from, Pnt3f new_center, Vec3f new_up); 109 void set (Matrix new_matrix); 93 virtual void setFrom(Pnt3f new_from); 94 virtual void setAt(Pnt3f new_at); 95 virtual void setUp(Vec3f new_up); 96 virtual void set(Pnt3f new_from, Pnt3f new_at, Vec3f new_up); 97 virtual void set(const Matrix & new_matrix); 98 virtual void setDistance(Real32 new_distance); 99 100 /*! \} */ 101 /*---------------------------------------------------------------------*/ 102 /*! \name navigator engine callbacks */ 103 /*! \{ */ 104 105 virtual void buttonPress(Int16 button, Int16 x, Int16 y, Navigator* nav); 106 virtual void buttonRelease(Int16 button, Int16 x, Int16 y, Navigator* nav); 107 virtual void keyPress(Int16 key, Int16 x, Int16 y, Navigator* nav); 108 virtual void moveTo( Int16 x, Int16 y, Navigator* nav); 109 virtual void idle(Int16 buttons, Int16 x, Int16 y, Navigator* nav); 110 111 virtual void onViewportChanged(ViewportPtr new_viewport); 110 112 111 113 /*! \} */ … … 119 121 void translateZ (Real32 distance); 120 122 123 121 124 /*! \} */ 122 /*========================== PR IVATE ================================*/123 pr ivate:125 /*========================== PROTECTED ==============================*/ 126 protected: 124 127 125 128 /*---------------------------------------------------------------------*/ … … 127 130 /*! \{ */ 128 131 129 Real32 _rRadius, _rDistance; 130 Matrix _tMatrix, _finalMatrix; 131 State _currentState; 132 Pnt3f _pFrom, _pAt; 132 Real32 _rRadius; 133 Real32 _rDistance; 134 Matrix _tMatrix; 135 Matrix _finalMatrix; 136 Pnt3f _pFrom; 137 Pnt3f _pAt; 133 138 Vec3f _vUp; 139 140 /* temporary values */ 141 Pnt3f _ip; 142 Vec3f _dir; 134 143 135 144 /*! \} */ … … 138 147 139 148 Real32 projectToSphere(Real32 rRadius, Real32 rX, Real32 rY); 149 void getIntersectionPoint(Int16 x, Int16 y, Navigator* nav); 150 void calcDeltas(Int16 , Int16 , Int16 toX, Int16 toY, 151 Real32 &distanceX, Real32 &distanceY, Navigator* nav); 152 153 154 private: 155 /* Not implemented */ 156 TrackballEngine(const TrackballEngine &other); 157 TrackballEngine &operator =(const TrackballEngine &other); 140 158 }; 141 159
