Added scaling by wheel
This commit is contained in:
parent
1f3fc8f9ce
commit
e2763f9a8b
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.8 2004/06/09 14:01:13 cignoni
|
||||
Heavily restructured. To be completed only rotation works...
|
||||
|
||||
Revision 1.7 2004/05/14 03:15:09 ponchio
|
||||
Redesigned partial version.
|
||||
|
||||
|
@ -128,7 +131,7 @@ void Trackball::ApplyInverse() {
|
|||
/***************************************************************/
|
||||
|
||||
void Trackball::DrawCircle() {
|
||||
const int nside=18;
|
||||
int nside=DH.CircleStep;
|
||||
const double pi2=3.14159265*2.0;
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for(double i=0;i<=nside;i++){
|
||||
|
@ -178,8 +181,8 @@ void Trackball::Draw() {
|
|||
glPushMatrix();
|
||||
ApplyInverse();
|
||||
glBegin(GL_POINTS);
|
||||
for(int i=0;i<Hits.size();++i)
|
||||
glVertex(Hits[i]);
|
||||
for(vector<Point3f>::iterator vi=Hits.begin();vi!=Hits.end();++vi)
|
||||
glVertex(*vi);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
|
@ -187,12 +190,14 @@ void Trackball::Draw() {
|
|||
|
||||
glTranslate(center);
|
||||
glScalef(radius,radius,radius);
|
||||
glScalef(1.0f/track.sca,1.0f/track.sca,1.0f/track.sca);
|
||||
|
||||
|
||||
/// Here start the real drawing stuff
|
||||
|
||||
float amb[4] ={.3f,.3f,.3f,1.0f};
|
||||
float col[4] ={.5f,.5f,.8f,1.0f};
|
||||
float col2[4]={.9f,.9f,1.0f,1.0f};
|
||||
//float col2[4]={.9f,.9f,1.0f,1.0f};
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT);
|
||||
glLineWidth(2.0);
|
||||
glEnable(GL_LIGHTING);
|
||||
|
@ -287,8 +292,14 @@ void Trackball::MouseUp(int /* x */, int /* y */, int button) {
|
|||
current_button &= (~button);
|
||||
SetCurrentAction();
|
||||
}
|
||||
|
||||
void Trackball::MouseWheel(Trackball::Button /* notch */ ) {
|
||||
// it assumes that a notch of 1.0 is a single step of the wheel
|
||||
void Trackball::MouseWheel(float notch ) {
|
||||
if(current_mode == NULL)
|
||||
{
|
||||
SphereMode tm;
|
||||
tm.TrackMode::Apply(this, notch);
|
||||
}
|
||||
current_mode->Apply(this, notch);
|
||||
}
|
||||
|
||||
void Trackball::ButtonDown(Trackball::Button button) {
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.7 2004/06/09 14:01:13 cignoni
|
||||
Heavily restructured. To be completed only rotation works...
|
||||
|
||||
Revision 1.6 2004/05/14 03:15:09 ponchio
|
||||
Redesigned partial version.
|
||||
|
||||
|
@ -73,9 +76,20 @@ namespace vcg {
|
|||
Transform interpolate(const Transform &a, const Transform &b, float t);
|
||||
|
||||
class TrackMode;
|
||||
|
||||
class Trackball: public Transform {
|
||||
class Trackball: public Transform {
|
||||
public:
|
||||
class DrawingHint
|
||||
{
|
||||
public:
|
||||
DrawingHint() { CircleStep=32; }
|
||||
|
||||
int CircleStep;
|
||||
};
|
||||
|
||||
|
||||
DrawingHint DH;
|
||||
|
||||
|
||||
enum Button { BUTTON_NONE = 0x0000,
|
||||
BUTTON_LEFT = 0x0001,
|
||||
BUTTON_MIDDLE = 0x0002,
|
||||
|
@ -94,7 +108,7 @@ namespace vcg {
|
|||
void SetTransform(const Transform &transform, int miilisec = 0);
|
||||
|
||||
//operating
|
||||
void GetView();
|
||||
void GetView();\
|
||||
void Apply();
|
||||
void ApplyInverse();
|
||||
void Draw();
|
||||
|
@ -102,15 +116,15 @@ namespace vcg {
|
|||
void Reset();
|
||||
|
||||
// Internal Drawing stuff
|
||||
static void DrawCircle ();
|
||||
static void DrawPlane();
|
||||
static void DrawPlaneHandle();
|
||||
void DrawCircle ();
|
||||
void DrawPlane();
|
||||
void DrawPlaneHandle();
|
||||
|
||||
//interface
|
||||
void MouseDown(int x, int y, /*Button*/ int button);
|
||||
void MouseMove(int x, int y);
|
||||
void MouseUp(int x, int y, /*Button */ int button);
|
||||
void MouseWheel(Button notch);
|
||||
void MouseWheel(float notch); // it assumes that a notch of 1.0 is a single step of the wheel
|
||||
void ButtonUp(Button button);
|
||||
void ButtonDown(Button button);
|
||||
|
||||
|
@ -154,7 +168,7 @@ namespace vcg {
|
|||
|
||||
int current_button;
|
||||
TrackMode *current_mode;
|
||||
|
||||
|
||||
std::map<int, TrackMode *> modes;
|
||||
|
||||
Similarityf last_track;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.6 2004/06/09 14:01:13 cignoni
|
||||
Heavily restructured. To be completed only rotation works...
|
||||
|
||||
Revision 1.5 2004/05/14 03:15:09 ponchio
|
||||
Redesigned partial version.
|
||||
|
||||
|
@ -48,6 +51,12 @@ Adding copyright.
|
|||
using namespace std;
|
||||
|
||||
using namespace vcg;
|
||||
|
||||
|
||||
void TrackMode::Apply(Trackball *trackball, float WheelNotch) {
|
||||
trackball->track.sca*=pow(1.2f,WheelNotch);
|
||||
};
|
||||
|
||||
/// Compute the plane plane perpedicular to view dir and passing through manip center
|
||||
Plane3f TrackMode::GetViewPlane(const View<float> &camera, const Point3f ¢er) {
|
||||
Point3f vp = camera.ViewPoint();
|
||||
|
@ -143,8 +152,8 @@ bool SphereMode::HitHyper(Point3f center, float radius, Point3f viewpoint, Plan
|
|||
float x1,x2,xval,yval;
|
||||
if(delta>0)
|
||||
{
|
||||
x1= (- b - sqrt(delta))/(2.0*a);
|
||||
x2= (- b + sqrt(delta))/(2.0*a);
|
||||
x1= (- b - sqrt(delta))/(2.0f*a);
|
||||
x2= (- b + sqrt(delta))/(2.0f*a);
|
||||
|
||||
xval=x1; // always take the minimum value solution
|
||||
yval=c/xval; // alternatively it also oould be the other part of the equation yval=-(hitplaney/viewpointx)*xval+hitplaney;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.6 2004/06/09 14:01:13 cignoni
|
||||
Heavily restructured. To be completed only rotation works...
|
||||
|
||||
Revision 1.5 2004/05/14 03:15:09 ponchio
|
||||
Redesigned partial version.
|
||||
|
||||
|
@ -54,6 +57,8 @@ class TrackMode {
|
|||
public:
|
||||
virtual ~TrackMode() {}
|
||||
virtual void Apply(Trackball *trackball, Point3f new_point) = 0;
|
||||
virtual void Apply(Trackball *trackball, float WheelNotch);
|
||||
|
||||
virtual void Draw() {}
|
||||
protected:
|
||||
Plane3f GetViewPlane(const View<float> &view, const Point3f ¢er);
|
||||
|
|
Loading…
Reference in New Issue