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_TRACKBALL_H_
00040 #define _OSG_TRACKBALL_H_
00041
00042 #include <OSGSystemDef.h>
00043 #include <OSGWindowBase.h>
00044 #include <OSGBaseTypes.h>
00045 #include <OSGVector.h>
00046 #include <OSGQuaternion.h>
00047
00048 OSG_BEGIN_NAMESPACE
00049
00051
00052 class OSG_SYSTEMLIB_DLLMAPPING Trackball
00053 {
00054 public:
00055
00056 enum TranslationGen
00057 {
00058 OSGOrientedTranslation = 0x01,
00059 OSGAbsoluteTranslation = 0x02
00060 };
00061
00062 enum Mode
00063 {
00064 OSGCamera = 0x01,
00065 OSGObject = 0x02
00066 };
00067
00068 enum TranslationMode
00069 {
00070 OSGFixedX,
00071 OSGFixedY,
00072 OSGFixedZ,
00073
00074 OSGFree
00075 };
00076
00077 public:
00078 const char *getClassname(void) { return "Trackball"; }
00079
00080 Trackball(Real32 rSize = 1.0);
00081 ~Trackball(void);
00082
00083 void setSum(bool bVal);
00084
00085 void updateRotation(Real32 rLastX, Real32 rLastY,
00086 Real32 rCurrentX, Real32 rCurrentY);
00087 void updatePosition(Real32 rLastX, Real32 rLastY,
00088 Real32 rCurrentX, Real32 rCurrentY);
00089 void updatePositionNeg(Real32 rLastX, Real32 rLastY,
00090 Real32 rCurrentX, Real32 rCurrentY);
00091
00092
00093 void setAutoPositionIncrement(Real32 rVal);
00094 void setAutoPosition(bool bVal);
00095 void setAutoPositionNeg(bool bVal);
00096
00097 void setMode (Mode gMode);
00098 void setTranslationMode (TranslationMode gMode );
00099 void setTranslationScale(Real32 rTranslationScale);
00100 void setTranslationGen (TranslationGen gMode );
00101
00102 void reset(void);
00103
00104 void setStartPosition(Real32 rX, Real32 rY, Real32 rZ,
00105 bool bUpdate = false);
00106 void setStartPosition(Vec3f &gStartPos, bool bUpdate = false);
00107
00108 Vec3f &getPosition (void);
00109
00110 void setStartRotation(Real32 rX, Real32 rY, Real32 rZ, Real32 rW,
00111 bool bUpdate = false);
00112 void setStartRotation(Quaternion &gStartRot, bool bUpdate = false);
00113
00114 void setRotationCenter(const Pnt3f &pRotationCenter);
00115
00116 Quaternion &getRotation (void);
00117
00118 Matrix &getFullExamineMatrix (void);
00119 Matrix &getFullTrackballMatrix(void);
00120
00121 void setSize(Real32 s);
00122 Real32 getSize(void ) const;
00123
00124 private:
00125
00126 bool _bSum;
00127 bool _bAutoPosition;
00128
00129 Mode _gMode;
00130 TranslationMode _gTransMode;
00131 TranslationGen _gTransGen;
00132
00133 Real32 _rAutoPositionStep;
00134 Real32 _rAutoPositionIncrement;
00135
00136 Real32 _rTrackballSize;
00137 Real32 _rTranslationScale;
00138
00139 Quaternion _qVal;
00140 Vec3f _pVal;
00141
00142 Quaternion _qValStart;
00143 Vec3f _pValStart;
00144
00145 Pnt3f _pRotationCenter;
00146
00147 Matrix _fullMatrix;
00148
00149 Trackball(const Trackball &org);
00150 void operator =(const Trackball &org);
00151
00152 protected:
00153
00154
00155 float projectToSphere(Real32 rRadius, Real32 rX, Real32 rY);
00156
00157 };
00158
00159 OSG_END_NAMESPACE
00160
00161 #endif
00162
00163
00164
00165
00166
00167
00168