Trackball translation corrected

This commit is contained in:
Paolo Cignoni 2005-02-11 11:44:07 +00:00
parent abaae0c2fd
commit 6a41a6ba9b
1 changed files with 10 additions and 4 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.11 2005/02/02 16:46:41 pietroni
some warning corrected
Revision 1.10 2005/01/14 15:44:03 ganovelli Revision 1.10 2005/01/14 15:44:03 ganovelli
PlaneMode completed PlaneMode completed
@ -107,7 +110,8 @@ void SphereMode::Apply(Trackball *tb, Point3f new_point) {
Point3f hitNew=Hit(tb, new_point); Point3f hitNew=Hit(tb, new_point);
// tb->Hits.push_back(hitNew); // tb->Hits.push_back(hitNew);
Point3f axis = (hitNew- tb->center)^(hitOld- tb->center); Point3f center = tb->track.tra+tb->center;
Point3f axis = (hitNew- center)^(hitOld- center);
// Figure out how much to rotate around that axis. // Figure out how much to rotate around that axis.
//float phi=Angle((hitNew- tb->center),(hitOld- tb->center)); //float phi=Angle((hitNew- tb->center),(hitOld- tb->center));
@ -274,9 +278,11 @@ Point3f SphereMode::Hit(Trackball *tb, const Point3f &p) {
} }
void PlaneMode::Apply(Trackball *tb, Point3f new_point) { void PlaneMode::Apply(Trackball *tb, Point3f new_point) {
Point3f hitOld=HitViewPlane(tb, tb->last_point); Point3f hitOld = HitViewPlane(tb, tb->last_point);
Point3f hitNew=HitViewPlane(tb, new_point); Point3f hitNew = HitViewPlane(tb, new_point);
tb->track.tra = tb->last_track.tra + Point3f(hitNew- hitOld); Matrix44f m; tb->track.rot.ToMatrix(m);
tb->track.tra = tb->last_track.tra + Inverse(m)*Point3f(hitNew- hitOld);
} }