Should work as before. I didn't test cylinder and other exotic modes.

This commit is contained in:
Federico Ponchio 2008-02-24 18:05:08 +00:00
parent 82635287c7
commit 654452b177
3 changed files with 20 additions and 8 deletions

View File

@ -24,6 +24,10 @@
History
$Log: not supported by cvs2svn $
Revision 1.26 2008/02/24 14:37:00 ponchio
Restored trackball functionality. Not very much tested, and code will need some
cleanup.
Revision 1.25 2008/02/22 18:57:46 benedetti
first attempt to correct after quaternion ToMatrix() inversion (does not work yet)
@ -173,7 +177,7 @@ void Trackball::DrawPostApply() {
void Trackball::Apply () {
glTranslate (center);
glMultMatrix (track.Matrix ());
glMultMatrix (track.Matrix());
glTranslate (-center);
}
@ -198,10 +202,9 @@ void Trackball::Scale(const float s)
void Trackball::Translate(Point3f tr)
{
// Matrix44f m;
// track.rot.ToMatrix(m);
// track.tra = last_track.tra + m*tr/track.sca;
track.tra = last_track.tra + tr;
Quaternionf irot = track.rot;
irot.Invert();
track.tra = last_track.tra + irot.Rotate(tr)/track.sca;
}
/***************************************************************/

View File

@ -24,6 +24,10 @@
History
$Log: not supported by cvs2svn $
Revision 1.27 2008/02/24 14:37:00 ponchio
Restored trackball functionality. Not very much tested, and code will need some
cleanup.
Revision 1.26 2008/02/15 20:56:41 benedetti
removed some variable initialization related warning, added snap to CylinderMode
@ -170,7 +174,7 @@ void SphereMode::Apply (Trackball * tb, Point3f new_point)
Point3f hitOld = HitSphere (tb, tb->last_point);
Point3f hitNew = HitSphere (tb, new_point);
tb->Hits.push_back (hitNew);
Point3f center = tb->center + tb->track.tra;
Point3f center = tb->center;
Point3f axis = (hitNew - center) ^ (hitOld - center);
// Figure out how much to rotate around that axis.
float phi = Distance (hitNew, hitOld) / tb->radius;

View File

@ -24,6 +24,10 @@
History
$Log: not supported by cvs2svn $
Revision 1.10 2008/02/24 14:37:00 ponchio
Restored trackball functionality. Not very much tested, and code will need some
cleanup.
Revision 1.9 2008/02/22 18:57:47 benedetti
first attempt to correct after quaternion ToMatrix() inversion (does not work yet)
@ -221,7 +225,7 @@ eq cono y=x+sqrt(2);
*/
Point3f HitSphere (Trackball * tb, const Point3f & p)
{
Point3f center = tb->center + tb->track.tra;
Point3f center = tb->center;
Line3fN ln = tb->camera.ViewLineFromWindow (Point3f (p[0], p[1], 0));
Plane3f vp = GetViewPlane (tb->camera, center);
Point3f hitPlane(0,0,0), //intersection view plane with point touched
@ -674,7 +678,8 @@ void DrawSphereIcon (Trackball * tb,bool active)
glPushAttrib (GL_TRANSFORM_BIT |GL_ENABLE_BIT | GL_LINE_BIT | GL_CURRENT_BIT | GL_LIGHTING_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix ();
glTranslate (tb->center);
Point3f center = tb->center + tb->track.InverseMatrix()*tb->center;
glTranslate(center);
glScale (tb->radius);
float amb[4] = { .3f, .3f, .3f, 1.0f };