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