Example #1
0
	//constructor .. e apelat cand e instantiata clasa
	Laborator(){
		//setari pentru desenare, clear color seteaza culoarea de clear pentru ecran (format R,G,B,A)
		glClearColor(0.5,0.5,0.5,1);
		glClearDepth(1);			//clear depth si depth test (nu le studiem momentan, dar avem nevoie de ele!)
		glEnable(GL_DEPTH_TEST);	//sunt folosite pentru a determina obiectele cele mai apropiate de camera (la curs: algoritmul pictorului, algoritmul zbuffer)
		
		//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");
		

		//Initializam pod_racer
		player = new Object("resurse\\pod racer.obj");
		//player->scale(2, 2, 2);
		player->rotate(180, 0, 1, 0);
		objects.push_back(player);
		//Initializam stadion
		//stadium = new Object("resurse\\Stadion.obj");
		//objects.push_back(stadium);
		
		//matrici de modelare si vizualizare
		cam1.set(glm::vec3(0,2,-4), glm::vec3(0,5,-100), glm::vec3(0,1,0));
		cam2.set(glm::vec3(0, 0, 40), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
		cam3.set(glm::vec3(0, 0, 40), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));

		//desenare wireframe
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		glLineWidth(10);
		glPointSize(10);

	}
Example #2
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;
	}
Example #3
0
	//constructor .. e apelat cand e instantiata clasa
	Laborator(){
		//setari pentru desenare, clear color seteaza culoarea de clear pentru ecran (format R,G,B,A)
		glClearColor(0.8,0.8,0.8,1);
		glClearDepth(1);			//clear depth si depth test (nu le studiem momentan, dar avem nevoie de ele!)
		glEnable(GL_DEPTH_TEST);	//sunt folosite pentru a determina obiectele cele mai apropiate de camera (la curs: algoritmul pictorului, algoritmul zbuffer)
		
		//initializari
		timp = 0.0f;
		amplitudine = 1.5f;
		frecventa = glm::pi<float>() /15;  // 2pi/lungime   ---    lungime e 30
		faza = frecventa /2 ;// viteza * frecventa ---- viteza = 0.5
		directional = 0; circular = 0; // unde
		directie = glm::vec3(1, 0, 1);
		centru.x = 150;
		centru.z =  10;
		drawable = 0;
		//incarca un shader din fisiere si gaseste locatiile matricilor relativ la programul creat
		gl_program_shader_gouraud = lab::loadShader("shadere\\shader_gouraud_vertex.glsl", "shadere\\shader_gouraud_fragment.glsl");

		//incarca o sfera
		lab::loadObj("resurse\\sphere.obj",mesh_vao_sphere, mesh_vbo_sphere, mesh_ibo_sphere, mesh_num_indices_sphere);	

		//incarca un plan
		//lab::loadObj("resurse\\plane.obj",mesh_vao_ground, mesh_vbo_ground, mesh_ibo_ground, mesh_num_indices_ground);	
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++) {
				ver.push_back(lab::VertexFormat(i, 0, -j, 0, 1, 0));
			}
		}
		for (int i = 0; i < 99; i++) {
			for (int j = 0; j < 99; j++) {
				ind.push_back(glm::uvec3(i * 100 + j, (i + 1) * 100 + j, (i + 1) * 100 + j + 1));
				ind.push_back(glm::uvec3(i * 100 + j, (i + 1) * 100 + j + 1, i * 100 + j + 1));
			}
		}
		// create grid
		createGrid();

		//lumina & material
		eye_position = glm::vec3(50, 25, 0);
		FPS.set(glm::vec3(50, 25, 0), glm::vec3(50, 0, -15), glm::vec3(0, 1, 0));
		
		light_position = glm::vec3(50,10,-50);
		material_shininess = 30;
		material_kd = 0.5;
		material_ks = 0.5;

		//matrici de modelare si vizualizare
		model_matrix = glm::mat4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);

		//desenare wireframe
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}
Example #4
0
	//constructor .. e apelat cand e instantiata clasa
	Laborator(){
		//setari pentru desenare, clear color seteaza culoarea de clear pentru ecran (format R,G,B,A)
		glClearColor(0.5,0.5,0.5,1);
		glClearDepth(1);			//clear depth si depth test (nu le studiem momentan, dar avem nevoie de ele!)
		glEnable(GL_DEPTH_TEST);	//sunt folosite pentru a determina obiectele cele mai apropiate de camera (la curs: algoritmul pictorului, algoritmul zbuffer)
		
		//incarca un shader din fisiere si gaseste locatiile matricilor relativ la programul creat
		lab::gl_program_shader_gouraud = lab::loadShader("shadere\\shader_gouraud_vertex.glsl", "shadere\\shader_gouraud_fragment.glsl");
	
		//incarca o sfera
		lab::loadObj("resurse\\sphere.obj",mesh_vao_sphere, mesh_vbo_sphere, mesh_ibo_sphere, mesh_num_indices_sphere);	

		ground = myLoadGround_as_Mesh();

		// init camera
		camera.set(glm::vec3(0, 10, 50), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));

		//lumina & material
		eye_position = glm::vec3(0, 10, 50);
		light_position = glm::vec3(10, 7, -100);
		material_shininess = 30;
		material_kd = 0.5;
		material_ks = 0.5;
		
		amplitudine[0] = 5.0f;
		amplitudine[1] = 5.0f;
		amplitudine[2] = 5.0f;
		lungime_unda[0] = 40.0f;
		lungime_unda[1] = 40.0f;
		lungime_unda[2] = 40.0f;
		viteza_s[0] = 2.0f;
		viteza_s[1] = 2.0f;
		viteza_s[2] = 0.5f;
		
		centru = glm::vec2(10, 10);

		for (int i = 0; i < 3; i++){	
			frecv[i] = 2 * pi / lungime_unda[i];
			faza[i] = viteza_s[i] * 2 * pi / lungime_unda[i];
		}

		timp = 1;

		//matrici de modelare si vizualizare
		model_matrix = glm::mat4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
		//view_matrix = glm::lookAt(eye_position, glm::vec3(0,0,0), glm::vec3(0,1,0));
		matrice_translatie_1 = glm::translate(model_matrix, glm::vec3(light_position.x, light_position.y, light_position.z + 100));
		//desenare wireframe
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	}
Example #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 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; }
		
	}