示例#1
0
文件: main.cpp 项目: flaviusone/EGC
	//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; }
		
	}
示例#2
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;
	}
示例#3
0
	Tema4() {
		// Setari pentru desenare, clear color seteaza culoarea de clear pentru ecran (format R,G,B,A).
		glClearColor(0.0, 0.0, 0.0, 1);
		glClearDepth(1);			// clear depth si depth test sunt folosite pentru a determina obiectele cele mai apropiate de camera.
		glEnable(GL_DEPTH_TEST);
		
		// Incarca un shader din fisiere si gaseste locatiile matricilor relativ la programul creat.
		gl_program_shader = lab::loadShader("shadere\\shader_vertex.glsl", "shadere\\shader_fragment.glsl");
		
		// Incarca texturi.
		textures.push_back(lab::loadTextureBMP("resurse\\b1.bmp"));
		textures.push_back(lab::loadTextureBMP("resurse\\b2.bmp"));
		textures.push_back(lab::loadTextureBMP("resurse\\b3.bmp"));
		textures.push_back(lab::loadTextureBMP("resurse\\b4.bmp"));
		textures.push_back(lab::loadTextureBMP("resurse\\b5.bmp"));
		textures.push_back(lab::loadTextureBMP("resurse\\flying_car_texture.bmp"));

		for (int i = 0; i < textures.size(); ++i) {
			glActiveTexture(GL_TEXTURE0 + i + 1);
			glBindTexture(GL_TEXTURE_2D, textures[i]);
		}

		srand(time(NULL));

		// Camere
		view1 = new lab::Camera();
		view1->set(glm::vec3(-10, Building::MAX_HEIGHT + 10, 500), glm::vec3(490, Building::MAX_HEIGHT + 10, 500), glm::vec3(0, 1, 0));
		view2 = new lab::Camera();
		view2->set(glm::vec3(500, 750, 500), glm::vec3(500.1, 0, 500.1), glm::vec3(0, 1, 0));
		view2->rotateFPSoX(-45);
		is_fps = true;

		vehicle = new Vehicle();
		quad = new Quad(1000);
		// Folosesc primele 5 texturi pentru cladiri.
		city = new City(textures.size() - 1);

		// Lumina & material
		material_shininess = 10;
		material_kd = 0.4;
		material_ks = 0.1;

		// Desenare solid
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

		modified = true;
	}