diff --git a/wrap/gui/trackmode.cpp b/wrap/gui/trackmode.cpp index 91a8eb6c..7a9aa3f7 100644 --- a/wrap/gui/trackmode.cpp +++ b/wrap/gui/trackmode.cpp @@ -772,3 +772,25 @@ void AreaMode::Draw(Trackball * tb) DrawSphereIcon(tb,true ); DrawUglyAreaMode(tb,points,status,old_status,plane,path,rubberband_handle); } + +// Polar mode implementation. +void PolarMode::Apply (Trackball * tb, Point3f new_point) +{ + Point3f hitOld = HitViewPlane (tb, tb->last_point); + Point3f hitNew = HitViewPlane (tb, new_point); + float dx = (hitNew.X() - hitOld.X()); + float dy = (hitNew.Y() - hitOld.Y()); + + const float PI2=6.283185307179586232f; + + 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 ; + +} + +void PolarMode::Draw(Trackball * tb){ + DrawSphereIcon(tb,true ); +} + diff --git a/wrap/gui/trackmode.h b/wrap/gui/trackmode.h index 4efcf8e7..e5e02ca3 100644 --- a/wrap/gui/trackmode.h +++ b/wrap/gui/trackmode.h @@ -1015,6 +1015,20 @@ private: }; +// Polar mode. + +class PolarMode:public TrackMode { +public: + void Apply (Trackball * trackball, Point3f new_point); + + const char *Name () { + return "PolarMode"; + }; + + void Draw (Trackball * trackball); +}; + + }//namespace #endif