Esempio n. 1
0
void drawInfo()
{
	if ( visibleInfo )
	{
	GLText text;	
	text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
	text.enterTextInputMode();
	text.draw("####### SUBJECT #######");
	text.draw("#");
	text.draw("# Name: " +parameters.find("SubjectName"));
	text.draw("# IOD: " +stringify<double>(interoculardistance));
	text.draw("#");
	text.draw("# trial: " +stringify<double>(trialNumber));
	text.draw("#");
	text.draw("# orientation: " +stringify<double>(trial.getCurrent()["Orientation"]*(str2num<double>(parameters.find("ThetaSign")))+theta));
	text.draw("#");
	/*
	for ( std::map<string,double>::iterator iter = trial.getCurrent().begin(); iter!=trial.getCurrent().end();++iter)
	{
		text.draw(iter->first + ": " + stringify<double>(iter->second));
	}
	*/
	text.draw("#######################");
/*	text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
	if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);
	text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
	
	if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(9)+stringify< Eigen::Matrix<double,1,3> > (markers[9].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);

	text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" );
	text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" );
	text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY));
	text.draw(" ");
	text.draw("jitter = " +stringify<double>(jitter));
	text.draw(" ");
	text.draw("size = " +stringify<double>((xedge + jitter)));
	text.draw("xedge = " +stringify<double>(xedge));
	text.draw(" ");
	text.draw("depth = " +stringify<double>(zedge + (jitter/2)));
	text.draw("zedge = " +stringify<double>(zedge));
*/	text.leaveTextInputMode();
	}
}
Esempio n. 2
0
/**
 * @brief drawTrial
 */
void drawTrial()
{
    if (!experimentStarted)
        return;

    if (drawInfo)
    {
        double radiusX = util::str2num<double>(parameters.find("RadiusX"));
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        glDisable(GL_TEXTURE_3D);
        GLText text;
        text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite);
        text.enterTextInputMode();
        text.draw("CurvatureZ = " + util::stringify<double>(CurvatureZ));
        text.draw("CurvatureZ x RadiusX= " + util::stringify<double>(CurvatureZ*radiusX));
        text.draw("Factor CurvatureZ = " + util::stringify<double>(trial.getCurrent().at("CurvatureZ")));
        text.draw("IOD x k = " + util::stringify<double>(interoculardistance));
        if (parameters.find("UsePolkaDots")=="1")
            text.draw("Actual curvature controlled= "+util::stringify<double>(surface.parabolicCylinderSurface.curvature));
        text.leaveTextInputMode();
        glPopAttrib();
    }

    if ( trialMode == PROBEMODE )
        drawProbe();

    if (trialMode == STIMULUSMODE )
        drawStimulus();
}
Esempio n. 3
0
void drawInfo()
{   switch ( headCalibrationDone )
    {   case 0:
        {   allVisibleHead = isVisible(markers[17].p) && isVisible(markers[18].p) && isVisible(markers[1].p) && isVisible(markers[2].p) && isVisible(markers[3].p) ;
            if ( allVisibleHead )
                glClearColor(0.0,1.0,0.0,1.0); //green light
            else
                glClearColor(1.0,0.0,0.0,1.0); //red light
        }
        break;
        case 1:
        {   
		if ( fingerCalibrationDone==0 )
		{
			GLText text;
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
            text.enterTextInputMode();
            text.draw("EL  " + stringify<int>(eyeLeft.x() ) + " " + stringify<int>(eyeLeft.y() ) + " " + stringify<int>(eyeLeft.z()));
            text.draw("ER " + stringify<int>(eyeRight.x() ) + " " + stringify<int>(eyeRight.y() ) + " " + stringify<int>(eyeRight.z()));
			text.draw("INDEX " + stringify<int>(realIndex.x() ) + " " + stringify<int>(realIndex.y() ) + " " + stringify<int>(realIndex.z()));
			text.draw("REFLECTED INDEX " + stringify<int>(realIndex.x() ) + " " + stringify<int>(realIndex.y() ) + " " + stringify<int>(realIndex.z()));
			text.leaveTextInputMode();
		}
		}
        break;
    }
    // end if ( headCalibrationDone )
}
Esempio n. 4
0
/*** INFO ***/
void drawInfo()
{
	if ( visibleInfo )
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		glColor3fv(glWhite);
		text.draw(experiment_title);
		text.draw("");

		if(!expFinished)
		{
			text.draw("####### SUBJECT #######");
			text.draw("#");
			text.draw("# Name: " +parameters.find("SubjectName"));
			text.draw("#");
			text.draw("# trial: " +stringify<double>(trialNumber));
			text.draw("#");
			text.draw("#######################\n\n");
			text.draw(" ");

			text.draw("time: " +stringify<int>(timer.getElapsedTimeInMilliSec()));
		} else
		{
			text.draw("The experiment is finished.");
		}

		text.leaveTextInputMode();
	}
}
void drawInfo()
{
	if ( visibleInfo )
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();
		text.draw("####### SUBJECT #######");
		text.draw("#");
		text.draw("# Name: " +parameters.find("SubjectName"));
		text.draw("# IOD: " +stringify<double>(interoculardistance));
		text.draw("#");
		text.draw("# trial: " +stringify<double>(trialNumber));
		text.draw("#");
		text.draw("#######################");
		
		text.draw(" ");
		text.draw(" ");
		text.draw("Press ENTER to start.");

		text.leaveTextInputMode();
	}

	if ( expFinished )
	{
		GLText text2;	
		text2.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text2.enterTextInputMode();
		text2.draw("The experiment is finished.");
		text2.leaveTextInputMode();
	}

}
void drawInfo()
{
	if ( headCalibrationDone!=3 )
	{
    GLText text;
    text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite, GLUT_BITMAP_HELVETICA_18);
    text.enterTextInputMode();
    if ( passiveMode )
    text.draw( "Passive"  );
    else
    text.draw(" Active " );
    if ( orthographicMode )
    text.draw(" Ortho " );
    else
    text.draw( "Perspective " );
    
    string row1 = stringify< Eigen::Matrix<double,1,4> >( objectPassiveTransformation.matrix().row(0) );
    string row2 = stringify< Eigen::Matrix<double,1,4> >( objectPassiveTransformation.matrix().row(1) );
    string row3 = stringify< Eigen::Matrix<double,1,4> >( objectPassiveTransformation.matrix().row(2) );
    
    text.draw( row1 );
    text.draw( row2 );
    text.draw( row3 );
    text.draw( stringify<int> (factors["Rotation"]) );
	text.draw( stringify< Eigen::Vector3d >(projPointEyeRight) );
    text.draw( stringify<int>(instantPlaneSlant));
	text.leaveTextInputMode();
	}
}
Esempio n. 7
0
void drawTrial()
{
    if (!experimentStarted)
    {
        GLText text;
        text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glRed);
        text.enterTextInputMode();
        text.draw("Press ENTER key to start the experiment");
        text.leaveTextInputMode();
        return;
    }

    if (drawInfo)
    {
        GLText text;
        text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glRed);
        text.enterTextInputMode();
        text.draw(util::stringify<int>(totalTimer.getElapsedTimeInMilliSec()));
        text.leaveTextInputMode();
    }
    switch ( trialMode )
    {
    case INITIALADAPTATION:
    {
        drawFixation();
    }
    case FIXATIONMODE:
    {   drawFixation();
    }
    break;
    case PROBEMODE :
    {   drawProbe();
    }
    break;
    case STIMULUSMODE:
    {
        drawRedDotsPlane();
    }
    break;
    }

    if ( useCircularMask )
        circleMask(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,circularMaskRadius);

    glGetError();
}
void drawStimulus()
{
	if (fingerCalibrationDone==3 && checkHandAtStart && isStimulusDrawn)
	{
	
	glLoadIdentity();

	// ###### draw rotated stimulus (adjusted) ######
	glTranslated(0.0,0,trial.getCurrent().first["AbsDepth"] + jitter);

	firstD = trial.getCurrent().second->getCurrentStaircase()->getState();

	if( !allVisibleFingers && !moveToPartIV)
		drawNoFingers();
	
	if(fingersShown)
		drawFingers();

	if(!pause)
	{
	
		if(part == 1 && started)
		{
			drawLetter(condition); // draw L or P
			if(moveToPartII)
				part += 1;
		} else if (part == 2)
		{
			drawCross();
			if(moveToPartIII)
				part += 1;
		} else if (part == 3)
		{
			drawTrial(firstD); // draw first triple of rods
			if(moveToPartIV)
				part += 1;
		} else if (part == 4)
		{
			drawBlack();
		}
	} else 
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glRed,GLUT_BITMAP_TIMES_ROMAN_24);
		text.enterTextInputMode();
		for(int i=0;i<13;i++)
		text.draw("");
		text.draw("                                                           BREAK");
		text.leaveTextInputMode();
		timer.stop();
	}
		

	glLoadIdentity();

	}
}
void drawCross()
{
	GLText text;	
	text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glRed,GLUT_BITMAP_TIMES_ROMAN_24);
	text.enterTextInputMode();
	for(int i=0;i<13;i++)
		text.draw("");
	text.draw("                                                             +");
	text.leaveTextInputMode();
}
void drawLetter(int letter)
{
	if (letter <= 0) // vision (L)
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glRed,GLUT_BITMAP_TIMES_ROMAN_24);
		text.enterTextInputMode();
		for(int i=0;i<13;i++)
			text.draw("");    
		text.draw("                                                             L");
		text.leaveTextInputMode();
	} else // pointing
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glRed,GLUT_BITMAP_TIMES_ROMAN_24);
		text.enterTextInputMode();
		for(int i=0;i<13;i++)
			text.draw("");
		text.draw("                                                             P");
		text.leaveTextInputMode();
	}
}
Esempio n. 11
0
void drawInfo()
{
	glDisable(GL_COLOR_MATERIAL);
	glDisable(GL_BLEND);
	glDisable(GL_LIGHTING);

	GLText text;

	text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);

