Polar mode now working.

This commit is contained in:
Federico Ponchio 2008-10-28 16:43:56 +00:00
parent c0c76bc5b8
commit 632f4842f1
2 changed files with 27 additions and 6 deletions

View File

@ -781,15 +781,30 @@ void PolarMode::Apply (Trackball * tb, Point3f new_point)
float dx = (hitNew.X() - hitOld.X());
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 angley = -dy/(tb->radius * PI2);
tb->track.rot = Quaternionf (anglex,Point3f(0,1,0)) * Quaternionf (angley,Point3f(1,0,0)) * tb->last_track.rot ;
float anglex = dx/(tb->radius * scale);
float angley = -dy/(tb->radius * scale);
enda = alpha + anglex;
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){
DrawSphereIcon(tb,true );
}

View File

@ -1016,16 +1016,22 @@ private:
};
// Polar mode.
/* WARNING this mode is not compatible with the other rotation modes */
class PolarMode:public TrackMode {
public:
PolarMode(): alpha(0), beta(0), enda(0), endb(0) {}
void Apply (Trackball * trackball, Point3f new_point);
const char *Name () {
return "PolarMode";
};
void SetAction();
void Reset();
void Draw (Trackball * trackball);
private:
double alpha, beta; //rotation in y and x axis
double enda, endb; //store intermediate values of alpha and beta
};