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();
*/
}
Ejemplo n.º 2
0
/**
 * @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();
}
Ejemplo n.º 3
0
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();
}
Ejemplo n.º 4
0
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();
}
Ejemplo n.º 5
0
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 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();

}
Ejemplo n.º 7
0
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();
*/
}
Ejemplo n.º 8
0
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();
    }
}
Ejemplo n.º 9
0
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();
}
Ejemplo n.º 10
0
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);
        }
    }
}
Ejemplo n.º 11
0
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();
}
Ejemplo n.º 12
0
void drawRedDotsPlane()
{	
// questo serve per disegnare lo stimolo solo se l'occhio ha passato da destra verso sinistra, facendo così appare nel centro
    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glPointSize(1);
    // Draw the stimulus ( red-dots plane )
    double angle = factors.at("Slant") + deltaT/1000.0*factors.at("OmegaY");
    //angle = mathcommon::toDegrees(headEyeCoords.getYaw());
    glPushMatrix();
    glLoadIdentity();
    glTranslated(0,0,focalDistance);
    switch ( (int)factors.at("Tilt") )
    {
    case 0:
    {
        glRotated( angle ,0,1,0);
    }
    break;
    case 90:
    {
        glRotated( angle,1,0,0);
    }
    break;
    case 180:
    {
        glRotated( angle,0,-1,0);
    }
    break;
    case 270:
    {
        glRotated( angle,-1,0,0);
    }
    break;
    }
    glGetDoublev(GL_MODELVIEW_MATRIX,objectActiveTransformation.data());
    if ( (eyeRight.x()) < centerTolerance )
	stimDrawer.draw();
    glPopMatrix();
    glPopAttrib();
}
Ejemplo n.º 13
0
void drawStimulus()
{
    double stimRadius = factors.getCurrent().at("StimulusRadius");

    glPushMatrix();
	glPointSize(7);
	glColor3fv(glRed);
	/*
	glPushMatrix();
    glLoadMatrixd(rigidStartThumb.getFullTransformation().data());
    glScaled(1,1,0.001);
    glutSolidSphere(thumbSphereRadius,15,15);
	glPopMatrix();

	glPushMatrix();
    glLoadMatrixd(rigidStartIndex.getFullTransformation().data());
    glScaled(0.001,1,1);
    glutSolidSphere(indexSphereRadius,15,15);
	glPopMatrix();
	*/
	glPushMatrix();
	glTranslated(-10,0,0);
    glMultMatrixd(rigidStartThumb.getFullTransformation().data());
	glRotated(90,0,1,0);
	ddcylinder();
	glPopMatrix();

	glPushMatrix();
	glTranslated(5,0,-10);
	glMultMatrixd(rigidStartIndex.getFullTransformation().data());
	ddcylinder();
	glPopMatrix();
	////////// OLD ////////
	/*
	glPointSize(7);
    glBegin(GL_POINTS);
    glVertex3dv(visualThumb.data());
    glVertex3dv(visualIndex.data());
    glEnd();
	*/

    double insideRadius = factors.getCurrent().at("DisappearRadius");
	if ((thumb - visualStimCenter).norm() > insideRadius ) // disegna lo stimolo
	{
		glColor3fv(glRed);
		glPushMatrix();
		glLoadIdentity();
		glTranslated(visualStimCenter.x(),visualStimCenter.y(),visualStimCenter.z());
		stimDrawer.draw();
		glScaled(0.99,0.99,0.99);
		glColor3fv(glBlack);
		glutSolidSphere(stimRadius,20,20);
		glPopMatrix();

		glPushAttrib(GL_ALL_ATTRIB_BITS);
		glLineWidth(5);
		glColor3fv(glRed);
		glBegin(GL_LINES);
		glVertex3dv(rodStart.data());
		glVertex3dv(rodEnd.data());
		glEnd();
		glPopAttrib();
	}
}
Ejemplo n.º 14
0
/**
 * @brief drawStimulus
 */
