2004-03-25 15:55:25 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2006-02-13 14:10:27 +01:00
|
|
|
Revision 1.8 2004/07/18 06:54:08 cignoni
|
|
|
|
Added Scaling
|
|
|
|
|
2004-07-18 08:54:08 +02:00
|
|
|
Revision 1.7 2004/07/11 22:06:56 cignoni
|
|
|
|
Added scaling by wheel
|
|
|
|
|
2004-07-12 00:06:56 +02:00
|
|
|
Revision 1.6 2004/06/09 14:01:13 cignoni
|
|
|
|
Heavily restructured. To be completed only rotation works...
|
|
|
|
|
2004-06-09 16:01:13 +02:00
|
|
|
Revision 1.5 2004/05/14 03:15:09 ponchio
|
|
|
|
Redesigned partial version.
|
|
|
|
|
2004-05-14 05:15:09 +02:00
|
|
|
Revision 1.4 2004/05/07 12:46:08 cignoni
|
|
|
|
Restructured and adapted in a better way to opengl
|
|
|
|
|
2004-05-07 14:46:08 +02:00
|
|
|
Revision 1.3 2004/04/07 10:54:11 cignoni
|
|
|
|
Commented out unused parameter names and other minor warning related issues
|
|
|
|
|
2004-04-07 12:54:11 +02:00
|
|
|
Revision 1.2 2004/03/25 14:55:25 ponchio
|
|
|
|
Adding copyright.
|
|
|
|
|
2004-03-25 15:55:25 +01:00
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
2004-03-25 15:50:08 +01:00
|
|
|
#ifndef TRACKMODE_H
|
|
|
|
#define TRACKMODE_H
|
|
|
|
|
2004-05-14 05:15:09 +02:00
|
|
|
#include <vcg/space/line3.h>
|
|
|
|
#include <vcg/space/plane3.h>
|
|
|
|
#include <wrap/gui/view.h>
|
2004-03-25 15:50:08 +01:00
|
|
|
|
|
|
|
namespace vcg {
|
2004-05-14 05:15:09 +02:00
|
|
|
|
2004-05-07 14:46:08 +02:00
|
|
|
class Trackball;
|
2004-05-14 05:15:09 +02:00
|
|
|
|
2004-03-25 15:50:08 +01:00
|
|
|
class TrackMode {
|
|
|
|
public:
|
|
|
|
virtual ~TrackMode() {}
|
2004-05-14 05:15:09 +02:00
|
|
|
virtual void Apply(Trackball *trackball, Point3f new_point) = 0;
|
2004-07-12 00:06:56 +02:00
|
|
|
virtual void Apply(Trackball *trackball, float WheelNotch);
|
|
|
|
|
2004-05-14 05:15:09 +02:00
|
|
|
virtual void Draw() {}
|
|
|
|
protected:
|
2004-06-09 16:01:13 +02:00
|
|
|
Plane3f GetViewPlane(const View<float> &view, const Point3f ¢er);
|
2004-05-14 05:15:09 +02:00
|
|
|
Point3f HitViewPlane(Trackball *trackball, const Point3f &p);
|
2004-03-25 15:50:08 +01:00
|
|
|
};
|
2004-05-14 05:15:09 +02:00
|
|
|
|
|
|
|
/* View space modes */
|
|
|
|
|
2004-03-25 15:50:08 +01:00
|
|
|
class SphereMode: public TrackMode {
|
2004-05-14 05:15:09 +02:00
|
|
|
public:
|
|
|
|
void Apply(Trackball *trackball, Point3f new_point);
|
|
|
|
protected:
|
|
|
|
Point3f Hit(Trackball *trackball, const Point3f &p);
|
2004-06-09 16:01:13 +02:00
|
|
|
bool HitHyper(Point3f center, float radius, Point3f viewpoint, Plane3f vp, Point3f hitplane, Point3f &hit) ;
|
|
|
|
|
2004-03-25 15:50:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CylinderMode: public TrackMode {
|
|
|
|
public:
|
2004-06-09 16:01:13 +02:00
|
|
|
CylinderMode(const Line3f &/*line*/, float /*radius = 1*/) {}
|
|
|
|
void Apply(Trackball * /*trackball*/, Point3f /*new_point*/) {}
|
2004-03-25 15:50:08 +01:00
|
|
|
protected:
|
2004-05-14 05:15:09 +02:00
|
|
|
Line3f line;
|
|
|
|
float radius;
|
2004-03-25 15:50:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class PlaneMode: public TrackMode {
|
|
|
|
public:
|
2004-05-14 05:15:09 +02:00
|
|
|
PlaneMode(const Plane3f &pl): plane(pl) {}
|
|
|
|
void Apply(Trackball *trackball, Point3f new_point);
|
2004-03-25 15:50:08 +01:00
|
|
|
protected:
|
2004-05-14 05:15:09 +02:00
|
|
|
Plane3f plane;
|
2004-03-25 15:50:08 +01:00
|
|
|
};
|
|
|
|
|
2006-02-13 14:10:27 +01:00
|
|
|
// Move the object along the Z of the Camera
|
|
|
|
// complement of the Plane mode
|
|
|
|
class ZMode: public TrackMode {
|
|
|
|
public:
|
|
|
|
void Apply(Trackball *trackball, Point3f new_point);
|
|
|
|
};
|
|
|
|
|
2004-03-25 15:50:08 +01:00
|
|
|
class LineMode: public TrackMode {
|
|
|
|
public:
|
2004-06-09 16:01:13 +02:00
|
|
|
LineMode(const Line3f &/*line*/) {}
|
|
|
|
void Apply(Trackball * /*trackball*/, Point3f /*new_point*/) {}
|
2004-03-25 15:50:08 +01:00
|
|
|
protected:
|
2004-05-14 05:15:09 +02:00
|
|
|
Line3f line;
|
2004-03-25 15:50:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScaleMode: public TrackMode {
|
|
|
|
public:
|
2004-07-18 08:54:08 +02:00
|
|
|
void Apply(Trackball *trackball, Point3f new_point);
|
2004-03-25 15:50:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}//namespace
|
|
|
|
|
2004-05-14 05:15:09 +02:00
|
|
|
#endif
|