Ejemplo n.º 1
0
void Camera::film(){

    int currentTime = glutGet(GLUT_ELAPSED_TIME);
    int timeInterval = 5;//currentTime - previousTime;

    float tmpEyeX, tmpEyeY, tmpEyeZ;
    tmpEyeX = sin(mouseDirection[1]*M_PI/180)*sin(mouseDirection[0]*M_PI/180);
    tmpEyeZ = sin(mouseDirection[1]*M_PI/180)*cos(mouseDirection[0]*M_PI/180);
    tmpEyeY = cos(mouseDirection[1]*M_PI/180);

    if(move[FORWARD]){
        setEyeX(getEyeX() + (timeInterval * tmpEyeX / 6));
    	setEyeY(getEyeY() + (timeInterval * tmpEyeY / 6));
    	setEyeZ(getEyeZ() + (timeInterval * tmpEyeZ / 6));
    }
    if(move[BACKWARD]){
        setEyeZ( getEyeZ() - (timeInterval * tmpEyeZ / 6));
    	setEyeY( getEyeY() - (timeInterval * tmpEyeY / 6));
    	setEyeX( getEyeX() - (timeInterval * tmpEyeX / 6));
    }
    if(move[LEFT]){
        setEyeX( getEyeX() + (timeInterval * sin((mouseDirection[0]+90)*M_PI/180) / 6));
	    setEyeZ( getEyeZ() + (timeInterval * cos((mouseDirection[0]+90)*M_PI/180) / 6));
    }
    if(move[RIGHT]){
        setEyeX( getEyeX() - (timeInterval * sin((mouseDirection[0]+90)*M_PI/180) / 6));
	    setEyeZ( getEyeZ() - (timeInterval * cos((mouseDirection[0]+90)*M_PI/180) / 6));
    }

    glLoadIdentity();

    setCenterX(getEyeX()+tmpEyeX);
    setCenterY(getEyeY()+tmpEyeY);
    setCenterZ(getEyeZ()+tmpEyeZ);

	gluLookAt(
        getEyeX(),getEyeY(),getEyeZ(),
	    getCenterX(),getCenterY(),getCenterZ(),
	    0.0f, 1.0f,  0.0f
    );

    int xc = glutGet(GLUT_WINDOW_WIDTH)/2;
    int yc = glutGet(GLUT_WINDOW_HEIGHT)/2;

    glutWarpPointer(xc,yc);

    move[0] = false;
    move[1] = false;
    move[2] = false;
    move[3] = false;
}
Ejemplo n.º 2
0
void Robot::refreshLight(){
		
	if(isMyLightOn){
		GLfloat eyeTemp[3];
		eyeTemp[0] = getEyeX();
		eyeTemp[1] = getEyeY();
		eyeTemp[2] = getEyeZ();
		GLfloat* lookTemp = getLightLookAt();

		GLfloat light8_position[] = { eyeTemp[0], eyeTemp[1], eyeTemp[2], 1.0f };
		GLfloat light8_direction[] = { lookTemp[0]-eyeTemp[0], lookTemp[1]-eyeTemp[1], lookTemp[2]-eyeTemp[2]};

		glLightfv(GL_LIGHT5, GL_AMBIENT, light8_ambient);
		glLightfv(GL_LIGHT5, GL_DIFFUSE, light8_diffuse);
		glLightfv(GL_LIGHT5, GL_SPECULAR, light8_specular);
		glLightfv(GL_LIGHT5, GL_POSITION, light8_position);
		glLightfv(GL_LIGHT5, GL_SPOT_DIRECTION, light8_direction);
		glLightf(GL_LIGHT5, GL_SPOT_CUTOFF, 20.0f);
		glLightf(GL_LIGHT5, GL_SPOT_EXPONENT, 10.0f); 
	
		glEnable(GL_LIGHT5);

		delete [] lookTemp;
	}
}
Ejemplo n.º 3
0
/**************************************
Debug Function.
***************************************/
void Camera::debug(){
    system("clear");
    cout << " Eye:    " << getEyeX() << "  " << getEyeY() << "  " << getEyeZ() << endl;
    cout << " Center: " << getCenterX() << "  " << getCenterY() << "  " << getCenterZ() << endl;
    cout << " Up:     " << getUpX() << "  " << getUpY() << "  " << getUpZ() << endl;
    cout << endl;
    cout << " Perspective: " << getFovy() << "  " << getAspect() << "  " << getZNear() << "  " << getZFar() << endl;
}