コード例 #1
0
ファイル: demoBuddha.cpp プロジェクト: guendas/cncsvision
void handleKeypress(unsigned char key, int x, int y)
{   switch (key)
    {   //Quit program
    case 'q':
    case 27:
    {   cleanup();
        exit(0);
    }
    break;
    case 'i':
        interoculardistance+=1;
        headEyeCoords.setInterOcularDistance(interoculardistance);
        break;
    case 'I':
        interoculardistance-=1;
        headEyeCoords.setInterOcularDistance(interoculardistance);
        break;
    case 'w':
        modelZ-=1;
        break;
    case 's':
        modelZ+=1;
        break;
    }
}
コード例 #2
0
// Funzione di callback per gestire pressioni dei tasti
void handleKeypress(unsigned char key, int x, int y)
{   switch (key)
    {   
		case 'i':
			visibleInfo=!visibleInfo;
		break;
		case 'm':
		{
			interoculardistance += 0.5;
			headEyeCoords.setInterOcularDistance(interoculardistance);
		}
		break;
		case 'n':
		{
			interoculardistance -= 0.5;
			headEyeCoords.setInterOcularDistance(interoculardistance);
		}
		break;
		case 'Q':
		case 'q':
		case 27:	//corrisponde al tasto ESC
		{   
			// Ricorda quando chiami una funzione exit() di chiamare prima cleanup cosi
			// spegni l'Optotrak ed i markers (altrimenti loro restano accesi e li rovini) 
			cleanup();
			exit(0);
		}
		break;
		case 'f':
		case 'F':
		{
			if(condition == 1)
			{
				// Here we record the finger tip physical markers
				if ( allVisiblePlatform && fingerCalibrationDone==0 )
				{
					fingerCalibrationDone=1;
					calibration_fingers(fingerCalibrationDone);
					beepOk(0);
					break;
				}
				if ( (fingerCalibrationDone==1) && allVisibleFingers )
				{
					fingerCalibrationDone=2;
					calibration_fingers(fingerCalibrationDone);
					beepOk(0);
					break;
				}
				if ( fingerCalibrationDone==2  && allVisibleFingers )
				{
					fingerCalibrationDone=3;
					beepOk(0);
					visibleInfo=false;
					drawGLScene();

					// prepare the object
					// check where top and bottom surfaces are
					whereTop = markers[4].p.transpose();
					whereBottom = markers[3].p.transpose();
					// what's next distance Z?
					absDepth = trial.getCurrent().first["AbsDepth"];
					// bring screen at Z
					initProjectionScreen(absDepth);
					// bring object at Z, with size 2 cm
					Vector3d moveBack(0.0,whereTop.y()-50.0,absDepth);
					moveObjectAbsolute(moveBack, whereBottom, 5000);
					break;
				}
			} else
				beepOk(1);
		}
		break;
		case '0':
		{
			if(condition == 0)
			{
				experimentBegun = true;
				whereTop = markers[4].p.transpose();
				visibleInfo=false;
				initTrial();
			}
			else
				beepOk(1);
		}
		break;
		case 13:
		{
			if(condition == 1 && trialNumber == 0)
			{
				experimentBegun = true;
				initTrial();
			}
		}
		break;
		case 'e':
			ind.y() += 10;
		break;
		case 'd':
			ind.y() -= 10;
		break;
		case 'y':
			ind.z() += 10;
		break;
		case 'h':
			ind.z() -= 10;
		break;
		case 'j':
			ind.x() -= 10;
		break;
		case 'g':
			ind.x() += 10;
		break;
		case 'w':
			markers[4].p.y() += 10;
		break;
		case 's':
			markers[4].p.y() -= 10;
		break;
	}
}
コード例 #3
0
// Edit case 'f' to establish calibration procedure
// Also contains other helpful button presses (ESC for quit, i for info)
void handleKeypress(unsigned char key, int x, int y)
{   switch (key)
    {

	case ' ':
	{
		if (allVisibleFingers){
			perceptual_estimate=grip_aperture;
			estimate_given=1;
			beepOk(9);
		}
		else
			beepOk(12);
	}
	break;

	case 'x':
	{
		beepOk(0);
		cout << "Finished?: " << finished << endl;
	}
	break;

	case 'i':
	{
		visibleInfo=!visibleInfo;
	}
	break;

	case 'm':
	{
		interoculardistance += 0.5;
		headEyeCoords.setInterOcularDistance(interoculardistance);
	}
	break;
	
	case 'n':
	{
		interoculardistance -= 0.5;
		headEyeCoords.setInterOcularDistance(interoculardistance);
	}

	case '*':
	{
		illusionID += 1;
		illusionID = illusionID%2;
	}
	break;

	case 'r':
	{
		beepOk(objId+7);
	}
	break;

    case 27:	// ESC
    {   
		cleanup();
        exit(0);
    }
    break;

	case 'f':
	case 'F':
	{
		// calibration_fingers handles step 1 with the block
        
		if ( fingerCalibration==2 && allVisibleFingers && allVisiblePlatform3 )
		{
			// set index and thumb tips
			calibration_fingers(3);
			fingerCalibration=3;
			beepOk(0);
			break;
		}
		if ( fingerCalibration==3 && allVisibleFingers )
		{
			// set start posn
			startPosLeft = index.x() - 20;
			startPosRight = index.x() + 20;
			startPosBottom = index.y() - 20;
			startPosTop = index.y() + 20;
			startPosFront = index.z() - 20;
			startPosRear = index.z() + 20;
			fingerCalibration=6;
			beepOk(0);
			break;
		}
		/*if ( fingerCalibration==4 && allVisibleFingers )
		{
			// set left obj position (origin for drawing isn't center...)
            
            //leftObjX = index.x();
			//leftObjY = index.y();
			//leftObjZ = index.z();
            
            cylL_x = index.x(); // leftObjX - cylRad/2;
            cylL_y = index.y(); // leftObjY + cylHeight/2;
            cylL_z = displayDepth; //leftObjZ - cylRad/2;

            fingerCalibration=5;
			beepOk(0);
			break;
		}
		if ( fingerCalibration==5 && allVisibleFingers )
		{
			// set right obj position (origin for drawing isn't center...)
			cylR_x = index.x();
			cylR_y = index.y();
			cylR_z = displayDepth;
			//cylR_x = rightObjX - cylRad/2;
			//cylR_y = rightObjY + cylHeight/2;
			//cylR_z = rightObjZ - cylRad/2;
			fingerCalibration=6;
			beepOk(0);
			break;
		}*/
		if ( fingerCalibration==6 && allVisibleFingers )
		{
			// start experiment
			fingerCalibration=7;
			beepOk(0);
			visibleInfo=false;
			//factors = trial.getNext();
			factors = trial[block_order[block]].getNext();
			initTrial();
		}
	}
	break;

    case '.':
		advanceTrial();
		break;

	case 't':
		if(training)
			block++;
		training=false;
		beepOk(0);
		// Close the trial file
		trialFile.close();
		// Initialize the first non-training trial
		initTrial();
		break;

	case '1':
		cylR_x -= 1.0;
		break;
	case '3':
		cylR_x += 1.0;
		break;
	case '2':
		cylR_y -= 1.0;
		break;
	case '5':
		cylR_y += 1.0;
		break;
	case '4':
		cylR_z += 1.0;
		break;
	case '6':
		cylR_z -= 1.0;
		break;
    case '7':
        cylR_pitch -= 1.0;
        break;
    case '9':
        cylR_pitch += 1.0;
        break;

	case 'a':
		cylL_x -= 1.0;
		break;
	case 'd':
		cylL_x += 1.0;
		break;
	case 's':
		cylL_y -= 1.0;
		break;
	case 'w':
		cylL_y += 1.0;
		break;
	case 'e':
		cylL_z += 1.0;
		break;
	case 'q':
		cylL_z -= 1.0;
		break;
    case 'z':
        cylL_pitch -= 1.0;
        break;
    case 'c':
        cylL_pitch += 1.0;
        break;

	case 'o':
		openloop = !openloop;
		break;
	}

}
コード例 #4
0
// Funzione di callback per gestire pressioni dei tasti
void handleKeypress(unsigned char key, int x, int y)
{   switch (key)
    {   //Quit program
	case 'x':
		// Facendo cosi si cancella lo stimolo durante il movimento (SINCRONO) del monitor.
		// Si imposta il isStimulusDrawn a FALSE e si riaggiorna la schermata con una drawGLScene()
		// infine si muove il monitor, la chiamata blocca il programma per x secondi, si 
		// simula lo spostamento dello schermo di proiezione ed infine si reimposta isStimulusDrawn a TRUE
		// cosi' la prossima chiamata di drawStimulus() lo disegna correttamente a schermo. Provare per credere...
		//factors = trial.getNext();
	//	trial.next();
		drawGLScene();
//		initProjectionScreen(trial.getCurrent()["AbsDepth"]);
		break;
	case 'i':
		visibleInfo=!visibleInfo;
		break;
	case 'l':
		exits=!exits;
	break;
	case 'm':
	{
		interoculardistance += 0.5;
		headEyeCoords.setInterOcularDistance(interoculardistance);
	}
	break;
	case 'n':
	{
		interoculardistance -= 0.5;
		headEyeCoords.setInterOcularDistance(interoculardistance);
	}
	break;
	case '+':
	{
		// Il trucco per avanzare alla modalita' trial successiva: incrementi di uno e poi tieni il resto della 
		// divisione per due, in questo caso ad esempio sara' sempre:
		// 0,1,0,1,0,1
		// se metti il resto della divisione per 3 invece la variabile trialMode sar'
		// 0,1,2,0,1,2
		// ogni ciclo della variabile trialMode normalmente e' un trial (1)
		// puoi anche definire una funzione void advanceTrial() che si occupa di andare al trial successivo,
		// deve contenere una chiamata alla BalanceFactor::getNext() cosi' passi alla nuova lista di fattori
		// Ad esempio
		 trialMode++;
		 trialMode=trialMode%3;
	}
	break;
	case 'Q':
	case 'q':
    case 27:	//corrisponde al tasto ESC
    {   
		// Ricorda quando chiami una funzione exit() di chiamare prima cleanup cosi
		// spegni l'Optotrak ed i markers (altrimenti loro restano accesi e li rovini) 
		cleanup();
        exit(0);
    }
    break;

	case 'f':
	case 'F':
		{
			// Interpolate the fingertip (fourth virtual marker)
			if ( fingerCalibrationDone==2 && allVisibleObject && allVisibleFingers )
			{
				fingerCalibrationDone=3;
				calibration_fingers(fingerCalibrationDone);
				beepOk(3);
				break;
			}

			// Start the experiment
			if ( fingerCalibrationDone==3  && allVisibleFingers )
			{
				fingerCalibrationDone=4;
				beepOk(0);
				visibleInfo=false;
				drawGLScene(); // this is needed otherwise the next motor command freezes the screen

				// check where the object is
				object_reset_position = markers[3].p.transpose();
				// calculate where the object has to go
				Vector3d object_position(0.0,object_reset_position.y(),-550.0);
				// move the object to position from where it is
				moveObjectAbsolute(object_position, object_reset_position, 5000);

				trial.next();
				initTrial();
				break;
			}
		}
		break;
      case 't':
      {  
		  advanceTrial();
	  }
      break;
	}
}