Version acceptable pourl es toits.

This commit is contained in:
Yoann 2012-01-18 15:09:57 +01:00
parent 8c844607e8
commit 876fe13a48
3 changed files with 13 additions and 5 deletions

View File

@ -35,7 +35,7 @@ public:
static const unsigned int largeurRoute = 200; static const unsigned int largeurRoute = 200;
static const unsigned int largeurTrottoir = 140; static const unsigned int largeurTrottoir = 140;
static const unsigned int hauteurEtage = 300; static const unsigned int hauteurEtage = 300;
static const unsigned int hauteurToit = 200 * 10; static const unsigned int hauteurToit = 200;
static const unsigned int hauteurTrottoir = 20; static const unsigned int hauteurTrottoir = 20;
static const unsigned int hauteurMaxBatiment = hauteurTrottoir + hauteurEtage + hauteurToit; static const unsigned int hauteurMaxBatiment = hauteurTrottoir + hauteurEtage + hauteurToit;
}; };

View File

@ -15,7 +15,7 @@ void ToitQuad::triangulation() {
switch (hash2(seed, -1) % 4) { switch (hash2(seed, -1) % 4) {
case 0: pointCentral(); break; case 0: pointCentral(); break;
// TODO : deuxPoints() et deuxPointsVerticaux() ne génèrent pas des quad où les 4 points sont sur le même plan. // TODO : deuxPoints() et deuxPointsVerticaux() ne génèrent pas des quad où les 4 points sont sur le même plan.
case 1: deuxPointsVerticaux(); break; case 1: deuxPoints(); break;
case 2: deuxPointsVerticaux(); break; case 2: deuxPointsVerticaux(); break;
case 3: case 3:
default: plat(); break; default: plat(); break;
@ -33,8 +33,16 @@ void ToitQuad::deuxPoints() {
// Orienter c dans le sens de la longueur d'est en ouest. // Orienter c dans le sens de la longueur d'est en ouest.
Quad q = c >> ((c.maxLengthNS() > c.maxLengthEW()) ? 1 : 0); Quad q = c >> ((c.maxLengthNS() > c.maxLengthEW()) ? 1 : 0);
Quad qh = q.offsetNormal(height); Quad qh = q.offsetNormal(height);
Vertex w = Segment(qh[NW], qh[SW]).randomPos(seed, 0, 1.f/3.f, 2.f/3.f);
Vertex e = Segment(qh[NE], qh[SE]).randomPos(seed, 1, 1.f/3.f, 2.f/3.f); float coef = height / Segment(q[NW],q[SW]).length();
float eLength = Segment(q[NE],q[SE]).length();
qh[NE] = q[NE] + Vertex(qh[NE]-q[NE]).setNorm(coef*eLength);
qh[SE] = q[SE] + Vertex(qh[SE]-q[SE]).setNorm(coef*eLength);
//Vertex w = Segment(qh[NW], qh[SW]).randomPos(seed, 0, 1.f/3.f, 2.f/3.f);
//Vertex e = Segment(qh[NE], qh[SE]).randomPos(seed, 1, 1.f/3.f, 2.f/3.f);
Vertex w = qh[SW] + Vertex(qh[NW] - qh[SW])/2;
Vertex e = qh[SE] + Vertex(qh[NE] - qh[SE])/2;
Vertex centerE = Segment(e,w).randomPos(seed, 2, 0.6f, 0.8f); Vertex centerE = Segment(e,w).randomPos(seed, 2, 0.6f, 0.8f);
Vertex centerW = Segment(e,w).randomPos(seed, 2, 0.2f, 0.4f); Vertex centerW = Segment(e,w).randomPos(seed, 2, 0.2f, 0.4f);
addGPUTriangle(q[SE], centerE, q[NE], Couleurs::toit); addGPUTriangle(q[SE], centerE, q[NE], Couleurs::toit);

View File

@ -147,7 +147,7 @@ void View::renderScene(int lastTime, int currentTime) {
lod.setCamera(camera.cameraCenter); lod.setCamera(camera.cameraCenter);
setLight(); setLight();
//setSkybox(); setSkybox();
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
root->display(); root->display();