00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * This library is free software; you can redistribute it and/or modify it * 00016 * under the terms of the GNU Library General Public License as published * 00017 * by the Free Software Foundation, version 2. * 00018 * * 00019 * This library is distributed in the hope that it will be useful, but * 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00022 * Library General Public License for more details. * 00023 * * 00024 * You should have received a copy of the GNU Library General Public * 00025 * License along with this library; if not, write to the Free Software * 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00027 * * 00028 \*---------------------------------------------------------------------------*/ 00029 /*---------------------------------------------------------------------------*\ 00030 * Changes * 00031 * * 00032 * * 00033 * * 00034 * * 00035 * * 00036 * * 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef _OSG_TRACKBALLNAVIGATOR_H_ 00040 #define _OSG_TRACKBALLNAVIGATOR_H_ 00041 00042 #include <OSGConfig.h> 00043 #include <OSGSystemDef.h> 00044 00045 #include <OSGVector.h> 00046 #include <OSGQuaternion.h> 00047 #include <OSGViewport.h> 00048 00049 OSG_BEGIN_NAMESPACE 00050 00054 class OSG_SYSTEMLIB_DLLMAPPING TrackballNavigator 00055 { 00056 /*========================== PUBLIC =================================*/ 00057 public: 00058 00059 enum State 00060 { 00061 IDLE=0, 00062 ROTATING, 00063 TRANSLATING_XY, 00064 TRANSLATING_Z 00065 }; 00066 00067 00068 /*---------------------------------------------------------------------*/ 00072 TrackballNavigator(Real32 rSize=0.8); 00073 00075 /*---------------------------------------------------------------------*/ 00079 ~TrackballNavigator(); 00080 00082 /*---------------------------------------------------------------------*/ 00086 const char *getClassname(void) { return "TrackballNavigator"; } 00087 00089 /*---------------------------------------------------------------------*/ 00093 Matrix &getMatrix(); 00094 Pnt3f &getFrom(); 00095 Pnt3f &getAt(); 00096 Vec3f &getUp(); 00097 Real32 getDistance(); 00098 00100 /*---------------------------------------------------------------------*/ 00104 void setAt (Pnt3f new_at); 00105 void setFrom (Pnt3f new_from); 00106 void setDistance (Real32 new_distance); 00107 void setUp (Vec3f new_up); 00108 void set (Pnt3f new_from, Pnt3f new_center, Vec3f new_up); 00109 void set (Matrix new_matrix); 00110 00112 /*---------------------------------------------------------------------*/ 00116 void rotate (Real32 fromX, Real32 fromY, 00117 Real32 toX, Real32 toY); 00118 void translateXY(Real32 distanceX, Real32 distanceY); 00119 void translateZ (Real32 distance); 00120 00122 /*========================== PRIVATE ================================*/ 00123 private: 00124 00125 /*---------------------------------------------------------------------*/ 00129 Real32 _rRadius, _rDistance; 00130 Matrix _tMatrix, _finalMatrix; 00131 State _currentState; 00132 Pnt3f _pFrom, _pAt; 00133 Vec3f _vUp; 00134 00137 void updateFinalMatrix(); 00138 00139 Real32 projectToSphere(Real32 rRadius, Real32 rX, Real32 rY); 00140 }; 00141 00142 OSG_END_NAMESPACE 00143 00144 #define OSGTRACKBALLNAVIGATOR_HEADER_CVSID "@(#)$Id: OSGTrackballNavigator.h,v 1.3 2002/05/24 14:45:12 istoynov Exp $" 00145 00146 #endif
1.5.5