Polar mode now working.
This commit is contained in:
parent
c0c76bc5b8
commit
632f4842f1
|
@ -781,15 +781,30 @@ void PolarMode::Apply (Trackball * tb, Point3f new_point)
|
||||||
float dx = (hitNew.X() - hitOld.X());
|
float dx = (hitNew.X() - hitOld.X());
|
||||||
float dy = (hitNew.Y() - hitOld.Y());
|
float dy = (hitNew.Y() - hitOld.Y());
|
||||||
|
|
||||||
const float PI2=6.283185307179586232f;
|
const float scale = 0.5*M_PI; //sensitivity of the mouse
|
||||||
|
const float top = 0.9*M_PI/2; //maximum top view angle
|
||||||
|
|
||||||
float anglex = dx/(tb->radius * PI2);
|
float anglex = dx/(tb->radius * scale);
|
||||||
float angley = -dy/(tb->radius * PI2);
|
float angley = -dy/(tb->radius * scale);
|
||||||
|
enda = alpha + anglex;
|
||||||
tb->track.rot = Quaternionf (anglex,Point3f(0,1,0)) * Quaternionf (angley,Point3f(1,0,0)) * tb->last_track.rot ;
|
endb = beta + angley;
|
||||||
|
if(endb > top) endb = top;
|
||||||
|
if(endb < -top) endb = -top;
|
||||||
|
tb->track.rot = Quaternionf (endb, Point3f(1,0,0)) *
|
||||||
|
Quaternionf (enda, Point3f(0,1,0)) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PolarMode::SetAction() {
|
||||||
|
alpha = enda;
|
||||||
|
beta = endb;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PolarMode::Reset() {
|
||||||
|
alpha = beta = enda = endb = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolarMode::Draw(Trackball * tb){
|
void PolarMode::Draw(Trackball * tb){
|
||||||
DrawSphereIcon(tb,true );
|
DrawSphereIcon(tb,true );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1016,16 +1016,22 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Polar mode.
|
// Polar mode.
|
||||||
|
/* WARNING this mode is not compatible with the other rotation modes */
|
||||||
|
|
||||||
class PolarMode:public TrackMode {
|
class PolarMode:public TrackMode {
|
||||||
public:
|
public:
|
||||||
|
PolarMode(): alpha(0), beta(0), enda(0), endb(0) {}
|
||||||
void Apply (Trackball * trackball, Point3f new_point);
|
void Apply (Trackball * trackball, Point3f new_point);
|
||||||
|
|
||||||
const char *Name () {
|
const char *Name () {
|
||||||
return "PolarMode";
|
return "PolarMode";
|
||||||
};
|
};
|
||||||
|
void SetAction();
|
||||||
|
void Reset();
|
||||||
void Draw (Trackball * trackball);
|
void Draw (Trackball * trackball);
|
||||||
|
private:
|
||||||
|
double alpha, beta; //rotation in y and x axis
|
||||||
|
double enda, endb; //store intermediate values of alpha and beta
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue