1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSG_TRACKBALLENGINE_H_
40 #define _OSG_TRACKBALLENGINE_H_
42 #include "OSGNavigatorEngine.h"
48 /*! \brief TrackballEngine provides the trackball navigator functionality.
49 \ingroup GrpUtilNavigation
50 \ingroup GrpLibOSGUtil
53 class OSG_UTIL_DLLMAPPING TrackballEngine
: public NavigatorEngine
55 typedef NavigatorEngine Inherited
;
56 typedef TrackballEngine Self
;
58 /*========================== PUBLIC =================================*/
62 /*---------------------------------------------------------------------*/
66 OSG_GEN_INTERNAL_MEMOBJPTR(TrackballEngine
);
69 /*---------------------------------------------------------------------*/
70 /*! \name Construction */
73 static ObjTransitPtr
create(Real32 rSize
= 0.8f
);
76 /*---------------------------------------------------------------------*/
77 /*! \name Class Get */
80 const char *getClassname(void) { return "TrackballEngine"; }
83 /*---------------------------------------------------------------------*/
87 virtual const Pnt3f
&getFrom (void);
88 virtual const Pnt3f
&getAt (void);
89 virtual const Vec3f
&getUp (void);
90 virtual const Matrix
&getMatrix (void);
91 virtual Real32
getDistance(void);
94 /*---------------------------------------------------------------------*/
98 virtual void setFrom ( Pnt3f new_from
);
99 virtual void setAt ( Pnt3f new_at
);
100 virtual void setUp ( Vec3f new_up
);
101 virtual void set ( Pnt3f new_from
,
104 virtual void set (const Matrix
&new_matrix
);
105 virtual void setDistance( Real32 new_distance
);
108 /*---------------------------------------------------------------------*/
109 /*! \name navigator engine callbacks */
112 virtual void buttonPress (Int16 button
,
116 virtual void buttonRelease(Int16 button
,
120 virtual void keyPress (Int16 key
,
124 virtual void moveTo (Int16 x
,
127 virtual void idle (Int16 buttons
,
133 /*---------------------------------------------------------------------*/
134 /*! \name Trackball Transformations */
137 void rotate (Real32 fromX
,
141 void translateXY(Real32 distanceX
,
143 void translateZ (Real32 distance
);
146 /*========================== PROTECTED ==============================*/
150 /*---------------------------------------------------------------------*/
151 /*! \name Constructors/Destructor */
154 TrackballEngine(Real32 rSize
= 0.8f
);
155 virtual ~TrackballEngine(void );
158 /*---------------------------------------------------------------------*/
170 /* temporary values */
176 /*---------------------------------------------------------------------*/
178 void updateFinalMatrix(void);
180 Real32
projectToSphere (Real32 rRadius
,
184 void getIntersectionPoint(Int16 x
,
188 void calcDeltas (Int16
,
198 /* Not implemented */
199 TrackballEngine(const TrackballEngine
&other
);
200 TrackballEngine
&operator =(const TrackballEngine
&other
);
203 OSG_GEN_MEMOBJPTR(TrackballEngine
);