void drawStimulus()
{
    //////////////////////////////
    // Update stimuli
    double oscillationAmplitude=50.0;
    double oscillationPeriod=100.0;
    static double timeFrame=0.0;
    timeFrame+=1.0;
	
    if ( !trial.getCurrent().at("StimulusAnchored") )
    {
        // FISSO
        glPushMatrix();
        glLoadIdentity();
        Vector3d translationFactor(0,0,focalDistance);
        double instantPlaneSlant = trial.getCurrent().at("Slant");

        switch ( (int) trial.getCurrent().at("Tilt") )
        {
        case 0:
        {
            glTranslated( translationFactor.x(), translationFactor.y(), translationFactor.z());
            glRotated( -instantPlaneSlant ,0,1,0);
            glScaled(1/sin(toRadians( -90-trial.getCurrent().at("Slant"))),1,1);	//backprojection phase
            break;
        }
        case 90:
        {
            glTranslated( translationFactor.x(), translationFactor.y(), translationFactor.z());
            glRotated( -instantPlaneSlant ,1,0,0);
            glScaled(1,1/sin(toRadians( -90-trial.getCurrent().at("Slant") )),1); //backprojection phase
            break;
        }
        case 180:
        {
            glTranslated( translationFactor.x(), translationFactor.y(), translationFactor.z());
            glRotated( -instantPlaneSlant ,0,1,0);
            glScaled(1/sin(toRadians( -90-trial.getCurrent().at("Slant") )),1,1); //backprojection phase
            break;
        }
        case 270:
        {
            glTranslated( translationFactor.x(), translationFactor.y(), translationFactor.z());
            glRotated( -instantPlaneSlant ,1,0,0);
            glScaled(1,1/sin(toRadians( -90-trial.getCurrent().at("Slant") )),1); //backprojection phase
            break;
        }
        }
		glGetDoublev(GL_MODELVIEW_MATRIX,objectActiveTransformation.data());
        stimDrawer.draw();
        glPopMatrix();
    }
    else
    {
        // ANCORATO
        glPushMatrix();
        glLoadMatrixd( (headEyeCoords.getRigidStart().getFullTransformation()*Translation3d(Vector3d(0,0,focalDistance))).data() );
        glGetDoublev(GL_MODELVIEW_MATRIX,objectActiveTransformation.data());
		stimDrawer.draw();
        glPopMatrix();
    }

	// Draw the occlusor
    if ( useCircularOcclusor )
    {
		double maskRadius=parameters.get("CircularOcclusorRadius");
        glPushMatrix();
        glLoadIdentity();
		Vector3d projCoords;
		if ( trial.getCurrent().at("StimulusAnchored") )
			projCoords << project( (headEyeCoords.getRigidStart().getFullTransformation()*Translation3d(Vector3d(0,0,focalDistance))).translation() );
		else
			projCoords << project( Vector3d(0,0,focalDistance) );
		circleMask( projCoords.x(), projCoords.y(), maskRadius );
        glPopMatrix();
    }
	bool passiveMode=false;
	stimDrawer.projectStimulusPoints( objectActiveTransformation, headEyeCoords.getRigidStart().getFullTransformation(), cam, focalDistance, screen, eyeCalibration, passiveMode, true);
}
Ejemplo n.º 15
0
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:
        theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]/2*(1-factors["Onset"]*variable)));
        //old fantoni theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]*(1-variable)/2));// inclinazione uguale a slant quando variable= 0.5
        angle = toDegrees(theta);
        glRotated(angle,0,1,0);
        glScaled(1/sin(toRadians( -90-factors["Slant"])),1,1);	//backprojection phase
        break;
    case 90:
        theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]/2*(1-factors["Onset"]*variable)));
        // old fantoni theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]*(1-variable)/2));
        angle = toDegrees(theta);

        glRotated( angle,1,0,0);
        glScaled(1,1/sin(toRadians( -90-factors["Slant"] )),1); //backprojection phase
        break;
    case 180:
        theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]/2*(1+factors["Onset"]*variable)));
        //old fantoni theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]*(1-(1-variable)/2)));
        angle = toDegrees(theta);

        glRotated(angle,0,1,0);
        glScaled(1/sin(toRadians( -90-factors["Slant"] )),1,1); //backprojection phase
        break;
    case 270:
        theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]/2*(1+factors["Onset"]*variable)));
        // old fantoni theta = acos(exp(-0.346574+0.5*factors["Def"]-factors["Def"]*(1-(1-variable)/2)));
        angle = toDegrees(theta);

        glRotated( angle,1,0,0);
        glScaled(1,1/sin(toRadians( -90-factors["Slant"] )),1); //backprojection phase
        break;
    }
    //cout << angle << endl;

    if (isInside && sumOutside < 0 )
        stimDrawer.draw();
    glPopMatrix();

    // Draw fixation (Always @ full-speed)
    if (isInside && sumOutside < 0 )
    {
        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();
    }

}
void drawRedDotsPlane()
{   // Draw the stimulus ( red-dots plane )
	glDisable(GL_COLOR_MATERIAL);
	glDisable(GL_BLEND);
	glDisable(GL_LIGHTING);

	Matrix3d objrotation ;
	Vector3d stimulusCenter;
    
	double instantPlaneSlant=0; 
	
	// IMPORTANT Reset the previous status of transformation
	objectActiveTransformation.setIdentity();

	switch ( (int) factors["Rotation"] )
	{
	case 2:
	{
		objrotation = (AngleAxis<double>(eulerAngles.getYaw()*factors["FollowingSpeed"], Vector3d::UnitY())
		*AngleAxis<double>(eulerAngles.getPitch(), Vector3d::UnitX())).toRotationMatrix();
		instantPlaneSlant = toDegrees(eulerAngles.getYaw())*factors["RotationSpeed"]+factors["Slant"];
		stimulusCenter = objrotation*Vector3d(0,0,focalDistance)+headEyeCoords.getRigidStart().getFullTransformation().translation();
		objectActiveTransformation.linear()=objrotation;
	}
	break;
	case 1:
	{
		objrotation = (AngleAxis<double>(eulerAngles.getYaw(), Vector3d::UnitY())
		*AngleAxis<double>(eulerAngles.getPitch()*factors["FollowingSpeed"], Vector3d::UnitX())).toRotationMatrix();
		instantPlaneSlant = toDegrees(eulerAngles.getPitch())*factors["RotationSpeed"]+factors["Slant"];
		stimulusCenter = objrotation*Vector3d(0,0,focalDistance)+headEyeCoords.getRigidStart().getFullTransformation().translation();
		objectActiveTransformation.linear()=objrotation;
	}
	break;
	case 0:
	{
		objrotation = (AngleAxis<double>(eulerAngles.getYaw(), Vector3d::UnitY())
		*AngleAxis<double>(eulerAngles.getPitch(), Vector3d::UnitX())).toRotationMatrix();
		//instantPlaneSlant = eyeRight.x()*factors["RotationSpeed"]/10+factors["Slant"];
		instantPlaneSlant = toDegrees( atan(eyeRight.x()/abs(focalDistance+eyeRight.z()) ) )+factors["Slant"];
		stimulusCenter  = headEyeCoords.getRigidStart().getFullTransformation().linear()*Vector3d(eyeRight.x()*factors["FollowingSpeed"],eyeRight.y(),eyeRight.z()+focalDistance);
		objectActiveTransformation.linear() = objrotation;
	}
	break;

	}
	objectActiveTransformation.translation() = stimulusCenter;
	
	//cerr << instantPlaneSlant << endl;

	glPushMatrix();     // PUSH MATRIX
	glLoadIdentity();
	glMultMatrixd(objectActiveTransformation.data());
	
	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;
    }
	stimDrawer.draw();

	glPopMatrix();	// POP MATRIX

}