Corrections sur les bâtiments.

This commit is contained in:
Georges Dupéron 2012-01-19 23:59:28 +01:00
parent 760d2e8c0d
commit b8cc7bd90e
4 changed files with 25 additions and 19 deletions

View File

@ -48,8 +48,9 @@ void BatimentQuad_::sousBatiments() {
Quad q = c << c.maxLengthSide();
QuadBool qb = w << c.maxLengthSide();
Vertex n = Segment(q[NW], q[NE]).randomPos(seed, 0, 1.f/3.f, 1.f/2.f);
Vertex s = Segment(q[SE], q[SW]).randomPos(seed, 1, 1.f/3.f, 1.f/2.f);
float posDelta = std::min(1.f/6.f, q.minLengthEW() / q.length(N) * 0.2f);
Vertex n = Segment(q[NW], q[NE]).randomPos(seed, 0, 0.5f - posDelta, 0.5f + posDelta);
Vertex s = Segment(q[SE], q[SW]).randomPos(seed, 1, 0.5f - posDelta, 0.5f + posDelta);
bool small = q.surface() < 4 * Dimensions::minSurfaceSousBatiment;
@ -78,7 +79,7 @@ void BatimentQuad_::etages() {
addChild(new ArcheQuad(q, h));
} else {
qh = q.offsetNormal(floatInRange(seed, 1+i, Dimensions::hauteurEtage*0.9f, Dimensions::hauteurEtage*1.1f));
addChild(new EtageQuad(q,qh));
addChild(new EtageQuad(q, qh, w));
}
q = qh;
}
@ -86,14 +87,18 @@ void BatimentQuad_::etages() {
}
void BatimentQuad_::triangulation() {
Quad ch = c.offsetNormal(Dimensions::hauteurEtage + Dimensions::hauteurToit);
addGPUQuad(ch, Couleurs::toit);
for (int i = 0; i < 4; i++)
addGPUQuad(Quad(c[NE+i], c[SE+i], ch[SE+i], ch[NE+i]), Couleurs::mur);
if (w[N] || w[E] || w[S] || w[W]) {
Quad ch = c.offsetNormal(Dimensions::hauteurEtage * 2 + Dimensions::hauteurToit);
addGPUQuad(ch, Couleurs::toit);
for (int i = 0; i < 4; i++)
addGPUQuad(Quad(c[NE+i], c[SE+i], ch[SE+i], ch[NE+i]), Couleurs::mur);
} else {
addGPUQuad(c, Couleurs::herbe);
}
}
void BatimentQuad_::getBoundingBoxPoints() {
addBBPoints(c, Dimensions::hauteurEtage + Dimensions::hauteurToit);
addBBPoints(c, Dimensions::hauteurEtage * 2 + Dimensions::hauteurToit);
}
BatimentTri_::BatimentTri_(Triangle _c) : Chose(), c(_c) {
@ -105,12 +110,12 @@ bool BatimentTri_::split() {
}
void BatimentTri_::triangulation() {
Triangle th = c.offsetNormal(Dimensions::hauteurEtage + Dimensions::hauteurToit);
Triangle th = c.offsetNormal(Dimensions::hauteurEtage * 2 + Dimensions::hauteurToit);
addGPUTriangle(th, Couleurs::toit);
for (int i = 0; i < 3; i++)
addGPUQuad(Quad(c[LEFT+i], c[TOP+i], th[TOP+i], th[LEFT+i]), Couleurs::mur);
}
void BatimentTri_::getBoundingBoxPoints() {
addBBPoints(c, Dimensions::hauteurEtage + Dimensions::hauteurToit);
addBBPoints(c, Dimensions::hauteurEtage * 2 + Dimensions::hauteurToit);
}

View File

@ -43,7 +43,7 @@ public:
static const unsigned int maxEtages = 5;
static const unsigned int hauteurToit = 200;
static const unsigned int hauteurTrottoir = 20;
static const unsigned int hauteurMaxBatiment = hauteurTrottoir + hauteurEtage + hauteurToit;
static const unsigned int hauteurMaxBatiment = hauteurTrottoir + hauteurEtage * 2 + hauteurToit;
static const unsigned int minSurfaceSousBatiment = 100 * 100*100; // 100 m²
// Qualité

View File

@ -1,9 +1,10 @@
#include "all_includes.hh"
EtageQuad::EtageQuad(Quad _c, Quad _ch, bool _we, bool _ws, bool _ww, bool _wn)
: Chose(), c(_c), ch(_ch), we(_we), ws(_ws), ww(_ww), wn(_wn) {
EtageQuad::EtageQuad(Quad _c, Quad _ch, QuadBool _w) : Chose(), c(_c), ch(_ch), w(_w) {
addEntropy(c);
addEntropy(ch);
for (int i = 0; i < 4; i++)
addEntropy(w[N+i] ? 0 : 1);
}
void EtageQuad::getBoundingBoxPoints() {
@ -21,10 +22,10 @@ bool EtageQuad::split() {
Quad mwh = ch.insetOpp(W,28);
Quad mnh = ch.inset(E,28).inset(W,28).insetOpp(N,28);
addChild(new MurQuad(me << 1,meh << 1,we));
addChild(new MurQuad(mw >> 1,mwh >> 1,ww));
addChild(new MurQuad(mn,mnh,wn));
addChild(new MurQuad(ms >> 2,msh >> 2,ws));
addChild(new MurQuad(me << 1,meh << 1,w[E]));
addChild(new MurQuad(mw >> 1,mwh >> 1,w[W]));
addChild(new MurQuad(mn,mnh,w[N]));
addChild(new MurQuad(ms >> 2,msh >> 2,w[S]));
return true;
}

View File

@ -8,10 +8,10 @@ class EtageQuad : public Chose {
private :
Quad c;
Quad ch;
bool we, ws, ww, wn;
QuadBool w;
public :
EtageQuad(Quad c, Quad ch, bool we=true, bool ws=true, bool ww=true, bool wn=true);
EtageQuad(Quad c, Quad ch, QuadBool _w);
virtual bool split();
virtual void triangulation();
virtual void getBoundingBoxPoints();