//	text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);

	text.enterTextInputMode();

	glColor3fv(glWhite);
	text.draw("# stim height: ");// +stringify<double>(stimulus_height));

	text.leaveTextInputMode();
}
Esempio n. 12
0
void drawInfo()
{
    markers = optotrak.getAllPoints();
    if ( headCalibrationDone==0 )
    {
        allVisibleHead = isVisible(markers[17]) && isVisible(markers[18]) && isVisible(markers[1]) && isVisible(markers[2]) && isVisible(markers[3]) ;
        allVisibleModel = (markers[10]+markers[14]+markers[19]+markers[20]).norm() < 1E20;
        if ( allVisibleHead )
            glClearColor(0.0,1.0,0.0,1.0); //green light
        else
            glClearColor(1.0,0.0,0.0,1.0); //red light
    }

    GLText text;
    text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
    text.enterTextInputMode();
    text.draw("Head is visible? " + stringify<int>(allVisibleHead));
    text.draw("Full model is visible? " + stringify<bool>(allVisibleModel));
    text.draw( stringify<double>((markers[14]-modelCoordinates.getFinger()).norm()));
    text.leaveTextInputMode();
}
Esempio n. 13
0
void drawInfo()
{
    if ( !infoDrawn )
        return;
    GLText text;
    text.init(SCREEN_WIDTH, SCREEN_HEIGHT,glWhite);
    text.enterTextInputMode();
    string strfactors;
    for ( map<string,double>::iterator iter = factors.begin(); iter!=factors.end(); ++iter)
    {
        text.draw( (iter->first) + "= " + util::stringify<int>( (int )(iter->second)) );
    }
    switch ( headCalibrationDone )
    {
    case 0:
    {
        if ( allVisibleHead )
            text.draw("OK! Press SPACEBAR");
        else
            text.draw("---");
    }
    break;
    case 1:
    case 2:
    {
        text.draw( "EL " + stringify<int>(eyeLeft.x() ) + " " + stringify<int>(eyeLeft.y() ) + " " + stringify<int>(eyeLeft.z()) );
        text.draw( "ER " + stringify<int>(eyeRight.x() ) + " " + stringify<int>(eyeRight.y() ) + " " + stringify<int>(eyeRight.z()) );
        text.draw("EC " + stringify<int>(cyclopeanEye.x())+" " + stringify<int>(cyclopeanEye.y())+" " + stringify<int>(cyclopeanEye.z()));
        text.draw("Dist " + stringify<int>(cyclopeanEye.z()-focalDistance+60.0));
        text.draw(" ");
        text.draw( "PITCH " + stringify<int>(toDegrees(headEyeCoords.getPitch())));
        text.draw( "YAW " + stringify<int>(toDegrees(headEyeCoords.getYaw())));
        text.draw( "ROLL " + stringify<int>(toDegrees(headEyeCoords.getRoll())));
    }
    break;
    }
    text.leaveTextInputMode();
}
void drawInfo()
{
	GLText text;	
	text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
	text.enterTextInputMode();

	text.draw("-----------LINEAR ACTUATORS-----------");
	text.draw("Press 7 to toggle motors");
	text.draw("Motor: " + stringify<int>(which_axis%2));		
	text.draw(" ");
	text.draw("Press w to increase desired position, or s to decrease desired position");
	text.draw("Then press 8 to move");
	text.draw(" ");
	text.draw("desired position = " + stringify<double>(phi_distance));
	text.draw(" ");
	text.draw("-----------STEPPER-----------");
	text.draw("Press q to increase desired theta, or a to decrease desired theta");
	text.draw("Then press 5 to move");
	text.draw(" ");
	text.draw("desired theta = " + stringify<double>(step_theta));
	text.draw(" ");

	text.leaveTextInputMode();
}
/*** INFO ***/
void drawInfo()
{
	if ( visibleInfo )
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		glColor3fv(glWhite);
		if(experiment)
			text.draw("####### SUBJECT #######");
		if(training)
			text.draw("####### THIS IS JUST A TRAINING #######");
		text.draw("#");
		text.draw("# Name: " +parameters.find("SubjectName"));
		text.draw("# IOD: " +stringify<double>(interoculardistance));
		text.draw("#");
		text.draw("# trial: " +stringify<double>(trialNumber));
		text.draw("#");
		text.draw("#######################\n\n");
		text.draw(" ");

		// check if mirror is calibrated
		if ( abs(mirrorAlignment - 45.0) < 0.2 )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));

		// check if monitor is calibrated
		if ( screenAlignmentY < 89.0 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));

		if ( abs(screenAlignmentZ) < 89.4 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));

		glColor3fv(glWhite);
		// X and Z coords of simulated fixation
		text.draw("# Fixation Z = " +stringify<double>(markers.at(screen1).p.x()-120.0)+ " [mm]");
		text.draw("# Fixation X = " +stringify<double>(markers.at(screen1).p.z()+363.0)+ " [mm]");
		text.draw(" ");

		glColor3fv(glWhite); 
		text.draw(" " );
		text.draw("time: " +stringify<int>(timer.getElapsedTimeInMilliSec()));
		text.draw("experiment = " +stringify<int> (experiment));
		text.draw("training = " +stringify<int> (training));
		text.draw("isTrialDone = " +stringify<int> (isTrialDone));
		text.draw("stimulus = " +stringify<int> (stimulus));

		text.leaveTextInputMode();
	}

	if ( expFinished )
	{
		GLText text2;	
		text2.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text2.enterTextInputMode();
		text2.draw("The experiment is finished.");
		text2.leaveTextInputMode();
	}
}
Esempio n. 16
0
void drawInfo()
{
	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);

		GLText text;

		if ( gameMode )
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		else
			text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		switch ( headCalibrationDone )
			{
		case 0:
			{
			if ( allVisibleHead )
				text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
			else
				text.draw("Be visible with the head and glasses");
			}
			break;
		case 1:
		case 2:
			{
			if ( allVisiblePatch )
				text.draw("Move the head in the center");
			else
				text.draw("Be visible with the patch");
			}
			break;
		case 3:	// When the head calibration is done then calibrate the fingers
			{
			switch ( fingerCalibrationDone )
				{
			case 0:
				text.draw("Press F to record platform markers");
				break;
			case 1:
				text.draw("Move index on platform markers to record ghost finger tips, then press F");
				break;
			case 2:
				text.draw("Move index to rigidbody tip to define starting position, then press F");
				break;
			case 3:
				text.draw("Finger calibration successfull!");
				break;
				}
			}
			break;
			}

	text.draw("####### SUBJECT #######");
	text.draw("#");
	text.draw("# Name: " +parameters.find("SubjectName"));
	text.draw("# IOD: " +stringify<double>(interoculardistance));
	text.draw("#");
	text.draw("# trial: " +stringify<double>(trialNumber));
	text.draw("#");
	text.draw("# obj depth: " +stringify<double>(trial.getCurrent()["RelDepthObj"] + dz));
	text.draw("#");
	/*
	for ( std::map<string,double>::iterator iter = trial.getCurrent().begin(); iter!=trial.getCurrent().end();++iter)
	{
		text.draw(iter->first + ": " + stringify<double>(iter->second));
	}
	*/
	text.draw("#######################");
	text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
	text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );

	if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);
	text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
	
	if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );

	if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

