Esempio n. 1
0
	//functie chemata inainte de a incepe cadrul de desenare, o folosim ca sa updatam situatia scenei ( modelam/simulam scena)
	void notifyBeginFrame(){
		if (up_pressed){
			glm::vec3 temp = glm::normalize(cam1.getforward());
			printf("%f %f %f \n", temp.x, temp.y, temp.z);
			//player->translate2(temp*viteza);
			player->translate2(temp*(-viteza));
			cam1.translateForward(viteza);
		}
		if (down_pressed){
			glm::vec3 temp = glm::normalize(cam1.getforward());
			//player->translate2(temp*(-viteza));
			player->translate2(temp*viteza);
			cam1.translateForward(-viteza);
		}
		if (right_pressed){
			player->rotate(-5.7f, 0, 1, 0);
			cam1.rotateTPSoY(0.1, -4);
		}
		if (left_pressed){
			player->rotate(5.7f, 0, 1, 0);
			cam1.rotateTPSoY(-0.1, -4);
		}

		if (enemy_state == 1){
			//player->translate(0, 0, viteza);
		}
		else{

		}

		//player->rotate(1.0f, 0, 1, 0);
	}
Esempio n. 2
0
	//tasta apasata
	void notifyKeyPressed(unsigned char key_pressed, int mouse_x, int mouse_y){

		if (key_pressed == 27) lab::glut::close();	//ESC inchide glut si 
		if (key_pressed == 32) {	//SPACE
			//reincarca shader
			glDeleteProgram(lab::gl_program_shader_gouraud);
			lab::gl_program_shader_gouraud = lab::loadShader("shadere\\shader_gouraud_vertex.glsl", "shadere\\shader_gouraud_fragment.glsl");
		}

		if (key_pressed == 'h'){
			static bool wire = true;
			wire = !wire;
			glPolygonMode(GL_FRONT_AND_BACK, (wire ? GL_LINE : GL_FILL));
		}
		if (key_pressed == 'a') {
			matrice_translatie_1 *= myTranslate(-2.0f, 0, 0);
			light_position.x -= 10;
		}
		if (key_pressed == 'd') {
			matrice_translatie_1 *= myTranslate(2.0f, 0, 0);
			light_position.x += 10;
		}
		if (key_pressed == 'w') {
			matrice_translatie_1 *= myTranslate(0, 0, -2.0f);
			light_position.z -= 10;
		}
		if (key_pressed == 's') {
			matrice_translatie_1 *= myTranslate(0, 0, 2.0f);
			light_position.z += 10;
		}

		float moveSpeed = 5;

		// Camera Translation
		if (key_pressed == 'u') { camera.translateForward(moveSpeed); }
		if (key_pressed == 'h') { camera.translateRight(-moveSpeed); }
		if (key_pressed == 'j') { camera.translateForward(-moveSpeed); }
		if (key_pressed == 'k') { camera.translateRight(moveSpeed); }
		if (key_pressed == 'i') { camera.translateUpword(moveSpeed); }
		if (key_pressed == 'y') { camera.translateUpword(-moveSpeed); }
	}
Esempio n. 3
0
	//tasta apasata
	void notifyKeyPressed(unsigned char key_pressed, int mouse_x, int mouse_y){
		if(key_pressed == 27) lab::glut::close();	//ESC inchide glut si 
		if(key_pressed == 32) {
			//SPACE reincarca shaderul si recalculeaza locatiile (offseti/pointeri)
			glDeleteProgram(gl_program_shader);
			gl_program_shader = lab::loadShader("shadere\\shader_vertex.glsl", "shadere\\shader_fragment.glsl");
		}
		if(key_pressed == 'i'){
			static bool wire =true;
			wire=!wire;
			glPolygonMode(GL_FRONT_AND_BACK, (wire?GL_LINE:GL_FILL));
		}
		if(key_pressed == 'w') { cam1.translateForward(1.0f); }
		if(key_pressed == 'a') { cam1.translateRight(-1.0f); }
		if(key_pressed == 's') { cam1.translateForward(-1.0f); }
		if(key_pressed == 'd') { cam1.translateRight(1.0f); }
		if(key_pressed == 'r') { cam1.translateUpword(1.0f); }
		if(key_pressed == 'f') { cam1.translateUpword(-1.0f); }
		if(key_pressed == 'q') { cam1.rotateFPSoY(1.0f); }
		if(key_pressed == 'e') { cam1.rotateFPSoY(-1.0f); }
		if(key_pressed == 'z') { cam1.rotateFPSoZ(-1.0f); }
		if(key_pressed == 'c') { cam1.rotateFPSoZ(1.0f); }
		if(key_pressed == 't') { cam1.rotateFPSoX(1.0f); }
		if(key_pressed == 'g') { cam1.rotateFPSoX(-1.0f); }
		if(key_pressed == 'o') { cam1.set(glm::vec3(0,0,40), glm::vec3(0,0,0), glm::vec3(0,1,0)); }
		if(key_pressed == '1') { cam1.rotateTPSoX(1.0f,40.0f); }
		if(key_pressed == '2') { cam1.rotateTPSoX(-1.0f,40.0f); }
		if(key_pressed == '3') { cam1.rotateTPSoY(1.0f,40.0f); }
		if(key_pressed == '4') { cam1.rotateTPSoY(-1.0f,40.0f); }
		if(key_pressed == '5') { cam1.rotateTPSoZ(1.0f,40.0f); }
		if(key_pressed == '6') { cam1.rotateTPSoZ(-1.0f,40.0f); }
		if (key_pressed == '7') { active_camera = 1; }
		if (key_pressed == '8') { active_camera = 2; }
		if (key_pressed == '9') { active_camera = 3; }
		if (key_pressed == '0') { active_camera = 4; }
		
	}
