void initCalibration() { // Now wind the input points file while the head calibration isn't done while ( true ) { // Here we load the variables needed to keep track of the experiment status readline(inputStream, trialNumber, headCalibration, trialMode, pointMatrix ); //First phase of calibration (equivalent when spacebar is pressed first time ) if ( (headCalibration== 1) && (headCalibrationDone==0 )) { headEyeCoords.init(pointMatrix.col(3),pointMatrix.col(4), pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2),interoculardistance ); headCalibrationDone=headCalibration; //cerr << headCalibrationDone << endl; } // Second phase of calibration (equivalent when space bar is pressed second time ) if ( (headCalibration== 2) && (headCalibrationDone==1 )) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=headCalibration; } // Third and final phase of calibration ( equivalent when spacebar is pressed third time ) if ((headCalibration==3)) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=3; break; // exit the while cycle } // simulates the update of head and eyes positions if ( headCalibration==headCalibrationDone) headEyeCoords.update(pointMatrix.col(0),pointMatrix.col(1),pointMatrix.col(2)); } }
void calibration_head(int phase) { switch (phase) { case 1: { headEyeCoords.init(markers[3].p-Vector3d(70,0,0),markers[3].p, markers[10].p,markers[11].p,markers[12].p,interoculardistance ); } break; case 2: { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[10].p, markers[11].p,markers[12].p,interoculardistance ); } break; } }
// 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(); isStimulusDrawn=false; drawGLScene(); initProjectionScreen(trial.getCurrent()["AbsDepth"]); isStimulusDrawn=true; break; case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case 'n': interoculardistance -= 0.5; 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 't': { if (trial.isEmpty()) exit(0); trial.next(); 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 ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=1; beepOk(0); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=2; break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1].p, markers[2].p,markers[3].p,interoculardistance ); headCalibrationDone=3; visibleInfo=false; } } break; case '5': { if(dz/2>10) zedge -= .25; else zedge = zedge; } break; case '8': { zedge += .25; } break; case '4': { xedge -= .25; } break; case '6': { xedge += .25; } break; case 'a': { theta -= M_PI/2.0; } break; case 's': { theta += M_PI/2.0; } break; case '0': { advanceTrial(); } break; } }
// 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(); isStimulusDrawn=false; drawGLScene(); initProjectionScreen(factors["AbsDepth"]); isStimulusDrawn=true; break; case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case 'n': interoculardistance -= 0.5; break; case 'd': visibleFingers=!visibleFingers; 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 ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=1; beepOk(0); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=2; break; } } break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { //platformFingers=markers[1].p; platformIndex=markers[1].p; platformThumb=markers[2].p; fingerCalibrationDone=1; beepOk(0); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p); indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); fingerCalibrationDone=2; beepOk(0); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { physicalRigidBodyTip = index; fingerCalibrationDone=3; fingerDistance = (thumb-index).norm(); visibleInfo=!visibleInfo; initTrial(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=3; } } break; case '2': { } break; case '8': { } break; case '4': { } break; case '6': { } break; // In genere a me piace attaccare al tasto p una funzione che stampi // le tue variabili di interesse su standard output ad esempio la lista dei fattori attuali con nome case 'p': { for (map<string,double>::iterator iter = factors.begin(); iter!=factors.end(); ++iter ) { cout << iter->first << " " << iter->second << endl; } } break; } }
// 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 'm': interoculardistance += 0.5; break; case 'n': interoculardistance -= 0.5; 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%4; } 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 'd': { fingersShown = !fingersShown; } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[1].p-Vector3d(230,0,0),markers[1].p, markers[5].p,markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=1; beepOk(0); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=2; break; } } break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { //platformFingers=markers[1].p; platformIndex=markers[1].p; platformThumb=markers[2].p; //centercal = markers[4].p; fingerCalibrationDone=1; beepOk(0); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p ); fingerCalibrationDone=2; beepOk(0); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { beepOk(0); fingerCalibrationDone=3; visibleInfo=!visibleInfo; trial.next(); initTrial(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=3; visibleInfo=false; } } break; case '5': { theta += 1; } break; case '8': { theta -= 1; } break; case 's': { advanceTrial(); } break; case '0': { training=!training; } break; case 'c': { pulsingColors=!pulsingColors; } break; case 'l': //L { //hapticLarger=!hapticLarger; } } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'o': orthographicMode=!orthographicMode; cam.setOrthoGraphicProjection(orthographicMode); break; case 'z': zOnFocalPlane=!zOnFocalPlane; break; case 'p': passiveMode=!passiveMode; break; case 'q': case 27: { cleanup(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead ) { headEyeCoords.init(markers[17],markers[18], markers[1],markers[2],markers[3],interoculardistance ); headCalibrationDone=1; break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1], markers[2],markers[3],interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=2; break; } if ( headCalibrationDone==2 ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1], markers[2],markers[3],interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[1], markers[2],markers[3],interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); headCalibrationDone=3; } } break; case '2': { probeAngle=270; keyPressed(); } break; case '8': { probeAngle=90; keyPressed(); } break; case '4': { probeAngle=180; keyPressed(); } break; case '6': { probeAngle=0; keyPressed(); } break; } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 'i': visibleInfo=!visibleInfo; break; case 'm': interoculardistance += 0.5; break; case '.': { trial[round].next(); initTrial(); } break; case 'n': interoculardistance -= 0.5; break; case 'Q': case 'q': case 27: //corrisponde al tasto ESC { cleanup(); exit(0); } break; case 'd': { fingersShown = !fingersShown; } break; case 'f': case 'F': { if(calib == 1){ // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { //platformFingers=markers[1].p; platformIndex=markers[1].p; platformThumb=markers[2].p; //centercal = markers[4].p; fingerCalibrationDone=1; beepOk(0); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { indexCoords.init(platformIndex, markers.at(13).p, markers.at(14).p, markers.at(16).p ); thumbCoords.init(platformThumb, markers.at(15).p, markers.at(17).p, markers.at(18).p ); fingerCalibrationDone=2; trial[round].next(); beepOk(0); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { beepOk(0); fingerCalibrationDone=3; platformPos = markers[4].p.transpose(); visibleInfo=!visibleInfo; initTrial(); break; } }else { beepOk(0); fingerCalibrationDone=3; platformPos = markers[4].p.transpose(); visibleInfo=!visibleInfo; trial[round].next(); initTrial(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1(),headEyeCoords.getP2(), markers[5].p, markers[6].p,markers[7].p,interoculardistance ); headCalibrationDone=3; visibleInfo=false; } } break; case ' ': { advanceTrial(); } break; case '5': { theta -= M_PI/2.0; } break; case '8': { theta += M_PI/2.0; } break; case '0': { half = !half; } } }