various stuff in opengl demos such as a better model,

stable trackball for the fly navigation mode, and started
to put some GUI elements...
This commit is contained in:
Gael Guennebaud
2008-09-09 18:50:45 +00:00
parent d3a70b7fac
commit 146c9e4494
11 changed files with 530 additions and 142 deletions

View File

@@ -27,12 +27,12 @@
using namespace Eigen;
void Trackball::track(const Vector2i& newPoint2D)
void Trackball::track(const Vector2i& point2D)
{
if (mpCamera==0)
return;
Vector3f newPoint3D;
bool newPointOk = mapToSphere(newPoint2D, newPoint3D);
bool newPointOk = mapToSphere(point2D, newPoint3D);
if (mLastPointOk && newPointOk)
{
@@ -40,12 +40,14 @@ void Trackball::track(const Vector2i& newPoint2D)
float cos_angle = mLastPoint3D.dot(newPoint3D);
if ( ei_abs(cos_angle) < 1.0 )
{
float angle = 2.0 * acos(cos_angle);
mpCamera->rotateAroundTarget(Quaternionf(AngleAxisf(angle, axis)));
float angle = acos(cos_angle);
if (mMode==Around)
mpCamera->rotateAroundTarget(Quaternionf(AngleAxisf(2.*angle, axis))); // *2 to speedup the rotation
else
mpCamera->localRotate(Quaternionf(AngleAxisf(-angle, axis)));
}
}
mLastPoint2D = newPoint2D;
mLastPoint3D = newPoint3D;
mLastPointOk = newPointOk;
}