Esempio n. 4
0
	void notifyKeyPressed(unsigned char key_pressed, int mouse_x, int mouse_y){
		//ESC inchide glut.
		if (key_pressed == 27) lab::glut::close();
		if (key_pressed == 'W') {
			static bool wire = true;
			wire = !wire;
			glPolygonMode(GL_FRONT_AND_BACK, (wire ? GL_LINE : GL_FILL));
		}
		// Taste pentru deplasarea camerei FPS de sus.
		if (key_pressed == 'w')
			view1->translateForward(1.0f);
		if (key_pressed == 's')
			view1->translateForward(-1.0f);
		if (key_pressed == 'q')
			view1->translateUpword(1.0f);
		if (key_pressed == 'e')
			view1->translateUpword(-1.0f);
		if (key_pressed == 'a')
			view1->translateRight(-1.0f);
		if (key_pressed == 'd')
			view1->translateRight(1.0f);
		if (key_pressed == '1')
			view1->rotateFPSoX(1.0f);
		if (key_pressed == '2')
			view1->rotateFPSoX(-1.0f);
		if (key_pressed == '3')
			view1->rotateFPSoY(1.0f);
		if (key_pressed == '4')
			view1->rotateFPSoY(-1.0f);
		if (key_pressed == '5')
			view1->rotateFPSoZ(1.0f);
		if (key_pressed == '6')
			view1->rotateFPSoZ(-1.0f);
		if (key_pressed == 'c')
			is_fps = !is_fps;
		modified = true;
	}
Esempio n. 5
0
	//tasta apasata
	void notifyKeyPressed(unsigned char key_pressed, int mouse_x, int mouse_y){
		if(key_pressed == 27) lab::glut::close();	//ESC inchide glut si 
		if(key_pressed == 32) {	//SPACE
			//reincarca shader
			glDeleteProgram(gl_program_shader_gouraud);
			gl_program_shader_gouraud = lab::loadShader("shadere\\shader_gouraud_vertex.glsl", "shadere\\shader_gouraud_fragment.glsl");
		}
		// grid view
		if(key_pressed == 'g'){
			static bool wire =true;
			wire=!wire;
			glPolygonMode(GL_FRONT_AND_BACK, (wire?GL_LINE:GL_FILL));
		}
		// directional
		if (key_pressed == '1') {
			directional ^= 1;
		}
		// circular
		if (key_pressed == '2') {
			circular ^= 1;
		}
		// inainte
		if (key_pressed == 'w') {
			FPS.translateForward(1);
			eye_position = FPS.getPosition();
		}
		// inapoi 
		if (key_pressed == 's') {
			FPS.translateForward(-1);
			eye_position = FPS.getPosition();
		}
		// rotire stanga
		if (key_pressed == 'a') {
			FPS.rotateFPS_OY(5);
			eye_position = FPS.getPosition();
		}
		// rotire dreapta
		if (key_pressed == 'd') {
			FPS.rotateFPS_OY(-5);
			eye_position = FPS.getPosition();
		}
		// rotire sus
		if (key_pressed == 'q') {
			FPS.rotateFPS_OX(-5);
			eye_position = FPS.getPosition();
		}
		// rotire jos
		if (key_pressed == 'e') {
			FPS.rotateFPS_OX(5);
			eye_position = FPS.getPosition();
		}
		// rotire oz
		if (key_pressed == 'z') {
			FPS.rotateFPS_OZ(-5);
			eye_position = FPS.getPosition();
		}
		// rotire oz
		if (key_pressed == 'c') {
			FPS.rotateFPS_OZ(5);
			eye_position = FPS.getPosition();
		}

	}