void BaseBuilding::creerToitPrisme(bool addChimney)
{

	/*
	 d_________________c
	 |				   |
	e|________g________|f --> arrête supérieure du prisme
	 | 				   |
	 |________h________|
	 a				   b
	*/

	double air = Quadrangle(listPoints[0],listPoints[1],listPoints[2],listPoints[3]).Area();

	if(air > airMin)
	{
		double hauteurPrisme = (double) UNIT * 3;
		Vector monterEnZ(0,0,hauteurPrisme);
		int j;

		Vector e = ( (listPoints[3] + listPoints[0]) /2 ) + monterEnZ;
		Vector f = ( (listPoints[2] + listPoints[1]) /2 ) + monterEnZ;

		glBegin(GL_TRIANGLES); // Face ade
			Vector n= (listPoints[3]-listPoints[0])/(e-listPoints[0]);
			n/=Norm(n);
			glNormal3f(n[0],n[1],n[2]);
			glColor3ub(Vector::col1,Vector::col2,Vector::col3);
			glVertex3f(listPoints[0][0], listPoints[0][1], listPoints[0][2]);
			glVertex3f(listPoints[3][0], listPoints[3][1], listPoints[3][2]);
			glVertex3f(e[0], e[1], e[2]);

			  
			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[0][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[3][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(e[j]);			

		glEnd();

		glBegin(GL_QUADS); // Face abfe
			n= (listPoints[1]-listPoints[0])/(e-listPoints[0]);
			n/=Norm(n);
			glNormal3f(n[0],n[1],n[2]);
			glColor3ub(Vector::col1,Vector::col2,Vector::col3);
			glVertex3f(listPoints[0][0], listPoints[0][1], listPoints[0][2]);
			glVertex3f(listPoints[1][0], listPoints[1][1], listPoints[1][2]);
			glVertex3f(f[0], f[1], f[2]);
			glVertex3f(e[0], e[1], e[2]);

			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[0][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[1][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(f[j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(e[j]);
			
		glEnd();

		glBegin(GL_QUADS); // Face cdef
			n= (listPoints[3]-listPoints[2])/(f-listPoints[2]);
			n/=Norm(n);
			glNormal3f(n[0],n[1],n[2]);
			glColor3ub(Vector::col1,Vector::col2,Vector::col3);
			glVertex3f(listPoints[2][0], listPoints[2][1], listPoints[2][2]);
			glVertex3f(listPoints[3][0], listPoints[3][1], listPoints[3][2]);
			glVertex3f(e[0], e[1], e[2]);
			glVertex3f(f[0], f[1], f[2]);

			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[2][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[3][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(e[j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(f[j]);

		glEnd();

		glBegin(GL_TRIANGLES); // Face bcf
			n= (listPoints[2]-listPoints[1])/(f-listPoints[1]);
			n/=Norm(n);
			glNormal3f(n[0],n[1],n[2]);
			glColor3ub(Vector::col1,Vector::col2,Vector::col3);
			glVertex3f(listPoints[1][0], listPoints[1][1], listPoints[1][2]);
			glVertex3f(listPoints[2][0], listPoints[2][1], listPoints[2][2]);
			glVertex3f(f[0], f[1], f[2]);

			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[1][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(listPoints[2][j]);
			for(j=0;j<=2;j++)
				PrismRoof.push_back(f[j]);

		glEnd();


		//-------------------Cheminée----------------------------->

		if(addChimney)
		{
			Vector g = (e + f)/2;
			Vector h = (listPoints[0] + listPoints[1])/2;

			double chimneyWidth = (double) UNIT;

			std::vector<Vector> newPoints;
			newPoints.push_back(listPoints[0] + monterEnZ/3);
			newPoints.push_back(h + monterEnZ/3); //e - monterEnZ + (monterEnZ/3)
			newPoints.push_back(e - (monterEnZ*2/3)); //g - monterEnZ + (monterEnZ/3)
			newPoints.push_back(g - (monterEnZ*2/3));

			Vector tmp = (listPoints[0] + e + g + h)/4;
			Vector centerAEGH = Vector(tmp[0],tmp[1], newPoints[0][2]); //le centre de la cheminée

			double tailleAd = Norm(newPoints[3] - newPoints[0]);
			double tailleAb = Norm(newPoints[1] - newPoints[0]);
			double ratioAbEtDc,ratioAdEtBc;
			if(tailleAd > tailleAb)
			{
				ratioAbEtDc = tailleAd/tailleAb;
				ratioAdEtBc = 1;
			}
			else
			{
				ratioAbEtDc = 1;
				ratioAdEtBc = tailleAb/tailleAd;
			}
		
			for(unsigned int i = 0; i < newPoints.size(); i++)
			{
				double pas = Norm(newPoints[i] - centerAEGH)/chimneyWidth;
				newPoints[i] = centerAEGH + ( (newPoints[i] - centerAEGH)/pas );
			}

			//Les sommets de la cheminée
			Vector a,b,c,d;
			a = newPoints[0];
			b = newPoints[1];
			c = newPoints[3];
			d = newPoints[2];

			//comme on veut que tous les côtés soient égaux, on applique un ratio
			PrismQuad(
				a,
				a + (b - a)*ratioAbEtDc,
				d + (c - d)*ratioAbEtDc,
				a + (d - a)*ratioAdEtBc,
				((double)UNIT)*3).Render();
		}
	}

}
void Batiment::creerToitPyramide()
{
	double largeurBord = (double) UNITE*0.2;
	double hauteurBord = (double) UNITE*0.2;
	double air = Quadrangle(listePoints[0],listePoints[1],listePoints[2],listePoints[3]).Area();
	bool airMini = air > 8*(largeurBord*largeurBord);
	int j;

	if(airMini)
	{
		double hauteurPyramide = hauteurEtage*2;
		Vector monterEnZ(0,0,hauteurPyramide);
		Vector centre(0,0,0);

		for(unsigned int i = 0; i < listePoints.size(); i++) centre += listePoints[i];
		centre /= listePoints.size();
		centre += monterEnZ;// mise à jour de Z


		glBegin(GL_TRIANGLES); // Debut du dessin de la pyramide
			glColor3ub(Vector::col1,Vector::col2,Vector::col3);
			for(unsigned int i = 0; i < 4; i++)
			{
				glNormal3d(0,0,1.0f);
				glVertex3f(centre[0], centre[1], centre[2]); // Haut du triangle de face
				glVertex3f(listePoints[i%4][0], listePoints[i%4][1], listePoints[i%4][3]); // Bas gauche du triangle de face
				glVertex3f(listePoints[(i+1)%4][0], listePoints[(i+1)%4][1], listePoints[(i+1)%4][3]); // Bas droit du triangle de face

				for(j=0;j<=2;j++)
			   	    ToitPyramide.push_back(centre[j]);
			    for(j=0;j<=1;j++)
				    ToitPyramide.push_back(listePoints[i%4][j]);
				if(j==2)
					ToitPyramide.push_back(listePoints[i%4][j+1]);
			    for(j=0;j<=1;j++)
			        ToitPyramide.push_back(listePoints[(i+1)%4][j]);
				if(j==2)
					ToitPyramide.push_back(listePoints[(i+1)%4][j+1]);

			}
		glEnd(); // Fin du dessin de la pyramide

		//ajout d'une antenne
		if(rand()%100 > 30)
		{
			//"0.9*" pour enterrer l'antenne dans la pyramide
			Vector enterrer(0,0, -0.15*hauteurPyramide);

			std::vector<Vector> quadrangleIn;

			// la base de l'antenne
			for(unsigned int i = 0; i < listePoints.size(); i++)
			{
				Vector in = (listePoints[i] + monterEnZ) + (centre - (listePoints[i] + monterEnZ))*0.97 + enterrer;
				quadrangleIn.push_back(in);
			}
			
			PrismQuad(quadrangleIn[0], quadrangleIn[1], quadrangleIn[2], quadrangleIn[3], hauteurEtage).Render();


			// l'antenne
			for(unsigned int i = 0; i < listePoints.size(); i++)
				quadrangleIn[i] = quadrangleIn[i] + (centre - quadrangleIn[i])*0.5;
			
			PrismQuad(quadrangleIn[0], quadrangleIn[1], quadrangleIn[2], quadrangleIn[3], hauteurPyramide*1.5).Render();
		}

	}
}