/*	if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );
*/
	glColor3fv(glWhite);

	text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" );
	text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" );
	text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY));
	text.draw("Index= " +stringify< Eigen::Matrix<double,1,3> >(index.transpose()));
	text.draw("Timer= " + stringify<int>(timer.getElapsedTimeInMilliSec()) );
	text.draw("Trial= " + stringify<int>(trialNumber));
	text.draw("Index Speed= " + stringify<double>(markers[14].v.norm()));
//	text.draw("Frame= " + stringify< double >(lastPos[0].z() ));
	text.draw("Trial= " + stringify<int>(timeStim));
	text.draw("FrontRod= " + stringify<double>( (estdepth/2) + (estsd * trial.getCurrent()["ConstStim"])));
	text.leaveTextInputMode();
	}
}
/*************************** FUNCTIONS ***********************************/
void drawInfo()
{
	if (paused)
		visibleInfo = true;

	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);

		GLText text;

		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		
		text.enterTextInputMode();
        
        glColor3fv(glWhite);
		text.draw("####### EXPERIMENTER INSTRUCTIONS #######");

		if (!objectsForward)
		{
			text.draw("Press F to bring platform forward");
		}
        if ( objectsForward && (startPosCalibration==0) && (fingerCalibrationDone==0))
		{
			text.draw("Press F to record platform markers");
		}
        if ( objectsForward && (startPosCalibration==0) && (fingerCalibrationDone==1) )
		{
			text.draw("Move index and thumb on platform markers to record ghost finger tips, then press F");
		}
		if ( objectsForward && (startPosCalibration==0) && (fingerCalibrationDone==2) && allVisibleFingers) 
		{
			text.draw("Move index and thumb to starting position, then press F");
		}
        if ( objectsForward && (startPosCalibration==1) && (fingerCalibrationDone==2)) 
		{
			text.draw("Mount the display board on the platform, then press F.");
		}
		if ( objectsForward && (startPosCalibration==2) && (fingerCalibrationDone==2)) 
		{
			text.draw("Press F to record position of left object (use straw).");
		}
		if ( objectsForward && (startPosCalibration==3) && (fingerCalibrationDone==2)) 
		{
			text.draw("Press F to record position of right object (use straw).");
		}
		if ( objectsForward && (startPosCalibration==4) && (fingerCalibrationDone==2) && allVisibleFingers) 
		{
			text.draw("Press F to begin!");
		}
		text.draw("#########################################");
		text.draw(" ");

		text.draw("####### SUBJECT #######");
		text.draw("#");
		text.draw("# Name: " +parameters.find("SubjectName"));
		text.draw("#");
		text.draw("# Trial: " +stringify<int>(trialNumber));
		text.draw("#");
		text.draw("#######################");
		text.draw("StartPosCalibration = " + stringify<int>(startPosCalibration) );
		text.draw("FingerCalibration = " + stringify<int>(fingerCalibrationDone) );
		text.draw(" ");
        
		text.draw("Calibration Platform Markers" );
		if ( isVisible(markers[15].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Thumb Calibration Point (15) "+stringify< Eigen::Matrix<double,1,3> >(markers[15].p.transpose())+ " [mm]" );

		if ( isVisible(markers[16].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Index Calibration Point (16) "+stringify< Eigen::Matrix<double,1,3> >(markers[16].p.transpose())+ " [mm]" );

		if ( isVisible(markers[10].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Straw Marker (10) "+stringify< Eigen::Matrix<double,1,3> >(markers[10].p.transpose())+ " [mm]" );

		glColor3fv(glWhite);
		text.draw(" ");
		text.draw("Thumb" );
		if ( isVisible(markers[20].p) && isVisible(markers[21].p) && isVisible(markers[22].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(20)+stringify< Eigen::Matrix<double,1,3> > (markers[20].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(21)+stringify< Eigen::Matrix<double,1,3> > (markers[21].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(22)+stringify< Eigen::Matrix<double,1,3> > (markers[22].p.transpose())+ " [mm]" );

		glColor3fv(glWhite);
		text.draw(" ");
		text.draw("Index" );
		if ( isVisible(markers[19].p) && isVisible(markers[23].p) && isVisible(markers[24].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(11)+stringify< Eigen::Matrix<double,1,3> > (markers[19].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(12)+stringify< Eigen::Matrix<double,1,3> > (markers[23].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[24].p.transpose())+ " [mm]" );

		glColor3fv(glGreen);
        text.draw(" ");
		text.draw("Index= " +stringify< Eigen::Matrix<double,1,3> >(index.transpose()));
		text.draw("Thumb= " +stringify< Eigen::Matrix<double,1,3> >(thumb.transpose()));
        text.draw(" ");
		text.draw("Trial= " + stringify<int>(trialNumber));
		text.draw("Frame= " + stringify<double>(frameNumber));
        text.draw("Timer= " + stringify<int>(timer.getElapsedTimeInMilliSec()) );
        text.draw(" ");
		
		text.draw("Target Object : " + stringify<int>(currentObj));
		if (handAtStart)
		{
			glColor3fv(glGreen);
			text.draw("Hand at start.");
		}
		else
		{
			glColor3fv(glWhite);
			text.draw("Hand in flight.");
		}

		text.draw(" ");

		
		if(reachedObject)
		{
            glColor3fv(glGreen);
			text.draw("Object Reached!");
		}
		else
		{
			glColor3fv(glRed);
			text.draw("Distance to object= " + stringify<double>(grip_distanceToTarget));
		}

		text.leaveTextInputMode();
    }
}
// Provide text instructions for calibration, as well as information about status of experiment
void drawInfo()
{
	if (finished)
		visibleInfo = true;

	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);
		GLText text;
		if ( gameMode )
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		else
			text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		if (finished) {
			glColor3fv(glWhite);
			text.draw("The experiment is over. Thank you! :)");
		}else{

			switch (fingerCalibration)
			{
			case 0:
				text.draw("Expose three and upper pin");
				break;
			case 1:
				text.draw("Expose three and lower pin");
				break;
			case 2:
				text.draw("Grasp the pins, expose three and posts, press F");
				break;
			case 3:
				text.draw("Place hand in start position, then press F");
				break;
			case 4:
				text.draw("Touch the position of the left object with your index finger, then press F");
				break;
			case 5:
				text.draw("Touch the position of the right object with your index finger, then press F");
				break;
			case 6:
				text.draw("Press F to begin!");
				break;
			} // end switch(fingerCalibration)

            /////// Header ////////
			text.draw("####### ####### #######");
			text.draw("#");
			//text.draw("# Name: " +parameters.find("SubjectName"));
			text.draw("# Name: " +parameters[0].find("SubjectName"));
			text.draw("# IOD: " +stringify<double>(interoculardistance));
			text.draw("# Block: " +stringify<double>(block+1));
			text.draw("# Trial: " +stringify<double>(trialNumber));
            
            /////// Mirror and Screen Alignment ////////
			if ( abs(mirrorAlignment - 45.0) < 0.2 )
				glColor3fv(glGreen);
			else
				glColor3fv(glRed);
			text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));
			if ( screenAlignmentY < 89.0 )
				glColor3fv(glRed);
			else
				glColor3fv(glGreen);
			text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));
			if ( abs(screenAlignmentZ) < 89.0 )
				glColor3fv(glRed);
			else
				glColor3fv(glGreen);
			text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));
            
            /////// Finger Calibration ////////
			glColor3fv(glWhite);
			text.draw("#######################");
			text.draw("Calibration Step= " + stringify<int>(fingerCalibration) );

			glColor3fv(glWhite);
			text.draw("Calibration Platform" );
			if ( allVisiblePlatform3 )
				glColor3fv(glGreen);
			else
				glColor3fv(glRed);
			text.draw("Platform Three "
				+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]\n"
				+stringify< Eigen::Matrix<double,1,3> > (markers[11].p.transpose())+ " [mm]\n"
				+stringify< Eigen::Matrix<double,1,3> > (markers[12].p.transpose())+ " [mm]" );
			if ( isVisible(markers[1].p) )
				glColor3fv(glGreen);
			else
				glColor3fv(glRed);
			text.draw("Index Marker " + stringify<int>(1)
				+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
			if ( isVisible(markers[2].p) )
				glColor3fv(glGreen);
			else
				glColor3fv(glRed);
			text.draw("Thumb Marker " + stringify<int>(2)
				+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
			
            /////// Only displayed during calibration ////////
            glColor3fv(glWhite);
			if (fingerCalibration!=7){

				glColor3fv(glWhite);
				text.draw(" " );
				text.draw("Index" );
				if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Marker " + stringify<int>(13)
					+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
				text.draw("Marker " + stringify<int>(14)
					+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
				text.draw("Marker " + stringify<int>(16)
					+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

				glColor3fv(glWhite);
				text.draw(" " );
				text.draw("Thumb" );
				if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Marker " + stringify<int>(15)
					+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
				text.draw("Marker " + stringify<int>(17)
					+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
				text.draw("Marker " + stringify<int>(18)
					+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );
			}
            
            /////// Index and Thumb Positions ////////
			glColor3fv(glWhite);
			text.draw("--------------------");
			if (allVisibleIndex)
				glColor3fv(glGreen);
			else
				glColor3fv(glRed);
			text.draw("Index= " +stringify< Eigen::Matrix<double,1,3> >(index.transpose()));
			if (allVisibleThumb)
				glColor3fv(glGreen);
			else
				glColor3fv(glRed);
			text.draw("Thumb= " +stringify< Eigen::Matrix<double,1,3> >(thumb.transpose()));
			glColor3fv(glWhite);
			text.draw("--------------------");
            
            /////// Extra Info ////////
			glColor3fv(glGreen);
			text.draw("Timer= " + stringify<int>(timer.getElapsedTimeInMilliSec()) );
			text.draw("Frame= " + stringify<int>(frameN));
			glColor3fv(glWhite);
			text.draw("--------------------");
			glColor3fv(glGreen);
			text.draw("Distance To Object = " + stringify<double>(distanceGripCenterToObject));
			text.draw("Distance To Start = " + stringify<double>(distanceGripCenterToHome));
			//text.draw("Object Size Check = " + stringify<double>(distanceBetweenSurfaces));
			glColor3fv(glWhite);
			if(handAtStart){
				text.draw("Hand is in starting position.");
			}
			if(started){
				text.draw("Grasp in progress...");
			}
			if(reachedObject){
				text.draw("Object reached!");
			}
            if (training){
                text.draw("TRAINING MODE");
            }
		}
		text.leaveTextInputMode();
		glEnable(GL_COLOR_MATERIAL);
		glEnable(GL_BLEND);
		glEnable(GL_LIGHTING);
	}
}
Esempio n. 19
0
void drawInfo()
{
	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);

		GLText text;

		if ( gameMode )
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		else
			text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		switch (fingerCalibrationDone)
		{
			case 0:
				text.draw("Calibration object and index marker are not visible.");		
				break;

			case 1:
				{
					glColor3fv(glGreen);
					text.draw("Index marker has been detected and calibrated. Waiting for Thumb marker to be visible...");	
				} break;

			case 2:
				{
					glColor3fv(glGreen);
					text.draw("Index marker has been detected and calibrated.");	
					text.draw("Thumb marker has been detected and calibrated.");	
					glColor3fv(glWhite);
					text.draw("Touch the two outer markers with the fingerpads then press F (fingers and calibration object visible)");
				} break;

			case 3:
				text.draw("Set home position then press F to start the demo");		
				break;
		}

	if(interoculardistance>0.0)
	{
		glColor3fv(glWhite);
		text.draw(" ");
		text.draw("####### SUBJECT #######");
		text.draw("#");
		text.draw("# Name: " +parameters.find("SubjectName"));
	} else {
		text.draw(" ");
		text.draw(" ");
		text.draw(" ");
	}
	text.draw("# IOD: " +stringify<double>(interoculardistance));
	if ( abs(mirrorAlignment - 45.0) < 0.2 )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));

	if(interoculardistance>0.0)
	{
		glColor3fv(glWhite);
		text.draw("#");
		text.draw("# trial: " +stringify<double>(trialNumber));
		text.draw("#");
		text.draw("#######################");
		text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
		text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );
		
		glColor3fv(glWhite);
		text.draw("Calibration Platform" );
		
		if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		
		text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
	
		glColor3fv(glWhite);
		text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );

		glColor3fv(glWhite);
		text.draw(" " );
		text.draw("Mirror" );

		if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );

		glColor3fv(glWhite);
		text.draw(" " );
		text.draw("Index" );

		if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

		glColor3fv(glWhite); 
		text.draw(" " );
		text.draw("Thumb" );

		if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );

		glColor3fv(glWhite);

		text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" );
		text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" );
		text.draw("Index= " +stringify< Eigen::Matrix<double,1,3> >(index.transpose()));
		text.draw("Thumb= " +stringify< Eigen::Matrix<double,1,3> >(thumb.transpose()));
		text.draw("Timer= " + stringify<int>(timer.getElapsedTimeInMilliSec()) );
		text.draw("Trial= " + stringify<int>(trialNumber));
		text.draw(stringify<double>(abs(mirrorAlignment - 45.0)));
		text.leaveTextInputMode();
	}
	}
}
Esempio n. 20
0
void drawInfo()
{   if ( infoDraw )
    {   glDisable(GL_COLOR_MATERIAL);
        glDisable(GL_BLEND);
        glDisable(GL_LIGHTING);

        GLText text;

        if ( gameMode )
            text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
        else
            text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
        text.enterTextInputMode();

        switch ( headCalibrationDone )
        {
        case 0:
        {   if ( allVisibleHead )
                text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
            else
                text.draw("Be visible with the head and glasses");
        }
        break;
        case 1:
        case 2:
        {   if ( allVisiblePatch )
                text.draw("Cyclopean(x,y,z)= " + stringify<int>((eyeRight.x()+eyeLeft.x())/2)+", "+ stringify<int>((eyeRight.y()+eyeLeft.y())/2)+", "+ stringify<int>((eyeRight.z()+eyeLeft.z())/2)+", " );
            else
                text.draw("Be visible with the patch");
        }
        break;
        case 3:  // When the head calibration is done then calibrate the fingers
        {   switch ( fingerCalibrationDone )
            {
            case 0:
                text.draw("Press F to record platform markers");
                break;
            case 1:
                text.draw("Move index and thumb on platform markers to record ghost finger tips, then press F");
                break;
            case 2:
            {
                text.draw("Move index and thumb to rigidbody tip to define starting position, then press F");
            }
            break;
            }
        }
        break;
        }
        if ( headCalibrationDone==3 && fingerCalibrationDone==3 )
        {   text.draw("Phase 0 Trial number= " + stringify<int>(block0TrialNumber));
            text.draw("Phase 1 Trial number= " + stringify<int>(block1TrialNumber));
            text.draw("Phase 2 Trial number= " + stringify<int>(block2TrialNumber));
            text.draw("Trial mode " + stringify<int>(trialMode ));
            text.draw("DrawingTrialFrame= " + stringify<int>(drawingTrialFrame));
            text.draw("IsDrawing?= " + stringify<int>(isDrawing));
            text.draw("VisualRod= " + stringify<Eigen::Matrix<double,1,3> >(visualRodCenter.transpose()) );
            text.draw("HapticRod= " + stringify<Eigen::Matrix<double,1,3> >(hapticRodCenter.transpose()) );
            text.draw("AdaptOffsets= " + stringify< vector<double> >(adaptOffsets) );
            text.draw("ThisAdaptOffset= " + stringify< double >(adaptOffsets.at(block1TrialNumber)) );
            text.draw("Index= " + stringify< Eigen::Matrix<double,1,3> >(indexCoords.getP1().p ));
            text.draw("Thumb= " + stringify< Eigen::Matrix<double,1,3> >(thumbCoords.getP1().p ));
            text.draw("GlobTime= " + stringify<int>(globalTimer.getElapsedTimeInMilliSec()));
            if ( block.at("Phase")!=1 )
            {
                text.draw("CurrentFactor= " + stringify<int>(factors.at("Distances")) );
                text.draw("Remaining= " + stringify<int>( trial.getRemainingTrials() ));
            }
        }

        text.leaveTextInputMode();
    }
}
Esempio n. 21
0
void drawInfo()
{
	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);

		GLText text;

		if ( gameMode )
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		else
			text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		switch ( headCalibrationDone )
			{
		case 0:
			{
			if ( allVisibleHead )
				text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
			else
				text.draw("Be visible with the head and glasses");
			}
			break;
		case 1:
		case 2:
			{
			if ( allVisiblePatch )
				text.draw("Move the head in the center");
			else
				text.draw("Be visible with the patch");
			}
			break;
		case 3:	// When the head calibration is done then calibrate the fingers
			{
			switch ( fingerCalibrationDone )
				{
			case 0:
				text.draw("Press F to record platform markers");
				break;
			case 1:
				text.draw("Move index and thumb on platform markers to record ghost finger tips, then press F");
				break;
			case 2:
				text.draw("Move index and thumb to rigidbody tip to define starting position, then press F");
				break;
			case 3:
				text.draw("Finger calibration successfull!");
				break;
				}
			}
			break;
			}

	if ((GetKeyState(VK_CAPITAL) & 0x0001)!=0)
	{
	  text.draw("#");
	  text.draw("#");
	  text.draw("# ----------------------------> Caps Lock ON!");
	  text.draw("#");
	  text.draw("#");
	}

	text.draw("####### SUBJECT #######");
	text.draw("#");
	text.draw("# Name: " +parameters.find("SubjectName"));
	text.draw("# IOD: " +stringify<double>(interoculardistance));
	text.draw("#");
	if ( abs(mirrorAlignment - 45.0) < 0.2 )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("# Mirror Alignment = " + stringify<double>(mirrorAlignment));
	glColor3fv(glWhite);
	text.draw("#");
	text.draw("#######################");
	text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
	text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );

	glColor3fv(glWhite);
	text.draw("Calibration Platform" );

	if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);
	text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );

	glColor3fv(glWhite);
	text.draw(" " );
	text.draw("Mirror" );

	if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );

	glColor3fv(glWhite);
	text.draw(" " );
	text.draw("Index" );

	if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

	glColor3fv(glWhite);
	text.draw(" " );
	text.draw("Thumb" );

	if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );

	glColor3fv(glWhite);

	text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY));
	text.draw("Index= " +stringify< Eigen::Matrix<double,1,3> >(index.transpose()));
	text.draw("Thumb= " +stringify< Eigen::Matrix<double,1,3> >(thumb.transpose()));
	text.draw("Timer= " + stringify<int>(timer.getElapsedTimeInMilliSec()) );
	text.draw("Frame= " + stringify<int>(frameN));
	text.draw("Training= " + stringify<int>(training));
	glColor3fv(glRed);
	text.draw("CurSize= " + stringify<int>(trial[round].getCurrent()["Size"]));	
	text.leaveTextInputMode();
	}else
	{

	glDisable(GL_COLOR_MATERIAL);
	glDisable(GL_BLEND);
	glDisable(GL_LIGHTING);
	GLText text1;

	if ( gameMode )
		text1.init(SCREEN_WIDTH,SCREEN_HEIGHT,glBlue,GLUT_BITMAP_HELVETICA_18);
	else
		text1.init(640,480,glBlue,GLUT_BITMAP_HELVETICA_12);
	text1.enterTextInputMode();

	text1.draw("                                                                                                                                                                                   Round= " + stringify<int>(round));
	text1.draw("  ");
	text1.draw("                                                                                                                                                                                   #-NOW-#");

	if(training)
		text1.draw("                                                                                                                                                                                   Training");
	else
		text1.draw("                                                                                                                                                                                   Catch");
	text1.draw("                                                                                                                                                                                   Trial= " + stringify<int>(trialNumber));

	text1.draw("                                                                                                                                                                                   SizeNow= " + stringify<int>(sizeNow));
	text1.draw("  ");
	text1.draw("                                                                                                                                                                                   #-NEXT-#");
	glColor3fv(glRed);
	text1.draw("                                                                                                                                                                                   SizeNext= " + stringify<int>(sizeNext));


	text1.leaveTextInputMode();
	}
}
/**
 * @brief drawInfo
 */
