Commit ae7dbc8a authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Near and far planes distances can now be changed.

parent f9e7dfe9
...@@ -174,6 +174,11 @@ void GLViewer::init( DisplayDoF dof ) ...@@ -174,6 +174,11 @@ void GLViewer::init( DisplayDoF dof )
m_View.fovY = 0.0f; m_View.fovY = 0.0f;
setFovY( 65.0f ); setFovY( 65.0f );
m_ChangeNearPlaneMode = false;
m_ChangeFarPlaneMode = false;
m_View.nearPlaneFactor = 0.01f;
m_View.farPlaneFactor = 5.0f;
m_View.distToFocusPoint = 0.0f; m_View.distToFocusPoint = 0.0f;
setDistToFocusPoint( 400.0f ); setDistToFocusPoint( 400.0f );
...@@ -1782,6 +1787,28 @@ void GLViewer::wheelEvent( QWheelEvent* evt ) ...@@ -1782,6 +1787,28 @@ void GLViewer::wheelEvent( QWheelEvent* evt )
{ {
setFovY( fovY() + evt->delta()*M_PI/180.0f ); setFovY( fovY() + evt->delta()*M_PI/180.0f );
} }
else if( m_ChangeNearPlaneMode )
{
double delta = 0.0005 * m_View.nearPlaneFactor * evt->delta();
if( m_View.nearPlaneFactor + delta > 0.0 )
{
m_View.nearPlaneFactor += delta;
m_View.zNear = m_View.nearPlaneFactor * m_View.distToFocusPoint;
m_MustUpdateProjectionMatrix = true;
update();
}
}
else if( m_ChangeFarPlaneMode )
{
double delta = 0.0005 * m_View.farPlaneFactor * evt->delta();
if( m_View.farPlaneFactor + delta > 0.0 )
{
m_View.farPlaneFactor += delta;
m_View.zFar = m_View.farPlaneFactor * m_View.distToFocusPoint;
m_MustUpdateProjectionMatrix = true;
update();
}
}
else else
{ {
double deltaD = -0.0005 * m_SpeedFactor * distToFocusPoint() * evt->delta(); double deltaD = -0.0005 * m_SpeedFactor * distToFocusPoint() * evt->delta();
...@@ -2105,6 +2132,8 @@ void GLViewer::keyPressEvent( QKeyEvent *evt ) ...@@ -2105,6 +2132,8 @@ void GLViewer::keyPressEvent( QKeyEvent *evt )
break; break;
} }
case Qt::Key_N: m_ChangeNearPlaneMode = true; break;
case Qt::Key_F: m_ChangeFarPlaneMode = true; break;
default: emit keyPressed( evt ); default: emit keyPressed( evt );
} }
...@@ -2119,6 +2148,12 @@ void GLViewer::keyPressEvent( QKeyEvent *evt ) ...@@ -2119,6 +2148,12 @@ void GLViewer::keyPressEvent( QKeyEvent *evt )
void GLViewer::keyReleaseEvent( QKeyEvent *evt ) void GLViewer::keyReleaseEvent( QKeyEvent *evt )
{ {
if( evt->key() == Qt::Key_N )
m_ChangeNearPlaneMode = false;
if( evt->key() == Qt::Key_F )
m_ChangeFarPlaneMode = false;
if( !m_SelectionCurrentTool->isSelecting() ) if( !m_SelectionCurrentTool->isSelecting() )
{ {
makeCurrent(); makeCurrent();
...@@ -2398,8 +2433,8 @@ void GLViewer::setDistToFocusPoint( const float d ) ...@@ -2398,8 +2433,8 @@ void GLViewer::setDistToFocusPoint( const float d )
if( d != m_View.distToFocusPoint ) if( d != m_View.distToFocusPoint )
{ {
m_View.distToFocusPoint = d; m_View.distToFocusPoint = d;
m_View.zNear = 0.01 * m_View.distToFocusPoint; m_View.zNear = m_View.nearPlaneFactor * m_View.distToFocusPoint;
m_View.zFar = 5.0 * m_View.distToFocusPoint; m_View.zFar = m_View.farPlaneFactor * m_View.distToFocusPoint;
m_MustUpdateProjectionMatrix = true; m_MustUpdateProjectionMatrix = true;
m_MustUpdateViewMatrix = true; m_MustUpdateViewMatrix = true;
......
...@@ -45,6 +45,8 @@ public: ...@@ -45,6 +45,8 @@ public:
QVector3D focusPoint; QVector3D focusPoint;
float fovY; float fovY;
float distToFocusPoint; float distToFocusPoint;
float nearPlaneFactor;
float farPlaneFactor;
float zNear; float zNear;
float zFar; float zFar;
QMatrix4x4 viewRotationMatrix; QMatrix4x4 viewRotationMatrix;
...@@ -171,6 +173,9 @@ protected: ...@@ -171,6 +173,9 @@ protected:
Frustum m_Frustum; Frustum m_Frustum;
bool m_ChangeNearPlaneMode;
bool m_ChangeFarPlaneMode;
/*****************************\ /*****************************\
| Constructor(s) / destructor | | Constructor(s) / destructor |
\*****************************/ \*****************************/
......
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