Commit 09dea6e0 authored by Frédéric Larue's avatar Frédéric Larue

Metric grid display behavior modified.

parent 8360ac8c
......@@ -18,27 +18,37 @@ void MetricGrid::displayGrid( GLViewer *viewer,
const double spacing,
const GLubyte alpha )
{
const QVector3D camCenter = viewer->viewpointLocation();
const QVector3D camFront = viewer->viewRotationMatrix().row(2).toVector3D();
const double spacing2 = 2.0 * spacing;
const double step = 0.1 * spacing;
float alphaX = 1.0f - std::abs(camFront.x());
alphaX = std::max( 0.0f, std::min( 1.0f, (alphaX-0.025f)*10.0f ) );
float alphaY = 1.0f - std::abs(camFront.y());
alphaY = std::max( 0.0f, std::min( 1.0f, (alphaY-0.025f)*10.0f ) );
float alphaZ = 1.0f - std::abs(camFront.z());
alphaZ = std::max( 0.0f, std::min( 1.0f, (alphaZ-0.025f)*10.0f ) );
// Display the points representing the current grid scale.
glPointSize( 5.0f );
glBegin( GL_POINTS );
if( isAxisEnabled(X) )
{
glColor4ub( 255, 100, 100, alpha );
glColor4ub( 255, 100, 100, alpha*alphaX );
glVertex3d( spacing, 0, 0 );
glVertex3d( -spacing, 0, 0 );
}
if( isAxisEnabled(Y) )
{
glColor4ub( 100, 255, 100, alpha );
glColor4ub( 100, 255, 100, alpha*alphaY );
glVertex3d( 0, spacing, 0 );
glVertex3d( 0, -spacing, 0 );
}
if( isAxisEnabled(Z) )
{
glColor4ub( 100, 100, 255, alpha );
glColor4ub( 100, 100, 255, alpha*alphaZ );
glVertex3d( 0, 0, spacing );
glVertex3d( 0, 0, -spacing );
}
......@@ -165,27 +175,18 @@ void MetricGrid::displayGrid( GLViewer *viewer,
strStream << spacing;
QString spacingStr = QString::fromStdString( strStream.str() );
QVector3D camCenter = viewer->viewpointLocation();
QVector3D camFront = viewer->viewRotationMatrix().row(2).toVector3D();
if( isAxisEnabled(X) && QVector3D::dotProduct( QVector3D(spacing,0,0)-camCenter, camFront ) < 0.0f )
{
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) && QVector3D::dotProduct( QVector3D(0,spacing,0)-camCenter, camFront ) < 0.0f )
{
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) && QVector3D::dotProduct( QVector3D(0,0,spacing)-camCenter, camFront ) < 0.0f )
{
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