fixed: compile issue
[opensg.git] / Source / System / Window / Utilities / OSGTrackballEngine.h
blob7c34a783f1f75d8dfc4b54cbbdc28866d0b6404d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSG_TRACKBALLENGINE_H_
40 #define _OSG_TRACKBALLENGINE_H_
42 #include "OSGNavigatorEngine.h"
44 OSG_BEGIN_NAMESPACE
46 class Navigator;
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 =================================*/
60 public:
62 /*---------------------------------------------------------------------*/
63 /*! \name Types */
64 /*! \{ */
66 OSG_GEN_INTERNAL_MEMOBJPTR(TrackballEngine);
68 /*! \} */
69 /*---------------------------------------------------------------------*/
70 /*! \name Construction */
71 /*! \{ */
73 static ObjTransitPtr create(Real32 rSize = 0.8f);
75 /*! \} */
76 /*---------------------------------------------------------------------*/
77 /*! \name Class Get */
78 /*! \{ */
80 const char *getClassname(void) { return "TrackballEngine"; }
82 /*! \} */
83 /*---------------------------------------------------------------------*/
84 /*! \name Get */
85 /*! \{ */
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);
93 /*! \} */
94 /*---------------------------------------------------------------------*/
95 /*! \name Set */
96 /*! \{ */
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,
102 Pnt3f new_at,
103 Vec3f new_up );
104 virtual void set (const Matrix &new_matrix );
105 virtual void setDistance( Real32 new_distance);
107 /*! \} */
108 /*---------------------------------------------------------------------*/
109 /*! \name navigator engine callbacks */
110 /*! \{ */
112 virtual void buttonPress (Int16 button,
113 Int16 x,
114 Int16 y,
115 Navigator *nav );
116 virtual void buttonRelease(Int16 button,
117 Int16 x,
118 Int16 y,
119 Navigator *nav );
120 virtual void keyPress (Int16 key,
121 Int16 x,
122 Int16 y,
123 Navigator *nav );
124 virtual void moveTo (Int16 x,
125 Int16 y,
126 Navigator *nav );
127 virtual void idle (Int16 buttons,
128 Int16 x,
129 Int16 y,
130 Navigator *nav );
132 /*! \} */
133 /*---------------------------------------------------------------------*/
134 /*! \name Trackball Transformations */
135 /*! \{ */
137 void rotate (Real32 fromX,
138 Real32 fromY,
139 Real32 toX,
140 Real32 toY );
141 void translateXY(Real32 distanceX,
142 Real32 distanceY);
143 void translateZ (Real32 distance );
145 /*! \} */
146 /*========================== PROTECTED ==============================*/
148 protected:
150 /*---------------------------------------------------------------------*/
151 /*! \name Constructors/Destructor */
152 /*! \{ */
154 TrackballEngine(Real32 rSize = 0.8f);
155 virtual ~TrackballEngine(void );
157 /*! \} */
158 /*---------------------------------------------------------------------*/
159 /*! \name Members */
160 /*! \{ */
162 Real32 _rRadius;
163 Real32 _rDistance;
164 Matrix _tMatrix;
165 Matrix _finalMatrix;
166 Pnt3f _pFrom;
167 Pnt3f _pAt;
168 Vec3f _vUp;
170 /* temporary values */
172 Pnt3f _ip;
173 Vec3f _dir;
175 /*! \} */
176 /*---------------------------------------------------------------------*/
178 void updateFinalMatrix(void);
180 Real32 projectToSphere (Real32 rRadius,
181 Real32 rX,
182 Real32 rY );
184 void getIntersectionPoint(Int16 x,
185 Int16 y,
186 Navigator *nav );
188 void calcDeltas (Int16 ,
189 Int16 ,
190 Int16 toX,
191 Int16 toY,
192 Real32 &distanceX,
193 Real32 &distanceY,
194 Navigator *nav );
196 private:
198 /* Not implemented */
199 TrackballEngine(const TrackballEngine &other);
200 TrackballEngine &operator =(const TrackballEngine &other);
203 OSG_GEN_MEMOBJPTR(TrackballEngine);
205 OSG_END_NAMESPACE
207 #endif