void initVariables() { double L = 2.5; double alfa = angle*M_PI/180.0; /* BoxNoiseStimulus planes[2]; double density = 0.0125; for (int i=0; i<2; i++) { int NPoints = L*L*density; planes[i].setDimensions(L,0.01,L); planes[i].setNpoints(1000); planes[i].compute(); stimDrawerPlanes[i].setSpheres(false); stimDrawerPlanes[i].setStimulus(&planes[i]); stimDrawerPlanes[i].initList(&planes[i],glRed); } */ WedgePointsStimulus wedge; wedge.setNpoints(500); wedge.setAngle(alfa); wedge.setPlanesSize(2*L, L); wedge.compute(); stimDrawer.setSpheres(false); stimDrawer.setStimulus(&wedge); stimDrawer.initList(&wedge,glRed); cerr << "angle= " << angle << endl; }
void initVariables() { interoculardistance = str2num<double>(parameters.find("IOD")); // Create the factors-staircase object TrialGenerator trial.init(parameters); maxTotalTrials = trial.getRemainingTrials(); cerr << "There are " << maxTotalTrials << " total trials to do..." << endl; factors = trial.getNext(); redDotsPlane.setNpoints(300); redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.compute(); //stimDrawer.drawSpecialPoints(); stimDrawer.setStimulus(&redDotsPlane); stimDrawer.setSpheres(false); stimDrawer.initList(&redDotsPlane,glRed,3); // Set the maximum x displacement of head maxXOscillation = util::str2num<double>(parameters.find("MaxXOscillation")); nOscillationsFixation = util::str2num<int>(parameters.find("NOscillationsFixation")); minOscTime = util::str2num<double>(parameters.find("MinOscillationTime")); maxOscTime = util::str2num<double>(parameters.find("MaxOscillationTime")); centerTolerance = util::str2num<double>(parameters.find("CenterTolerance")); totalTimer.start(); }
void initVariables() { interoculardistance = str2num<double>(parameters.find("IOD")); stimulusEmiCycles= atoi(parameters.find("StimulusEmiCycles").c_str()); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 if ( atoi(parameters.find("DrawOccluder").c_str()) ==1 ) { redDotsPlane.setNpoints(500); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(200,200,0.1); } else { redDotsPlane.setNpoints(75); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(50,50,0.1); } //redDotsPlane.setSlantTilt( factors["Slant"], (int) factors["Tilt"] ); redDotsPlane.compute(); stimDrawer.setStimulus(&redDotsPlane); stimDrawer.initList(&redDotsPlane); /** Bound check things **/ signsX.push_back(false); signsX.push_back(false); signsY.push_back(false); signsY.push_back(false); headEyeCoords.init(Vector3d(-32.5,0,0),Vector3d(32.5,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); model.load("../data/objmodels/occluder.obj"); }
void generateSphereStimulus(double radius) { int nStimulusPoints=(int)(stimulusDensity*4*M_PI*radius*radius); /* cylinder.setNpoints(nStimulusPoints); cylinder.setAperture(0,2*M_PI); cylinder.setRadiusAndHeight(radius,height); cylinder.setFluffiness(0.001); cylinder.compute(); */ sphere.setNpoints(nStimulusPoints); sphere.setRadius(radius); sphere.setFluffiness(0.001); sphere.compute(); // Update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&sphere); stimDrawer.initList(&sphere,glRed,3); //stimDrawer.setStimulus(&cylinder); //stimDrawer.initList(&cylinder,glRed,3); visualStimCenter << util::str2num<double>(parameters.find("OffsetX")),0,factors.getCurrent().at("Distances"); rodStart = visualStimCenter + r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod)); rodEnd= visualStimCenter - r*Vector3d(sin(thetaRod)*cos(phiRod),cos(thetaRod),sin(thetaRod)*sin(phiRod)); }
void draw_two_planes_motion_mono(double deltaz) { glLoadIdentity(); glTranslated(0, 0, objdistance); glRotated(motion, 1, 0, 0); //glRotated(90, 1, 0, 0); // Front left glPushMatrix(); glTranslated(-35.0, 0, deltaz/2); boxLeftDrawer.draw(); glPopMatrix(); // Back right glPushMatrix(); glTranslated(35.0, 0, -deltaz/2); boxLeftDrawer.draw(); glPopMatrix(); // Oblique plane glPushMatrix(); glTranslated(0, 0, 0); if(current_stimulus == "pedestal") { glRotated(oblTheta_pedestal, 0, 1, 0); boxOblique_pedestalDrawer.draw(); } else { glRotated(oblTheta_stimulus, 0, 1, 0); boxOblique_stimulusDrawer.draw(); } glPopMatrix(); /* // Fixation rod glPushMatrix(); glTranslated(0, 0, 0); rodMiddleDrawer.draw(); glPopMatrix(); glLoadIdentity(); glTranslated(0, 0, objdistance+(deltaz/2)+20.0); glColor3fv(glBlack); glBegin(GL_QUADS); glVertex3f(-100.0f, -100.0f, 0.1f); // Top Left glVertex3f( 100.0f, -100.0f, 0.1f); // Top Right glVertex3f( 100.0f, -30.0f, 0.1f); // Bottom Right glVertex3f(-100.0f, -30.0f, 0.1f); // Bottom Left glVertex3f(-100.0f, 30.0f, 0.1f); // Top Left glVertex3f( 100.0f, 30.0f, 0.1f); // Top Right glVertex3f( 100.0f, 100.0f, 0.1f); // Bottom Right glVertex3f(-100.0f, 100.0f, 0.1f); // Bottom Left glEnd(); */ }
void build_two_planes() { // BOX left boxLeft.setDimensions(40.0, 50.0, 0.1); boxLeft.setNpoints(450); boxLeft.compute(); boxLeftDrawer.setStimulus(&boxLeft); boxLeftDrawer.setSpheres(true); boxLeftDrawer.initList(&boxLeft, glRed); // BOX right boxRight.setDimensions(40.0, 50.0, 0.1);; boxRight.setNpoints(450); boxRight.compute(); boxRightDrawer.setStimulus(&boxRight); boxRightDrawer.setSpheres(true); boxRightDrawer.initList(&boxRight, glRed); // fixation rod rodMiddle.setDimensions(10.0, 5.0, 0.5);; rodMiddle.setNpoints(100); rodMiddle.compute(); rodMiddleDrawer.setStimulus(&rodMiddle); rodMiddleDrawer.setSpheres(true); rodMiddleDrawer.initList(&rodMiddle, glRed); }
void initVariables() { interoculardistance = str2num<double>(parameters.find("IOD")); redDotsPlane.setNpoints(75); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.compute(); stimDrawer.setSpheres(true); stimDrawer.setStimulus(&redDotsPlane); stimDrawer.initList(&redDotsPlane); }
void buildTrainingCylinder(double depth) { // stimolo training cylinder[3].setNpoints(250); cylinder[3].setRadiusAndHeight(depth/2,50); // raggio (mm) altezza (mm) // Dispone i punti random sulla superficie cilindrica cylinder[3].compute(); trainingstim.setStimulus(&cylinder[3]); // seguire questo ordine altrimenti setspheres non ha effetto se chiamata dopo StimulusDrawer::initList trainingstim.setSpheres(true); trainingstim.initList(&cylinder[3], glRed); }
void initVariables() { //interoculardistance = str2num<double>(parameters.find("IOD")); cylinder.setNpoints(150); cylinder.setAperture(0,2*M_PI); cylinder.setRadiusAndHeight(10,50); cylinder.setFluffiness(0.001); cylinder.compute(); // update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&cylinder); stimDrawer.initList(&cylinder,glRed,3); }
/** * @brief drawStimulus */ void drawStimulus() { double radiusX = util::str2num<double>(parameters.find("RadiusX")); glPushMatrix(); glLoadIdentity(); glTranslated(0,0,focalDistance); //if (horizontal) glRotated(90,0,0,1); glScaled(radiusX,radiusX,radiusX); //glRotated(90,0,1,0); //for lateral debug mode if ( parameters.find("UsePolkaDots")=="1") surface.draw(); glPopMatrix(); glPushAttrib(GL_ALL_ATTRIB_BITS); glDisable(GL_TEXTURE_3D); glPushMatrix(); glLoadIdentity(); glTranslated(0,0,focalDistance+0.02); // if ( horizontal ) glRotated(90,0,0,1); glScaled(radiusX,radiusX,radiusX); //glRotated(90,0,1,0); //for lateral debug mode if (parameters.find("AddRandomNoise")=="1") { stimDrawerRed.draw(); //stimDrawerBlack.draw(); } glPopMatrix(); glPopAttrib(); }
void initVariables() { totalTimer.start(); interoculardistance = str2num<double>(parameters.find("IOD")); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 useCircularMask = util::str2num<int>( parameters.find("CircularMask")) == 1 ; circularMaskRadius = util::str2num<int>(parameters.find("CircularMaskRadius")); if (useCircularMask) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); fixationDurationInSeconds = util::str2num<double>(parameters.find("AdaptationDurationInSeconds")); // Imposta stimolo e drawer redDotsPlane.setNpoints(util::str2num<int>(parameters.find("NumStimulusPoints"))); redDotsPlane.setDimensions( util::str2num<int>(parameters.find("StimulusEdgeLength")), util::str2num<int>(parameters.find("StimulusEdgeLength")),0.1); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane,glRed); resetPointStrip(); stimulusDurationInMilliSeconds = util::str2num<double>(parameters.find("StimulusDuration")); initialAdaptationTimeInSeconds = util::str2num<double>(parameters.find("InitialAdaptationTime")); initialAdaptationFlowIncrement = util::str2num<double>(parameters.find("InitialAdaptationFlowIncrement")); stimMotion=SINUSOIDAL_MOTION; trialMode = INITIALADAPTATION; headEyeCoords.init(Vector3d(interoculardistance/2,0,0),Vector3d(interoculardistance/2,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); }
void drawThings() { glDisable(GL_LIGHTING); double a = angle*M_PI/180.0; double L = 2.5; glPushMatrix(); glLoadIdentity(); glTranslated(0,0,focalDistance); arcball.applyRotationMatrix(); glBegin(GL_LINES); glVertex3d(-8,0,0); glVertex3d(8,0,0); glEnd(); //glutWireSphere(1,20,20); glPopMatrix(); /* glPushMatrix(); glTranslated(0,0,-L/2); glRotated(angle/2,1,0,0); //glScaled(1,1.0/sin(0.5*a),1); stimDrawerPlanes[0].draw(); glPopMatrix(); */ /* int n=0; double h = 1.0; double salfa = sin(a); double calfa = cos(a); glBegin(GL_POINTS); while (n<1000) { double x = mathcommon::unifRand(-L/2,L/2); double y = mathcommon::unifRand(-h/2,h/2); double z = mathcommon::unifRand(-L/2,L/2); if ( y<= z*salfa+1E-2 && y>= z*salfa-1E-2) { n++; glVertex3d(x,y,z); } } glEnd(); */ /* glPushMatrix(); glRotated(-angle/2,1,0,0); glScaled(1,1/sin(angle*M_PI/180.0),1); stimDrawerPlanes[1].draw(); glPopMatrix(); */ glPushMatrix(); glLoadIdentity(); glTranslated(0,0,focalDistance); arcball.applyRotationMatrix(); stimDrawer.draw(); glPopMatrix(); }
void drawRedDotsPlane() { // Draw the stimulus ( red-dots plane ) glDisable(GL_COLOR_MATERIAL); glDisable(GL_BLEND); glDisable(GL_LIGHTING); // IMPORTANT Reset the previous status of transformation objectActiveTransformation.setIdentity(); objectActiveTransformation.translation() = projPointEyeRight + translationFactor; if ((int)factors["Translation"]==-1 || (int)factors["Translation"]==-2 ) objectActiveTransformation.linear().setIdentity(); else objectActiveTransformation.linear() = (AngleAxis<double>(eulerAngles.getYaw(), Vector3d::UnitY())*AngleAxis<double>(eulerAngles.getPitch(), Vector3d::UnitX())).toRotationMatrix(); glPushMatrix(); // PUSH MATRIX glLoadIdentity(); glMultMatrixd(objectActiveTransformation.data()); Vector3d posAlongLineOfSight = (headEyeCoords.getRigidStart().getFullTransformation().rotation())*(eyeRight-eyeCalibration); double argslant = acos( cos(toRadians(factors["Slant"]))*(focalDistance-posAlongLineOfSight.z() )/((focalDistance ))); instantPlaneSlant = toDegrees(argslant); switch ( (int) factors["Tilt"] ) { case 0: glRotated( instantPlaneSlant ,0,1,0); //objectActiveTransformation*=AngleAxisd( toRadians(-instantPlaneSlant), Vector3d::UnitY() ); glScaled(1/sin(toRadians( -90-factors["Slant"])),1,1); //backprojection phase break; case 90: glRotated( -instantPlaneSlant ,1,0,0); //objectActiveTransformation*=AngleAxisd( toRadians(-instantPlaneSlant), Vector3d::UnitX() ); glScaled(1,1/sin(toRadians( -90-factors["Slant"] )),1); //backprojection phase break; case 180: glRotated( -instantPlaneSlant ,0,1,0); //objectActiveTransformation*=AngleAxisd( toRadians(-instantPlaneSlant), Vector3d::UnitY() ); glScaled(1/sin(toRadians( -90-factors["Slant"] )),1,1); //backprojection phase break; case 270: glRotated( instantPlaneSlant ,1,0,0); //objectActiveTransformation*=AngleAxisd( toRadians(-instantPlaneSlant), Vector3d::UnitX() ); glScaled(1,1/sin(toRadians( -90-factors["Slant"] )),1); //backprojection phase break; } glGetDoublev(GL_MODELVIEW_MATRIX,objectActiveTransformation.data()); BoundChecker stimBoundariesActive(&cam, &redDotsPlane); BoundChecker stimBoundariesPassive(&camPassive, &redDotsPlane); stimOutside = ( stimBoundariesActive.checkOutside(objectActiveTransformation) || stimBoundariesPassive.checkOutside(objectActiveTransformation)); stimDrawer.draw(); glPopMatrix(); // POP MATRIX }
void drawRedDotsPlane() { int planeTilt = (int)factors.at("Tilt"); int planeSlant = (int)factors.at("Slant"); double planeDef = factors.at("Def"); double planeOnset=1; bool backprojectionActive=true; double theta=0.0; Eigen::Affine3d modelTransformation; glPushMatrix(); //glLoadIdentity(); //glTranslated(0,0,focalDistance); glMultMatrixd(stimTransformation.data()); switch ( planeTilt ) { case 0: { theta = -acos(exp(-0.346574+0.5*planeDef-planeDef/2*(1-planeOnset*periodicValue/oscillationAmplitude))); glRotated(toDegrees(theta),0,1,0); if (backprojectionActive) glScaled(1/sin(toRadians( -90-planeSlant)),1,1); //backprojection phase } break; case 90: { theta = -acos(exp(-0.346574+0.5*planeDef-planeDef/2*(1-planeOnset*periodicValue/oscillationAmplitude))); glRotated( toDegrees(theta),1,0,0); if (backprojectionActive) glScaled(1,1/sin(toRadians( -90-planeSlant )),1); //backprojection phase } break; case 180: { theta = acos(exp(-0.346574+0.5*planeDef-planeDef/2*(1+planeOnset*periodicValue/oscillationAmplitude))); glRotated(toDegrees(theta),0,1,0); if (backprojectionActive) glScaled(1/sin(toRadians( -90-planeSlant )),1,1); //backprojection phase } break; case 270: { theta = acos(exp(-0.346574+0.5*planeDef-planeDef/2*(1+planeOnset*periodicValue/oscillationAmplitude))); glRotated( toDegrees(theta),1,0,0); if (backprojectionActive) glScaled(1,1/sin(toRadians( -90-planeSlant )),1); //backprojection phase } break; default: cerr << "Error, select tilt to be {0,90,180,270} only" << endl; } stimDrawer.draw(); glGetDoublev(GL_MODELVIEW_MATRIX,modelTransformation.matrix().data()); modelTransformation.matrix() = modelTransformation.matrix().eval(); glPopMatrix(); }
void initStimulus(double height, double longAxis, double shortAxis ) { double ellipticCircumferenceApproximate = 4*3.1415*longAxis*shortAxis/(longAxis+shortAxis); // Evitiamo di calcolarci la circonferenza dell'ellisse con la mega formula tanto cambia ben poco alla fine... int nStimulusPoints=2*(int)floor(ellipticCircumferenceApproximate*height*stimulusDensity); ellipseBaseCylinder.setNpoints(nStimulusPoints); ellipseBaseCylinder.setAperture(0,2*M_PI); ellipseBaseCylinder.setAxesAndHeight(longAxis,shortAxis,height); ellipseBaseCylinder.setFluffiness(0.001); ellipseBaseCylinder.compute(); // update the stimulus drawer stimDrawer.setSpheres(false); stimDrawer.setStimulus(&ellipseBaseCylinder); stimDrawer.initList(&ellipseBaseCylinder,glRed,3); }
void draw_three_rods_motion_mono(double deltaz) { glLoadIdentity(); glTranslated(0, 0, objdistance); glRotated(motion, 1, 0, 0); // glRotated(90, 1, 0, 0); // Left rear glPushMatrix(); glTranslated(-objwidth/2, 0, -deltaz/2); stimDrawer[0].draw(); glPopMatrix(); // Right rear rod glPushMatrix(); glTranslated(objwidth/2, 0, -deltaz/2); stimDrawer[1].draw(); glPopMatrix(); // Front rod glPushMatrix(); glTranslated(0, 0, deltaz/2); stimDrawer[2].draw(); glPopMatrix(); // Box glPushMatrix(); glTranslated(0, 0, 0); if(stimulus == 1) { if (first_stimulus == "pedestal") boxPedestalDrawer.draw(); else boxStimulusDrawer.draw(); } else { if (second_stimulus == "pedestal") boxPedestalDrawer.draw(); else boxStimulusDrawer.draw(); } glPopMatrix(); }
void mouseFunc(int button, int state, int _x , int _y) { if ( trialMode == PROBEMODE ) { glutWarpPointer(SCREEN_WIDTH/2,SCREEN_HEIGHT/2); if ( button == GLUT_LEFT_BUTTON && (state==GLUT_DOWN) ) probeAngle+=90; if ( button == GLUT_RIGHT_BUTTON && (state==GLUT_DOWN) ) probeAngle-=90; if( button== GLUT_MIDDLE_BUTTON ) { double responseTime=responseTimer.getElapsedTimeInMilliSec(); double clickDelay=100; //milliseconds before the click is valid if ( responseTime > clickDelay ) { timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in bool contraction = ( factors["Tilt"]==90 ) || (factors["Tilt"]==0); double angleResponse = (mod(probeAngle+probeStartingAngle,360)); if ( trial.getRemainingTrials()==0 ) { responseFile << setw(6) << left << trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << angleResponse << " " << responseTime << " " << contraction << endl; cleanup(); exit(0); } else { responseFile << setw(6) << left << trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << angleResponse << " " << responseTime << " " << contraction << endl; factors = trial.getNext(); trialNumber++; } advanceTrial(); double possibleAngles[]= {0,90,180,270}; probeStartingAngle=possibleAngles[rand()%4]; probeAngle=0; if ( atoi(parameters.find("DrawOccluder").c_str()) ==1 ) { redDotsPlane.setNpoints(500); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(200,200,0.1); } else { redDotsPlane.setNpoints(75); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(50,50,0.1); } //redDotsPlane.setSlantTilt( factors["Slant"], (int) factors["Tilt"] ); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane); mouseButton=0; } } } glutPostRedisplay(); }
void draw_two_planes_motion_mono(double deltaz) { glLoadIdentity(); glTranslated(0, 0, objdistance); glRotated(motion, 1, 0, 0); // glRotated(90, 1, 0, 0); // Front left glPushMatrix(); glTranslated(-objwidth*3/4, 0, deltaz/2); boxLeftDrawer.draw(); glPopMatrix(); // Back right glPushMatrix(); glTranslated(objwidth*3/4, 0, -deltaz/2); boxLeftDrawer.draw(); glPopMatrix(); // Fixation rod glPushMatrix(); glTranslated(0, 0, 0); rodMiddleDrawer.draw(); glPopMatrix(); /* glLoadIdentity(); glTranslated(0, 0, objdistance+(deltaz/2)+20.0); glColor3fv(glBlack); glBegin(GL_QUADS); glVertex3f(-100.0f, -100.0f, 0.1f); // Top Left glVertex3f( 100.0f, -100.0f, 0.1f); // Top Right glVertex3f( 100.0f, -30.0f, 0.1f); // Bottom Right glVertex3f(-100.0f, -30.0f, 0.1f); // Bottom Left glVertex3f(-100.0f, 30.0f, 0.1f); // Top Left glVertex3f( 100.0f, 30.0f, 0.1f); // Top Right glVertex3f( 100.0f, 100.0f, 0.1f); // Bottom Right glVertex3f(-100.0f, 100.0f, 0.1f); // Bottom Left glEnd(); */ }
void initVariables() { interoculardistance = str2num<double>(parameters.find("IOD")); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 redDotsPlane.setNpoints(75); //XXX controllare densita di distribuzione dei punti redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.compute(); //stimDrawer.drawSpecialPoints(); stimDrawer.setSpheres(true); stimDrawer.setStimulus(&redDotsPlane); stimDrawer.initList(&redDotsPlane); /** Bound check things **/ signs.push_back(false); signs.push_back(false); rythmMaker.start(); }
void drawStimulus() { if(fingerCalibrationDone==4) if(!allVisibleFingers) drawNoFingers(); if(experiment) { if ( isStimulusDrawn && !isHandHome && !iGrasped ) { glLoadIdentity(); glTranslated(0, 0, trial.getCurrent()["AbsDepth"]); // Left rear glPushMatrix(); glTranslated(-objwidth/2, 0, -objdepth/2); stimDrawer[0].draw(); glPopMatrix(); // Right rear rod glPushMatrix(); glTranslated(objwidth/2, 0, -objdepth/2); stimDrawer[1].draw(); glPopMatrix(); // Front rod glPushMatrix(); glTranslated(0, 0, objdepth/2); stimDrawer[2].draw(); glPopMatrix(); } if (iGrasped && isHandHome) advanceTrial(); } if(training) { drawFingers(areFingersDrawn); if ( isStimulusDrawn && !isHandHome && !iGrasped ) { glLoadIdentity(); glTranslated(0, 0, -450); // Left rear glPushMatrix(); trainingstim.draw(); glPopMatrix(); } if (iGrasped && isHandHome) initTrial(); } }
void build_three_rods() { // Ora inizializza i 3 rods (stimoli) for (int i=0; i<3; i++) { cylinder[i].setNpoints(150); cylinder[i].setRadiusAndHeight(0.1,50.0); // raggio (mm) altezza (mm) // Dispone i punti random sulla superficie cilindrica cylinder[i].compute(); stimDrawer[i].setStimulus(&cylinder[i]); // seguire questo ordine altrimenti setspheres non ha effetto se chiamata dopo StimulusDrawer::initList stimDrawer[i].setSpheres(true); stimDrawer[i].initList(&cylinder[i], glRed); } // BOX pedestal boxPedestal.setDimensions(objwidth+10.0, 55.0, depth_pedestal+5.0); boxPedestal.setNpoints(150); boxPedestal.compute(); boxPedestalDrawer.setStimulus(&boxPedestal); boxPedestalDrawer.setSpheres(true); boxPedestalDrawer.initList(&boxPedestal, glRed); // BOX stimulus boxStimulus.setDimensions(objwidth+10.0, 55.0, depth_stimulus+5.0);; boxStimulus.setNpoints(150); boxStimulus.compute(); boxStimulusDrawer.setStimulus(&boxStimulus); boxStimulusDrawer.setSpheres(true); boxStimulusDrawer.initList(&boxStimulus, glRed); }
void drawRedDotsPlane() { // Draw the stimulus ( red-dots plane ) bool isInside = ((projPoint - Vector3d(0,0,focalDistance) ).norm()) <= (circleRadius); glPushMatrix(); // Reset every previous transformation, put the stimulus in (0,0,0) with no rotation ( fronto-parallel ) glLoadIdentity(); if ( (int) factors["Anchored"]==0 ) glTranslated(0,0,fixationPoint.z()); else glTranslated(fixationPoint.x(),fixationPoint.y(),fixationPoint.z()); //double k=0.34657; double theta = 0.0; double angle = 0.0; switch ( (int)factors["Tilt"] ) { case 0: glRotated( -90-factors["Slant"] - variable*factors["RotationSpeed"], 0,1,0 ); break; case 90: glRotated( -90+factors["Slant"] - variable*factors["RotationSpeed"], 1,0,0 ); break; case 180: glRotated( -90+factors["Slant"] - variable*factors["RotationSpeed"], 0,1,0 ); break; case 270: glRotated( -90-factors["Slant"] - variable*factors["RotationSpeed"], 1,0,0 ); break; } if (isInside ) stimDrawer.draw(); glPopMatrix(); // Draw fixation (Always @ full-speed) if ( isInside ) { glColor3fv(glRed); glPushMatrix(); if ( (int) factors["Anchored"]==0 ) glTranslated(0,0,fixationPoint.z()); else glTranslated(fixationPoint.x(),fixationPoint.y(),fixationPoint.z()); glutSolidSphere(1,10,10); glPopMatrix(); } //drawCircle(); }
void keyPressed() { // Reset the translation of strip stripDisplacementIncrement = 0; double responseTime=responseTimer.getElapsedTimeInMilliSec(); timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in advanceTrial(); // Imposta stimolo e drawer redDotsPlane.setNpoints(75); redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane,glRed,2); }
void drawStimulus() { if ( isDrawing ) { if ( block.at("Phase") == 1 ) { glPushMatrix(); glLoadIdentity(); glTranslated(visualRodCenter.x(), visualRodCenter.y(), visualRodCenter.z()); stimDrawer.draw(); glPopMatrix(); } else { glPushMatrix(); glLoadIdentity(); glTranslated(visualRodCenter.x(), visualRodCenter.y(), visualRodCenter.z()); stimDrawer.draw(); glLoadIdentity(); glTranslated(visualRodCenter.x()+deltaXRods/2, visualRodCenter.y(), visualRodCenter.z()-factors.at("RelDepth")*0.5); } } }
void initVariables() { totalTimer.start(); interoculardistance = str2num<double>(parameters.find("IOD")); trial.init(parameters); factors = trial.getNext(); // Initialize the factors in order to start from trial 1 // Imposta stimolo e drawer redDotsPlane.setNpoints(75); redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane,glRed); // Imposta striscia del fixation e drawer stripPlane.setNpoints(N_STRIP_POINTS); stripPlane.setDimensions(STRIP_WIDTH,STRIP_HEIGHT,0.01); stripPlane.compute(); stripDrawer.initList(&stripPlane,glRed); stimMotion=SINUSOIDAL_MOTION; headEyeCoords.init(Vector3d(-32.5,0,0),Vector3d(32.5,0,0), Vector3d(0,0,0),Vector3d(0,10,0),Vector3d(0,0,10),interoculardistance ); eyeCalibration=headEyeCoords.getRightEye(); }
/** * @brief updateStimulus */ void updateStimulus() { double stimSize = parameters.get("StimulusSize"); double stimPeriod = parameters.get("StimulusPeriod"); double zWidth = trial.getCurrent().at("ZWidth"); int nStimulusPoints = (int)(stimSize*stimSize*parameters.get("StimulusDensity")); // Generate the plane stimulus if (parameters.find("StimulusType")=="Plane") { stimulus.setDimensions(stimSize,stimSize,0.001); stimulus.setNpoints(nStimulusPoints); stimulus.setFluffiness(0.001); stimulus.compute(); } else if (parameters.find("StimulusType")=="Sinusoid") { stimulus.setDimensions(stimSize,stimSize,0.001); stimulus.setNpoints(nStimulusPoints); stimulus.setFluffiness(0.001); for (PointsRandIterator iter = stimulus.pointsRand.begin(); iter!=stimulus.pointsRand.end();++iter) { (*iter)->x = mathcommon::unifRand(-stimSize/2,stimSize/2); (*iter)->y = mathcommon::unifRand(-stimSize/2,stimSize/2); (*iter)->z = 0.5*zWidth*sin(((*iter)->x)/stimPeriod*M_PI); } } else { throw std::runtime_error("Wrong argument! Must be Sinusoid or Plane"); } // Generate the front stimulus stimDrawer.setSpheres(false); stimDrawer.setStimulus(&stimulus); stimDrawer.initList(&stimulus,glRed,parameters.get("PointsSize")); }
/** * @brief updateStimulus * @param CurvatureZ */ void updateStimulus(double CurvatureZ) { double radiusX = util::str2num<double>(parameters.find("RadiusX")); double noiseDensity = util::str2num<double>(parameters.find("RandomNoiseDensity")); int nRandomDots = mathcommon::getParaboloidArea(radiusX,CurvatureZ)*noiseDensity; parabolicCylinderPoints.setNpoints(nRandomDots); parabolicCylinderPoints.setCurvature(CurvatureZ); parabolicCylinderPoints.setFluffiness(0.0); parabolicCylinderPoints.compute(); stimDrawerBlack.setSpheres(false); stimDrawerRed.setSpheres(false); stimDrawerRed.setStimulus(¶bolicCylinderPoints); stimDrawerBlack.setStimulus(¶bolicCylinderPoints); float randomDotsSize = util::str2num<float>(parameters.find("RandomDotsSize")); if (parameters.find("DotsColor")=="RedAndBlack") { stimDrawerRed.initList(¶bolicCylinderPoints,glRed,randomDotsSize); parabolicCylinderPoints.compute(); stimDrawerBlack.initList(¶bolicCylinderPoints,glBlack,randomDotsSize); surface.setUniformColor(glRed); } else { stimDrawerRed.initList(¶bolicCylinderPoints,glWhite,randomDotsSize); parabolicCylinderPoints.compute(); stimDrawerBlack.initList(¶bolicCylinderPoints,glWhite,randomDotsSize); surface.setUniformColor(glWhite); } if ( parameters.find("UsePolkaDots")=="1" ) { int nSpheres = util::str2num<int>(parameters.find("TotalPolkaDots")); int dotsRadiusMin = util::str2num<int>(parameters.find("PolkaDotsRadiusMin")); int dotsRadiusMax = util::str2num<int>(parameters.find("PolkaDotsRadiusMax")); int textureResolution = util::str2num<int>(parameters.find("TextureResolution")); //surface.fillVolumeWithSpheres2(nSpheres,nSpheres,nSpheres*util::str2num<double>(parameters.find("MaxCurvatureZ")),dotsRadiusMin,dotsRadiusMax); surface.fillVolumeWithSpheres(nSpheres,dotsRadiusMin ,dotsRadiusMax); surface.initializeTexture(); surface.parabolicCylinderSurface.curvature=CurvatureZ; //surface.setUniformColor(glWhite); } }
void drawPointsField() { stripDisplacementIncrement+=factors.at("FlowXIncrement"); glPushMatrix(); glLoadIdentity(); switch ((int)factors.at("Tilt")) { case 0: glTranslated(stripDisplacementIncrement,0,focalDistance); break; case 90: glTranslated(0,stripDisplacementIncrement,focalDistance); break; } stripDrawer.draw(); glPopMatrix(); }
void mouseFunc(int button, int state, int _x , int _y) { if ( trialMode == PROBEMODE ) { glutWarpPointer(SCREEN_WIDTH/2,SCREEN_HEIGHT/2); if ( button == GLUT_LEFT_BUTTON && (state==GLUT_DOWN) ) mouseButton=1; if ( button == GLUT_RIGHT_BUTTON && (state==GLUT_DOWN) ) mouseButton=-1; if( (button== GLUT_LEFT_BUTTON || button==GLUT_RIGHT_BUTTON) && (state==GLUT_UP) && (mouseButton!=0) ) { double responseTime=responseTimer.getElapsedTimeInMilliSec(); double clickDelay=100; //milliseconds before the click is valid if ( responseTime > clickDelay ) { timeFrame=0.0; //this put the stimulus in the center each central time mouse is clicked in if ( trial.isEmpty() ) { responseFile << setw(6) << left << trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << mouseButton << " " << responseTime << endl; cleanup(); exit(0); } else { responseFile << setw(6) << left << trialNumber << " " << factors["Def"] <<" " << factors["Tilt"] <<" " << factors["Slant"] << " " << factors["Anchored"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << (focalDistance - eyeCalibration.z()) << " " << mouseButton << " " << responseTime << endl; factors = trial.getNext(); trialNumber++; } advanceTrial(); redDotsPlane.setDimensions(50,50,0.1); redDotsPlane.setSlantTilt(factors["Slant"], factors["Tilt"] ); redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane); mouseButton=0; } } } glutPostRedisplay(); }
void keyPressed() { if ( trialMode == PROBEMODE ) { if ( trialNumber==0) { responseFile << setw(6) << left << "TrialNumber" << "Tilt Slant Rotation RotationSpeed FollowingSpeed Onset EyeCal.x EyeCal.y EyeCal.z StimFrames ProbeAngle" << endl; } responseFile << setw(6) << left << trialNumber << " " << factors["Tilt"] << " " << factors["Slant"] << " " << factors["Rotation"] << " " << factors["RotationSpeed"] << " " << factors["FollowingSpeed"] << " " << factors["Onset"] << " " << eyeCalibration.transpose() << " " << stimulusFrames << " " << probeAngle << endl; double possibleAngles[]= {0,90,180,270}; probeStartingAngle=possibleAngles[rand()%4]; redDotsPlane.compute(); stimDrawer.initList(&redDotsPlane); isReading=true; // Winds down the file until probemode isn't finished while ( trialMode == PROBEMODE || trialMode == CALIBRATIONMODE ) { if ( readline(inputStream, trialNumber, headCalibration, trialMode, pointMatrix ) ) { cleanup(); exit(0); } } #ifdef _WIN32 beepOk(); #endif } }