1 #include "TrackballBase.hh"
2 #include <Base/Math/Vector3.hh>
3 #include <Gui/biasgl.h>
13 controlledObject_=NULL;
14 UseLeftDouble_ =
true;
26 case KEY_PGUP : Stepsize_*=1.1; cout<<
"[Trackball] stepsize = "
29 case KEY_PGDOWN : Stepsize_*=0.9; cout<<
"[Trackball] stepsize = "
37 const double stepsize,
44 distance = direction.
NormL2();
46 if (
Equal(distance, 0.0))
56 direction.
Multiply(stepsize, direction);
57 res_translation = direction;
62 const int x1,
const int x2,
63 const int y1,
const int y2,
70 glGetIntegerv(GL_VIEWPORT, viewport);
71 double width = viewport[2];
72 double height = viewport[3];
77 R = cam->GetMyselfAsProjectionParameterBase()->GetR();
81 double x = x1 / width * 2.0;
82 double y = y1 / height * 2.0;
87 double z = sqrt(2.0) - x * x - y * y;
102 x = x2 / width * 2.0;
103 y = y2 / height * 2.0;
108 z = sqrt(2.0) - x * x - y * y;
138 A[0] = R[0][2]; A[1] = R[1][2]; A[2] = R[2][2];
149 const int x1,
const int x2,
150 const int y1,
const int y2,
168 directionRight.
MultIP(Stepsize_);
175 directionRight.
MultIP(-Stepsize_);
190 directionUp.
MultIP(-Stepsize_);
197 directionUp.
MultIP(Stepsize_);
206 transl = directionRight + directionUp;
217 glGetIntegerv(GL_VIEWPORT, viewport);
218 int width = viewport[2];
219 int height = viewport[3];
238 rotationAngle *= -1.0;
240 return(rotationAngle);
void GetMoveinViewDirection(GLProjectionParametersInterface *cam, const double stepsize, const BIAS::Vector3< double > &viewdir, BIAS::Vector3< double > &res_translation)
bool SpecialKeyPressed(int key)
react to press of special keys such as F1-F12, ...
void ScalarProduct(const Vector3< T > &argvec, T &result) const
scalar product (=inner product) of two vectors, storing the result in result
void GetTranslation(GLProjectionParametersInterface *cam, const int x1, const int x2, const int y1, const int y2, const BIAS::Vector3< double > &viewdir, BIAS::Vector3< double > &transl)
void SetZero()
set all values to 0
void Multiply(const T &scalar, Vector3< T > &dest) const
Multiplication with a scalar, storing results in destination vector.
void GetViewDirection(GLProjectionParametersInterface *cam, BIAS::Vector3< double > &direction)
Abstract interface class to handle changes in rendering parameters by controllers and in rendering co...
virtual int GetExtrinsics(BIAS::Vector3< double > &C, BIAS::Vector3< double > &up) const =0
void CrossProduct(const Vector3< T > &argvec, Vector3< T > &destvec) const
cross product of two vectors destvec = this x argvec
void SetStepsize(double stepsize)
bool Equal(const T left, const T right, const T eps)
comparison function for floating point values See http://www.boost.org/libs/test/doc/components/test_...
void MultIP(const T &scalar)
double GetRotationAngle(GLProjectionParametersInterface *cam, const int x1, const int x2, const int y1, const int y2, const BIAS::Vector3< double > viewdir)
bool GetRotationAxisAndAngle(GLProjectionParametersInterface *cam, const int x1, const int x2, const int y1, const int y2, BIAS::Vector3< double > &axis, double &angleRAD)
Vector3< T > & Normalize()
normalize this vector to length 1
double NormL2() const
the L2 norm sqrt(a^2 + b^2 + c^2)