Example #1
0
void Dialog::on_dialog_addCity_clicked()
{
      QString cityname = ui->name_line->text();
      qDebug() << cityname;

      QString cityX = ui->xline->text();
      qDebug() << cityX;

      QString cityY = ui->yline->text();
      qDebug() << cityY;


      int intCityX = cityX.toInt();
      qDebug() << intCityX;

      int intCityY = cityY.toInt();
      qDebug() << intCityY;

      ControlDialog controldialog (cityname, cityX, cityY);
      int result = controldialog.exec();

      if ( controldialog.control == 1)
      {
          City *NewCity = new City (cityname , intCityX , intCityY);
          map->addCity(NewCity);
          NewCity->draw(*scene);
          close();
      }
}
Example #2
0
	//functia de afisare (lucram cu banda grafica)
	void notifyDisplayFrame() {
		// Deseneaza doar daca s-a modificat pozitia camerei sau perspectiva (a fost apasata o tasta).
		if (modified) {
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

			// Foloseste shaderul.
			glUseProgram(gl_program_shader);

			// Trimite variabile uniforme la shader.
			glUniformMatrix4fv(glGetUniformLocation(gl_program_shader, "projection_matrix"), 1, false, glm::value_ptr(projection_matrix));
			glUniform1i(glGetUniformLocation(gl_program_shader, "tps_color"), 0);
			glUniform3f(glGetUniformLocation(gl_program_shader, "light_position"),
				view1->getPosition().x, view1->getPosition().y, view1->getPosition().z);
			glUniform3f(glGetUniformLocation(gl_program_shader, "eye_position"),
				view1->getPosition().x, view1->getPosition().y, view1->getPosition().z);
			glUniform3f(glGetUniformLocation(gl_program_shader, "light_direction"),
				view1->getForward().x, view1->getForward().y, view1->getForward().z);
			glUniform1i(glGetUniformLocation(gl_program_shader, "material_shininess"), material_shininess);

			if (is_fps)
				vehicle->drawGeometry(gl_program_shader, textures.size());

			view_matrix = is_fps ? view1->getViewMatrix() : view2->getViewMatrix();
			glUniformMatrix4fv(glGetUniformLocation(gl_program_shader, "view_matrix"), 1, false, glm::value_ptr(view_matrix));
			glUniform1f(glGetUniformLocation(gl_program_shader, "material_kd"), is_fps ? material_kd : 0);
			glUniform1f(glGetUniformLocation(gl_program_shader, "material_ks"), is_fps ? material_ks : 0);

			std::vector<glm::vec4> plane_coefs;
			glm::mat4 pv = projection_matrix * view1->getViewMatrix();

			// Calculeaza coeficientii ecuatiilor pentru planurile frustumului.
			plane_coefs.push_back(glm::vec4(pv[0][3] + pv[0][0], pv[1][3] + pv[1][0], pv[2][3] + pv[2][0], pv[3][3] + pv[3][0])); // left
			plane_coefs.push_back(glm::vec4(pv[0][3] - pv[0][0], pv[1][3] - pv[1][0], pv[2][3] - pv[2][0], pv[3][3] - pv[3][0])); // right
			plane_coefs.push_back(glm::vec4(pv[0][3] + pv[0][1], pv[1][3] + pv[1][1], pv[2][3] + pv[2][1], pv[3][3] + pv[3][1])); // bottom
			plane_coefs.push_back(glm::vec4(pv[0][3] - pv[0][1], pv[1][3] - pv[1][1], pv[2][3] - pv[2][1], pv[3][3] - pv[3][1])); // top
			plane_coefs.push_back(glm::vec4(pv[0][3] + pv[0][2], pv[1][3] + pv[1][2], pv[2][3] + pv[2][2], pv[3][3] + pv[3][2])); // near
			plane_coefs.push_back(glm::vec4(pv[0][3] - pv[0][2], pv[1][3] - pv[1][2], pv[2][3] - pv[2][2], pv[3][3] - pv[3][2])); // far

			quad->drawGeometry(gl_program_shader, is_fps, plane_coefs);
			city->draw(gl_program_shader, is_fps, plane_coefs);
			modified = false;
		}
	}