void drawInfo()
{   if ( infoDraw )
    {   glDisable(GL_COLOR_MATERIAL);
        glDisable(GL_BLEND);
        glDisable(GL_LIGHTING);
        GLText text;
        if ( gameMode )
            text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
        else
            text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
        text.enterTextInputMode();
        text.draw("Marker5= " + stringify<Eigen::Matrix<double,1,3> >(markers.at(5).p.transpose()) );
        switch ( headCalibrationDone )
        {
        case 0:
        {   if ( allVisibleHead )
                text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
            else
                text.draw("Be visible with the head and glasses");
        }
        break;
        case 1:
        case 2:
        {   if ( allVisiblePatch )
                text.draw("Cyclopean(x,y,z)= " + stringify<int>((eyeRight.x()+eyeLeft.x())/2)+", "+ stringify<int>((eyeRight.y()+eyeLeft.y())/2)+", "+ stringify<int>((eyeRight.z()+eyeLeft.z())/2)+", " );
            else
                text.draw("Be visible with the patch");
        }
        break;
        case 3:  // When the head calibration is done then calibrate the fingers
        {   switch ( fingerCalibrationDone )
            {
            case 0:
                text.draw("Press F to record platform markers");
                break;
            case 1:
                text.draw("Move INDEX on platform markers to record ghost finger tips, then press F");
                break;
			case 2:
                text.draw("Move THUMB on platform markers to record ghost finger tips, then press F");
                break;
			case 3:
                text.draw("Move BOTH INDEX AND THUMB to rigidbody tip, then press F");
				break;
            }
        }
        break;
        }
        if ( headCalibrationDone==3 && fingerCalibrationDone==4 )
        {   text.draw("Trial mode " + stringify<int>(trialMode ));
            text.draw("ThumbProjectedInside " + stringify<int>(thumbProjectedInside));
            text.draw("DrawingTrialFrame= " + stringify<int>(drawingTrialFrame));
            text.draw("TrialFrame= " + stringify<int>(trialFrame));
            text.draw("IsDrawing?= " + stringify<int>(isDrawing));
            text.draw("VisualRod= " + stringify<Eigen::Matrix<double,1,3> >(visualStimCenter.transpose()) );
            text.draw("Index= " + stringify< Eigen::Matrix<double,1,3> >(indexCoords.getP1().p ));
            text.draw("Thumb= " + stringify< Eigen::Matrix<double,1,3> >(thumbCoords.getP1().p ));
            text.draw("GlobTime= " + stringify<int>(globalTimer.getElapsedTimeInMilliSec()));
            text.draw("TrialTimer= " + stringify<int>(trialTimer.getElapsedTimeInMilliSec()));
			text.draw("FingersTime= " + stringify<int>(fingersTimer.getElapsedTimeInMilliSec()));
        }
        //text.draw("Gain=" + stringify<double>(factors.getCurrent().at("Gain")));
        text.leaveTextInputMode();
    }
}
Esempio n. 23
0
void drawInfo()
{
    if ( visibleInfo )
    {
        GLText text;
        text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
        text.enterTextInputMode();

        switch (fingerCalibrationDone)
        {
        case 0:
            text.draw("Calibration object and index marker are not visible.");
            break;

        case 1:
        {
            glColor3fv(glGreen);
            text.draw("Index marker has been detected and calibrated. Waiting for Thumb marker to be visible...");
        }
        break;

        case 2:
        {
            glColor3fv(glGreen);
            text.draw("Index marker has been detected and calibrated.");
            text.draw("Thumb marker has been detected and calibrated.");
            glColor3fv(glWhite);
            text.draw("Touch the two outer markers with the fingerpads then press F (fingers and calibration object visible)");
        }
        break;

        case 3:
            text.draw("Set home position then press F to start the demo");
            break;
        }
        glColor3fv(glWhite);
        text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );
        text.draw(" ");
        if(experiment)
            text.draw("####### SUBJECT #######");
        if(training)
            text.draw("####### THIS IS JUST A TRAINING #######");
        text.draw("#");
        text.draw("# Name: " +parameters.find("SubjectName"));
        text.draw("# IOD: " +stringify<double>(interoculardistance));
        text.draw("#");
        text.draw("# trial: " +stringify<double>(trialNumber));
        text.draw("#");
        text.draw("#######################\n\n");
        text.draw(" ");

        // check if mirror is calibrated
        if ( abs(mirrorAlignment - 45.0) < 0.2 )
            glColor3fv(glGreen);
        else
            glColor3fv(glRed);
        text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));

        // check if monitor is calibrated
        if ( screenAlignmentY < 89.0 )
            glColor3fv(glRed);
        else
            glColor3fv(glGreen);
        text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));
        if ( abs(screenAlignmentZ) < 89.0 )
            glColor3fv(glRed);
        else
            glColor3fv(glGreen);
        text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));
        glColor3fv(glWhite);
        // X and Z coords of simulated fixation
        text.draw("# Fixation Z = " +stringify<double>(markers[19].p.x()-120.0)+ " [mm]");
        text.draw("# Fixation X = " +stringify<double>(markers[19].p.z()+363.0)+ " [mm]");
        text.draw(" ");

        glColor3fv(glWhite);
        text.draw("Calibration Platform" );

        if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
            glColor3fv(glGreen);
        else
            glColor3fv(glRed);

        text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
        text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );

        if ( isVisible(markers[3].p) )
            glColor3fv(glGreen);
        else
            glColor3fv(glRed);
        text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );

        glColor3fv(glWhite);
        text.draw(" " );
        text.draw("Index" );

        if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
            glColor3fv(glGreen);
        else
            glColor3fv(glRed);
        text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
        text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
        text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

        glColor3fv(glWhite);
        text.draw(" " );
        text.draw("Thumb" );

        if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
            glColor3fv(glGreen);
        else
            glColor3fv(glRed);
        text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
        text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
        text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );

        glColor3fv(glWhite);
        text.draw(" " );
        text.draw("time: " +stringify<int>(timer.getElapsedTimeInMilliSec()));
        text.draw("Index = " +stringify< Eigen::Matrix<double,1,3> > (ind.transpose()));
        text.draw("Thumb = " +stringify< Eigen::Matrix<double,1,3> > (thu.transpose()));
        text.draw("Home = " +stringify< Eigen::Matrix<double,1,3> > (home_position.transpose()));
        text.draw("Dist To Home = " +stringify<double> (dist_to_home));
        text.draw("experiment = " +stringify<int> (experiment));
        text.draw("training = " +stringify<int> (training));

        text.leaveTextInputMode();
    }

    if ( expFinished )
    {
        GLText text2;
        text2.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
        text2.enterTextInputMode();
        text2.draw("The experiment is finished.");
        text2.leaveTextInputMode();
    }

}
Esempio n. 24
0
void drawInfo()
{
	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);

		GLText text;

		if ( gameMode )
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		else
			text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		switch ( headCalibrationDone )
			{
		case 0:
			{
			if ( allVisibleHead )
				text.draw("==== Head Calibration OK ==== Press Spacebar to continue");
			else
				text.draw("Be visible with the head and glasses");
			}
			break;
		case 1:
		case 2:
			{
			if ( allVisiblePatch )
				text.draw("Move the head in the center");
			else
				text.draw("Be visible with the patch");
			}
			break;
		case 3:	// When the head calibration is done then calibrate the fingers
			{
			switch ( fingerCalibrationDone )
				{
			case 0:
				text.draw("Press F to record platform markers");
				break;
			case 1:
				text.draw("Move index and thumb on platform markers to record ghost finger tips, then press F");
				break;
			case 2:
				text.draw("Move index and thumb to rigidbody tip to define starting position, then press F");
				break;
			case 3:
				text.draw("Finger calibration successfull!");
				break;
				}
			}
			break;
			}

	text.draw("####### SUBJECT #######");
	text.draw("#");
	text.draw("# Name: " +parameters.find("SubjectName"));
	text.draw("# IOD: " +stringify<double>(interoculardistance));
	text.draw("#");
	text.draw("#######################");
	text.draw("HeadCalibration= " + stringify<int>(headCalibrationDone) );
	text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );

	if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
	
	glColor3fv(glWhite);
	text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
	
	if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );

	if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

	if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
		glColor3fv(glGreen);
	else
		glColor3fv(glRed);
	text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
	text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );

	glColor3fv(glWhite);

	text.draw("EyeRight= "+stringify< Eigen::Matrix<double,1,3> > (eyeRight.transpose())+ " [mm]" );
	text.draw("EyeLeft= "+stringify< Eigen::Matrix<double,1,3> > (eyeLeft.transpose())+ " [mm]" );
	text.draw("Alignment(X,Y)= " +stringify<double>(alignmentX)+","+stringify<double>(alignmentY));
	text.draw("Index = " +stringify< Eigen::Matrix<double,1,3> >(index.transpose()));
	text.draw("Thumb = " +stringify< Eigen::Matrix<double,1,3> >(thumb.transpose()));
	text.draw("Inside Time= " + stringify<int>(timer.getElapsedTimeInMilliSec()) );
	text.draw("Trial = " + stringify<int>(trialNumber));
	text.draw("Stimulus Time= " + stringify<int>(stimTimer.getElapsedTimeInMilliSec()) );

	text.leaveTextInputMode();
	}
}
Esempio n. 25
0
void drawInfo()
{
	if ( visibleInfo )
	{
		glDisable(GL_COLOR_MATERIAL);
		glDisable(GL_BLEND);
		glDisable(GL_LIGHTING);

		GLText text;

		if ( gameMode )
			text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		else
			text.init(640,480,glWhite,GLUT_BITMAP_HELVETICA_12);

		text.enterTextInputMode();
		
		// check if IOD has been input
		if(interoculardistance>45.0)
		{
			text.draw("####### SUBJECT #######");
			text.draw("#");
			text.draw("# Name: " + parameters.find("SubjectName") + "_" + parameters.find("NoiseLevel"));
		} else {
			text.draw(" "); text.draw(" "); text.draw(" ");
		}
		text.draw("# IOD: " +stringify<double>(interoculardistance));
		
		// check if mirror is calibrated
		if ( abs(mirrorAlignment - 45.0) < 0.2 )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));

		// check if monitor is calibrated
		if ( screenAlignmentY < 89.0 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));
		if ( abs(screenAlignmentZ) < 89.0 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));
		glColor3fv(glWhite);
		// X and Z coords of simulated fixation
		text.draw("# Fixation Z = " +stringify<double>(markers[19].p.x()-120.0)+ " [mm]");
		text.draw("# Fixation X = " +stringify<double>(markers[19].p.z()+363.0)+ " [mm]");
		text.draw(" ");

		// if IOD has been input
		if(interoculardistance>45.0)
		{
			glColor3fv(glWhite);
			text.draw("# trial: " +stringify<int>(trialNumber));
			text.draw("# time: " +stringify<int>(frameN));

			if(condition == 1)
			{
				text.draw("FingerCalibration= " + stringify<int>(fingerCalibrationDone) );
				glColor3fv(glWhite);
				text.draw("Calibration Platform" );
				
				if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				
				text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );
				glColor3fv(glWhite);
				text.draw(" " );
				text.draw("Mirror" );

				if ( isVisible(markers[5].p) && isVisible(markers[6].p) && isVisible(markers[7].p) )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Marker "+ stringify<int>(5)+stringify< Eigen::Matrix<double,1,3> > (markers[5].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(6)+stringify< Eigen::Matrix<double,1,3> > (markers[6].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(7)+stringify< Eigen::Matrix<double,1,3> > (markers[7].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );

				glColor3fv(glWhite);
				text.draw(" " );
				text.draw("Index" );

				if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

				glColor3fv(glWhite); 
				text.draw(" " );
				text.draw("Thumb" );

				if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );
				
				glColor3fv(glWhite); 
				text.draw(" " );
				text.draw("time_progress: "+ stringify<double>(time_progress)+ " [s]" );
				text.draw("Haptic height: "+ stringify<double>(markers[4].p.y() - markers[3].p.y())+ " [mm]" );
				text.draw("Index: "+ stringify< Eigen::Matrix<double,1,3> > (ind.transpose())+ " [mm]" );
			} else
			{
				text.draw(" ");
				text.draw("Press zero on the numeric pad to start");
			}

			text.leaveTextInputMode();
		}
	}
}
void drawInfo()
{
	if ( visibleInfo )
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		switch (fingerCalibrationDone)
		{
			case 0:
				text.draw("Calibration object and index marker are not visible.");		
				break;

			case 1:
				{
					glColor3fv(glGreen);
					text.draw("Index marker has been detected and calibrated. Waiting for Thumb marker to be visible...");	
				} break;

			case 2:
				{
					glColor3fv(glGreen);
					text.draw("Index marker has been detected and calibrated.");	
					text.draw("Thumb marker has been detected and calibrated.");	
					glColor3fv(glWhite);
					text.draw("Touch the two outer markers with the fingerpads then press F (fingers and calibration object visible)");
				} break;

			case 3:
				text.draw("Set home position then press F to start the demo");		
				break;
		}

		text.draw("# IOD: " +stringify<double>(interoculardistance));

		// check if mirror is calibrated
		if ( abs(mirrorAlignment - 45.0) < 0.2 )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));

		// check if monitor is calibrated
		if ( screenAlignmentY < 89.0 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));
		if ( abs(screenAlignmentZ) < 89.0 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));
		glColor3fv(glWhite);
		// X and Z coords of simulated fixation
		text.draw("# Fixation Z = " +stringify<double>(markers[19].p.x()-120.0)+ " [mm]");
		text.draw("# Fixation X = " +stringify<double>(markers[19].p.z()+363.0)+ " [mm]");
		text.draw(" ");

		glColor3fv(glWhite);
		text.draw("Calibration Platform" );
		
		if ( isVisible(markers[1].p) && isVisible(markers[2].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		
		text.draw("Marker "+ stringify<int>(1)+stringify< Eigen::Matrix<double,1,3> > (markers[1].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(2)+stringify< Eigen::Matrix<double,1,3> > (markers[2].p.transpose())+ " [mm]" );

		if ( isVisible(markers[3].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(3)+stringify< Eigen::Matrix<double,1,3> > (markers[3].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(4)+stringify< Eigen::Matrix<double,1,3> > (markers[4].p.transpose())+ " [mm]" );

		glColor3fv(glWhite);
		text.draw(" " );
		text.draw("Index" );

		if ( isVisible(markers[13].p) && isVisible(markers[14].p) && isVisible(markers[16].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(13)+stringify< Eigen::Matrix<double,1,3> > (markers[13].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(14)+stringify< Eigen::Matrix<double,1,3> > (markers[14].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(16)+stringify< Eigen::Matrix<double,1,3> > (markers[16].p.transpose())+ " [mm]" );

		glColor3fv(glWhite); 
		text.draw(" " );
		text.draw("Thumb" );

		if ( isVisible(markers[15].p) && isVisible(markers[17].p) && isVisible(markers[18].p) )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("Marker "+ stringify<int>(15)+stringify< Eigen::Matrix<double,1,3> > (markers[15].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(17)+stringify< Eigen::Matrix<double,1,3> > (markers[17].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(18)+stringify< Eigen::Matrix<double,1,3> > (markers[18].p.transpose())+ " [mm]" );

		if ( allVisibleObject )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw(" " );
		text.draw("Marker "+ stringify<int>(11)+stringify< Eigen::Matrix<double,1,3> > (markers[11].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(12)+stringify< Eigen::Matrix<double,1,3> > (markers[12].p.transpose())+ " [mm]" );
		text.draw("Marker "+ stringify<int>(8)+stringify< Eigen::Matrix<double,1,3> > (markers[8].p.transpose())+ " [mm]" );

		glColor3fv(glWhite); 
		text.draw(" " );
		text.draw("Index = " +stringify< Eigen::Matrix<double,1,3> > (ind.transpose()));
		text.draw("Thumb = " +stringify< Eigen::Matrix<double,1,3> > (thu.transpose()));
		text.draw("Platform Orientation = " + stringify<double>(platformXZtheta));
		text.draw("test = " +stringify< Eigen::Matrix<double,1,3> > (test.transpose()));

		text.leaveTextInputMode();
	}

	if ( expFinished )
	{
		GLText text2;	
		text2.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text2.enterTextInputMode();
		text2.draw("The experiment is finished.");
		text2.leaveTextInputMode();
	}

}
Esempio n. 27
0
void drawGeneratedPlanes()
{
	Hyperplane<double,3> screenPlane,mirrorPlane;

	//mirror[3] = Vector3d(mirror[1].x(),mirror[2].y(),mirror[1].z());
	screen[3] = Vector3d(screen[1].x(), screen[2].y(),screen[1].z());


	screenPlane = Hyperplane<double,3>::Through( screen[0], screen[1],screen[2] );
	mirrorPlane = Hyperplane<double,3>::Through(mirror[1], mirror[0], mirror[2] );

	screenNormal = screenPlane.normal();
	mirrorNormal = mirrorPlane.normal();

	Eigen::ParametrizedLine<double,3> line = Eigen::ParametrizedLine<double,3>::Through( screenCenter , screenCenter + screenNormal*10);
	// Calcola il punto proiezione della normale uscente dallo schermo sullo specchio
	double p = line.intersection(mirrorPlane);
	screenProjectionOnMirror = p*((screenNormal).normalized()) + screenCenter;

	planesIntersectionBase = -getPlaneIntersection(mirrorPlane,screenPlane,0);
	planesIntersectionDirection = mirrorPlane.normal().cross(screenPlane.normal());

	planesIntersecEnd = planesIntersectionBase - 200*planesIntersectionDirection;

	// Draw the planes intersection
	glPushMatrix();
	glColor3fv(glBlue);
	glBegin(GL_LINES);
	glVertex3dv(planesIntersectionBase.data());
	glVertex3dv(planesIntersecEnd.data());
	glEnd();
	glPopMatrix();

	// Draw the mirror plane (only if calibrationPhase==0)
	if ( calibrationPhase==0 )
	{
		glPushMatrix();
		Grid gridMirror;
		gridMirror.setRowsAndCols(20,20);
		gridMirror.init(mirror[1],mirror[0],mirror[2],mirror[3]);	// invert the order to have 45 degrees yaw and 90 degree pitch when correct
		glColor3fv(glRed);
		gridMirror.draw();
		glPopMatrix();

		// Draw the mirror normal
		mirrorCenter = (mirror[0]+mirror[1]+mirror[2]+mirror[3])/4.0;
		Vector3d mirrorCenterDirection = mirrorCenter + 20*mirrorNormal;
		glPushMatrix();
		glColor3fv(glRed);
		glBegin(GL_LINES);
		glVertex3dv(mirrorCenter.data());
		glVertex3dv(mirrorCenterDirection.data());
		glEnd();
		glPopMatrix();
	}

	// Draw the screen plane
	if ( calibrationPhase!=0)
	{
		glPushMatrix();
		Grid gridScreen;
		gridScreen.setRowsAndCols(20,20);
		gridScreen.init(screen[0],screen[1],screen[2],screen[3]);
		glColor3fv(glGreen);
		gridScreen.draw();
		glPopMatrix();

		// Draw the screen normal
		screenCenter = (screen[0]+screen[1]+screen[2]+screen[3])/4.0;
		Vector3d screenCenterDirection = screenCenter + 20*screenNormal;
		glPushMatrix();
		glBegin(GL_LINES);
		glVertex3dv(screenCenter.data());
		glVertex3dv(screenCenterDirection.data());
		glEnd();
		glPopMatrix();
	}


	// Draw the vector from screen center to mirror center
	glPushMatrix();
	glColor3fv(glRed);
	glBegin(GL_LINES);
	glVertex3dv(screenCenter.data());
	glVertex3dv(mirrorCenter.data());
	glEnd();
	glPopMatrix();

	// Draw the vector from mirror center to X axis
	Vector3d orthoProjMirrorCenter(mirrorCenter);
	glPushMatrix();
	glColor3fv(glRed);
	glBegin(GL_LINES);
	glVertex3dv(mirrorCenter.data());
	glVertex3d(mirrorCenter.x(),mirrorCenter.y(),0);
	glEnd();
	glPopMatrix();

	// draw mirror saved center
	if ( calibrationPhase == 1)
	{
		glPushMatrix();
		glTranslatef(mirrorSavedCenter.x(),mirrorSavedCenter.y(),mirrorSavedCenter.z());
		glutSolidSphere(1,10,20);
		glPopMatrix();
	}

	mirrorYaw = mathcommon::toDegrees(acos(mirrorNormal.z()));
	mirrorPitch = mathcommon::toDegrees(acos(mirrorNormal.y()));

	screenYaw = mathcommon::toDegrees(acos(screenNormal.z()));
	screenPitch = mathcommon::toDegrees(acos(screenNormal.y()));
	glColor3fv(glWhite);

	double tolerance = 0.5; //degrees
	bool mirrorYawOK = abs(mirrorYaw - 45) <= tolerance;
	bool screenYawOK = abs(screenYaw - 90) <= tolerance;
	bool mirrorPitchOK = abs(mirrorPitch-90) <= tolerance;
	bool screenPitchOK = abs(screenPitch-90) <= tolerance;


	GLText text;
	text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
	text.enterTextInputMode();
	switch( calibrationPhase )
	{
	case 0:
		text.draw("==== INSTRUCTIONS ====");
		text.draw("Put the markers on the mirror vertices, try to keep them aligned. Press SPACEBAR to save their coordinates");
		text.draw("Press 2/8 to zoom out/in. Press '+/-' to go forward or backward");
		break;
	case 1:
		{
			text.draw("Now remove the mirror, mirror coordinates are saved to calibrationCoordinates.txt");
			text.draw("Now you must put the markers on the screen");
			text.draw("");
			text.draw("");
			text.draw("Mirror current center= " + util::stringify< Eigen::Matrix<double,1,3> >(mirrorSavedCenter.transpose() ) );
			text.draw("Distance from mirror center to screen center " + util::stringify<double>( (mirrorSavedCenter - screenCenter).norm()	 ));
			text.draw("Projection error of screen normal on mirror center  " + util::stringify<Eigen::Matrix<double,1,3> >( screenProjectionOnMirror.transpose() ) );
		}
		break;
	case 2:
		break;
	}

	text.draw("==== MIRROR INFO ====");
	mirrorPitchOK ? glColor3fv(glGreen) : glColor3fv(glRed);
	text.draw("Mirror Pitch= " + util::stringify<double>(mirrorPitch) );
	mirrorYawOK ? glColor3fv(glGreen) : glColor3fv(glRed);
	text.draw("Mirror Yaw=" + util::stringify<double>(mirrorYaw));
	glColor3fv(glWhite);
	text.draw("==== SCREEN INFO ====");
	screenPitchOK ? glColor3fv(glGreen) : glColor3fv(glRed);
	text.draw("Screen Pitch=" + util::stringify<double>(screenPitch));
	screenYawOK ? glColor3fv(glGreen) : glColor3fv(glRed);
	text.draw("Screen Yaw=" + util::stringify<double>(screenYaw));
	// Here print the relative orientation of screen and mirror
	if ( calibrationPhase==0)
	{   text.draw("Total distance (norm)= " + util::stringify<double>(abs(mirrorCenter.z())+(mirrorCenter - screenCenter).norm()) );
	text.draw("Total distance (only x+z)= " + util::stringify<double>( abs(mirrorCenter.x()-screenCenter.x()) + abs(mirrorCenter.z()) ));
	}
	else
	{
		text.draw("Total distance (norm)= " + util::stringify<double>(abs(mirrorSavedCenter.z())+(mirrorSavedCenter - screenCenter).norm()) );
		text.draw("Total distance (ignore y offset)= " + util::stringify<double>( abs(mirrorSavedCenter.x()-screenCenter.x()) + abs(mirrorSavedCenter.z()) ));
	}
	text.draw("Intersection of planes" + util::stringify<Eigen::Matrix<int,1,3> >(planesIntersectionBase.cast<int>()));
	text.leaveTextInputMode();
}
Esempio n. 28
0
/*** INFO ***/
void drawInfo()
{
	if ( visibleInfo )
	{
		GLText text;	
		text.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text.enterTextInputMode();

		glColor3fv(glWhite);
		text.draw("####### summer15-SMT-pyramid #######");
		text.draw("");

		if(experiment)
			text.draw("####### SUBJECT #######");
		if(training)
			text.draw("####### THIS IS JUST A TRAINING #######");
		text.draw("#");
		text.draw("# Name: " +parameters.find("SubjectName"));
		text.draw("# IOD: " +stringify<double>(interoculardistance));
		text.draw("#");
		text.draw("# trial: " +stringify<double>(trialNumber));
		text.draw("#");
		text.draw("#######################\n\n");
		text.draw(" ");

		// check if mirror is calibrated
		if ( abs(mirrorAlignment - 45.0) < 0.2 )
			glColor3fv(glGreen);
		else
			glColor3fv(glRed);
		text.draw("# Mirror Alignment = " +stringify<double>(mirrorAlignment));

		// check if monitor is calibrated
		if ( screenAlignmentY < 89.0 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Y = " +stringify<double>(screenAlignmentY));

		if ( abs(screenAlignmentZ) < 89.4 )
			glColor3fv(glRed);
		else
			glColor3fv(glGreen);
		text.draw("# Screen Alignment Z = " +stringify<double>(screenAlignmentZ));

		glColor3fv(glWhite);
		// X and Z coords of simulated fixation
		text.draw("# Fixation Z = " +stringify<double>(markers.at(screen1).p.x()-120.0)+ " [mm]");
		text.draw("# Fixation X = " +stringify<double>(markers.at(screen1).p.z()+363.0)+ " [mm]");
		text.draw(" ");

		glColor3fv(glWhite); 
		text.draw(" " );
		text.draw("time: " +stringify<int>(timer.getElapsedTimeInMilliSec()));
		text.draw(" " );
		text.draw("stereocheck: " + stringify<double>(stereocheckZ[0]) + " " + stringify<double>(stereocheckZ[1]));
		text.draw("stereocheck: " + stringify<double>(stereocheckZ[2]) + " " + stringify<double>(stereocheckZ[3]));

/*
		if(depth_cue_pedestal == "stereo")
		{
			text.draw("Moving: = " +stringify<double> (depth_stimulus));
			text.draw("Stereo: = " +stringify<double> (depth_pedestal));
		} else
		{
			text.draw("Moving: = " +stringify<double> (depth_pedestal));
			text.draw("Stereo: = " +stringify<double> (depth_stimulus));
		}
*/
		text.leaveTextInputMode();
	}

	if ( expFinished )
	{
		GLText text2;	
		text2.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_12);
		text2.enterTextInputMode();
		text2.draw("The experiment is finished.");
		text2.leaveTextInputMode();
	}

	if ( inPause )
	{
		GLText text3;	
		text3.init(SCREEN_WIDTH,SCREEN_HEIGHT,glWhite,GLUT_BITMAP_HELVETICA_18);
		text3.enterTextInputMode();
		text3.draw("P A U S E");
		text3.leaveTextInputMode();
	}
}
Esempio n. 29
0
/*** INFO ***/
void drawInfo()
{
	if ( visibleInfo )
	{
		GLText text;	
		text.init(SCREEN_WIDTH-350,SCREEN_HEIGHT-250,glWhite,GLUT_BITMAP_HELVETICA_18);
		text.enterTextInputMode();

		if(!expFinished)
		{
			if(!system_calibrated)
			{
				text.draw("");
				text.draw("");
				text.draw("Calibrate the coordinate system by pressing C");
				text.draw("");
				text.draw("");
				if ( allVisibleReferenceMarkers )
						glColor3fv(glGreen);
					else
						glColor3fv(glRed);
				text.draw("Marker "+ stringify<int>(calibration1)+":	"+stringify< Eigen::Matrix<double,1,3> > (markers.at(calibration1).p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(calibration2)+":	"+stringify< Eigen::Matrix<double,1,3> > (markers.at(calibration2).p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(calibration3)+":	"+stringify< Eigen::Matrix<double,1,3> > (markers.at(calibration3).p.transpose())+ " [mm]" );
				text.draw("Marker "+ stringify<int>(calibration4)+":	"+stringify< Eigen::Matrix<double,1,3> > (markers.at(calibration4).p.transpose())+ " [mm]" );
			} else
			{
				switch (fingerCalibrationDone)
				{
					case 0:
						text.draw("Calibration markers are not visible.");		
						break;

					case 1:
						{
							glColor3fv(glGreen);
							text.draw("Calibration markers have been detected. Press F to record their positions.");	
						} break;

					case 2:
						{
							glColor3fv(glWhite);
							text.draw("Place index and thumb tips on the markers and press F to calibrate");	
						} break;

					case 3:
						text.draw("Set home position then press F.");		
						break;

					case 4:
						text.draw("Set target position then press F to start.");		
						break;
				}
				glColor3fv(glWhite);
				text.draw(" ");

				if(fingerCalibrationDone == 5)
				{
					text.draw("####### " + student_directory + "'s experiment #######");
					text.draw("");

					if(experiment)
					{
						text.draw("####### EXPERIMENT #######");
					}
					if(training)
					{
						glColor3fv(glRed);
						text.draw("####### THIS IS JUST A TRAINING: press E to begin when ready #######");
					}
					glColor3fv(glWhite);
					text.draw("#");
					text.draw("# Name: " + subjectName);
					text.draw("#");
					text.draw("# trial: " +stringify<double>(trialNumber));
					text.draw("#");
					text.draw("#######################\n\n");
					text.draw(" ");
				}

				if(fingerCalibrationDone < 3)
				{
					glColor3fv(glWhite);
					text.draw("Index Marker: "+ stringify< Eigen::Matrix<double,1,3> > (index_marker.transpose()) + " [mm]" );
					text.draw("Thumb Marker: "+ stringify< Eigen::Matrix<double,1,3> > (thumb_marker.transpose()) + " [mm]" );
					text.draw("");

					if(fingerCalibrationDone < 2)
					{
						if ( allVisibleCalibrationMarkers )
							glColor3fv(glGreen);
						else
							glColor3fv(glRed);
						
						text.draw("Index Calibration Marker "+ stringify<int>(indexcal)+stringify< Eigen::Matrix<double,1,3> > (markers.at(indexcal).p.transpose())+ " [mm]" );
						text.draw("Thumb Calibration Marker "+ stringify<int>(thumbcal)+stringify< Eigen::Matrix<double,1,3> > (markers.at(thumbcal).p.transpose())+ " [mm]" );
						text.draw(" ");
					}
				}

				glColor3fv(glWhite);
				text.draw(" " );
				text.draw("Index" );

				if ( allVisibleIndex )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Index = " +stringify< Eigen::Matrix<double,1,3> > (ind.transpose()));

				glColor3fv(glWhite); 
				text.draw(" " );
				text.draw("Thumb" );

				if ( allVisibleThumb )
					glColor3fv(glGreen);
				else
					glColor3fv(glRed);
				text.draw("Thumb = " +stringify< Eigen::Matrix<double,1,3> > (thu.transpose()));			

				glColor3fv(glWhite); 
				text.draw(" " );

				text.draw(" " );
				text.draw("Elapsed Time: " +stringify<int>(timer.getElapsedTimeInMilliSec()));
				text.draw("Grip Aperture: " +stringify<double>(grip_aperture));

			}
		} else
		{
			text.draw("The experiment is finished.");
		}
		text.leaveTextInputMode();
	}
}