Added Zmode for moving objects along the perpendicular to the viewplane

This commit is contained in:
Paolo Cignoni 2006-02-13 13:10:27 +00:00
parent c01d03e1ee
commit 07613df38d
2 changed files with 24 additions and 2 deletions

View File

@ -24,6 +24,10 @@
History
$Log: not supported by cvs2svn $
Revision 1.15 2006/01/12 15:40:05 cignoni
Corrected small bugs on rotating after scaling+translating
changed void PlaneMode::Apply and void SphereMode::Apply
Revision 1.14 2005/07/15 16:39:30 callieri
in SphereMode::Hit added a check on the sphere intersection, if no intersection, calculating distance could generate a NAN exception
@ -294,9 +298,17 @@ Point3f SphereMode::Hit(Trackball *tb, const Point3f &p) {
void PlaneMode::Apply(Trackball *tb, Point3f new_point) {
Point3f hitOld = HitViewPlane(tb, tb->last_point);
Point3f hitNew = HitViewPlane(tb, new_point);
Matrix44f m; tb->track.rot.ToMatrix(m);
//Matrix44f m; tb->track.rot.ToMatrix(m);
//tb->track.tra = tb->last_track.tra + Inverse(m)*Point3f(hitNew- hitOld);// orig 2006 01 12
tb->track.tra = tb->last_track.tra + Inverse(m)*Point3f(hitNew- hitOld)/tb->track.sca;;
//tb->track.tra = tb->last_track.tra + Inverse(m)*Point3f(hitNew- hitOld)/tb->track.sca;;
tb->Translate(hitNew- hitOld);
}
void ZMode::Apply(Trackball *tb, Point3f new_point) {
float ScreenHeight= float(tb->camera.viewport[3]-tb->camera.viewport[1]);
float dist=(new_point[1]-tb->last_point[1])/ScreenHeight;
//Matrix44f m; tb->track.rot.ToMatrix(m);
//tb->track.tra = tb->last_track.tra + Inverse(m)*Point3f(0,0,-2*dist)/tb->track.sca;;
tb->Translate(Point3f(0,0,-2*dist));
}

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.8 2004/07/18 06:54:08 cignoni
Added Scaling
Revision 1.7 2004/07/11 22:06:56 cignoni
Added scaling by wheel
@ -96,6 +99,13 @@ protected:
Plane3f plane;
};
// 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);
};
class LineMode: public TrackMode {
public:
LineMode(const Line3f &/*line*/) {}