Commit 78ea0e6e authored by Jan Möbius's avatar Jan Möbius

Handle zoom via modifying the fovy. Fixes incompatibility with SkyDome

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16411 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cf82e735
...@@ -196,6 +196,8 @@ glViewer::glViewer( QGraphicsScene* _scene, ...@@ -196,6 +196,8 @@ glViewer::glViewer( QGraphicsScene* _scene,
timer_ = new QTimer( this ); timer_ = new QTimer( this );
connect( timer_, SIGNAL(timeout()), this, SLOT( slotAnimation()) ); connect( timer_, SIGNAL(timeout()), this, SLOT( slotAnimation()) );
fovyModifier_ = 1.0;
allowRotation_ = true; allowRotation_ = true;
...@@ -418,7 +420,7 @@ void glViewer::updateProjectionMatrix() ...@@ -418,7 +420,7 @@ void glViewer::updateProjectionMatrix()
aspect = 1.0; aspect = 1.0;
// Get fovy // Get fovy
double fovy = OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble(); double fovy = OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble() + fovyModifier_;
glstate_->perspective(fovy, (GLdouble) aspect, glstate_->perspective(fovy, (GLdouble) aspect,
properties_.nearPlane(), properties_.farPlane()); properties_.nearPlane(), properties_.farPlane());
...@@ -1883,14 +1885,37 @@ void glViewer::viewWheelEvent( QWheelEvent* _event) ...@@ -1883,14 +1885,37 @@ void glViewer::viewWheelEvent( QWheelEvent* _event)
if (projectionMode() == PERSPECTIVE_PROJECTION ) if (projectionMode() == PERSPECTIVE_PROJECTION )
{ {
double d = -(double)_event->delta() / 120.0 * 0.2 * factor * properties_.trackballRadius() / 3.0;
translate( ACG::Vec3d(0.0, 0.0, d) ); // Old style zoom (bad as it does not modify the projection but the modelview,
// which kills e.g. Sky Boxes
//double d = -(double)_event->delta() / 120.0 * 0.2 * factor * properties_.trackballRadius() / 3.0;
//translate( ACG::Vec3d(0.0, 0.0, d) );
// Most mouse types work in steps of 15 degrees, in which case the delta value is a
// multiple of 120; i.e., 120 units * 1/8 = 15 degrees
double numDegrees = double(_event->delta()) / 8.0;
double numSteps = numDegrees / 15.0;
// Update the fovy modifier
// This modifier will be added to the default fov to get the zoom
fovyModifier_ += numSteps * factor ;
// Clamp to minimum
if ( (OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble() + fovyModifier_) < 1.0 )
fovyModifier_ = 1.0 -OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble();
// Clamp to maximum
if ( (OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble() + fovyModifier_) > 179.0 )
fovyModifier_ = 179.0-OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble();
updateGL(); updateGL();
} }
else else
{ {
double d = (double)_event->delta() / 120.0 * 0.2 * factor * properties_.orthoWidth(); double d = (double)_event->delta() / 120.0 * 0.2 * factor * properties_.orthoWidth();
properties_.orthoWidth( properties_.orthoWidth() + d ); properties_.orthoWidth( properties_.orthoWidth() + d );
updateProjectionMatrix(); updateProjectionMatrix();
updateGL(); updateGL();
} }
......
...@@ -867,6 +867,7 @@ private: ...@@ -867,6 +867,7 @@ private:
double lastRotationAngle_; double lastRotationAngle_;
QTime lastMoveTime_; QTime lastMoveTime_;
QTimer* timer_; QTimer* timer_;
double fovyModifier_;
QTimer clickTimer_; QTimer clickTimer_;
QTime clickTime_; QTime clickTime_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment