Commit 0ad7ef13 authored by Frédéric Larue's avatar Frédéric Larue

Rendering of MetricGrid axes improved.

parent d6a49ac3
......@@ -165,19 +165,28 @@ void MetricGrid::displayGrid( GLViewer *viewer,
strStream << spacing;
QString spacingStr = QString::fromStdString( strStream.str() );
if( isAxisEnabled(X) )
QVector3D camCenter = viewer->viewpointLocation();
QVector3D camFront = viewer->viewRotationMatrix().row(2).toVector3D();
if( isAxisEnabled(X) && QVector3D::dotProduct( QVector3D(spacing,0,0)-camCenter, camFront ) < 0.0f )
{
glColor4ub( 255, 130, 130, alpha );
float alphaX = 1.0f - std::abs(camFront.x());
alphaX = std::max( 0.0f, std::min( 1.0f, (alphaX-0.025f)*10.0f ) );
glColor4ub( 255, 130, 130, alpha*alphaX );
viewer->renderText( spacing, spacing/40.0, spacing/40.0, "X = "+spacingStr );
}
if( isAxisEnabled(Y) )
if( isAxisEnabled(Y) && QVector3D::dotProduct( QVector3D(0,spacing,0)-camCenter, camFront ) < 0.0f )
{
glColor4ub( 200, 255, 200, alpha );
float alphaY = 1.0f - std::abs(camFront.y());
alphaY = std::max( 0.0f, std::min( 1.0f, (alphaY-0.025f)*10.0f ) );
glColor4ub( 200, 255, 200, alpha*alphaY );
viewer->renderText( spacing/40.0, spacing, spacing/40.0, "Y = "+spacingStr );
}
if( isAxisEnabled(Z) )
if( isAxisEnabled(Z) && QVector3D::dotProduct( QVector3D(0,0,spacing)-camCenter, camFront ) < 0.0f )
{
glColor4ub( 130, 130, 255, alpha );
float alphaZ = 1.0f - std::abs(camFront.z());
alphaZ = std::max( 0.0f, std::min( 1.0f, (alphaZ-0.025f)*10.0f ) );
glColor4ub( 130, 130, 255, alpha*alphaZ );
viewer->renderText( spacing/40.0, spacing/40.0, spacing, "Z = "+spacingStr );
}
}
......
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