Ajout de la fonction de split sur les maison avec la division en block.

Rectification de la division des blocks en mors.
Amélioration des toits.
This commit is contained in:
Yoann 2012-01-10 15:32:25 +01:00
parent 62197c4e2b
commit 474ab3e706
10 changed files with 59 additions and 34 deletions

View File

@ -36,5 +36,5 @@ void BatimentQuad::triangulation() {
float h = floatInRange(seed,1,minHeight,maxHeight); float h = floatInRange(seed,1,minHeight,maxHeight);
float htoit = floatInRange(seed,2,minHeight/2,maxHeight/2); float htoit = floatInRange(seed,2,minHeight/2,maxHeight/2);
addGPUOcto(c, c + Vertex(0,0,h + htoit), 0xFF, 0xFF, 0x00); addGPUOcto(c, c + Vertex(0,0,h + htoit), 0xFF, 0xFF, 0xFF);
} }

View File

@ -1,27 +1,32 @@
#include "all_includes.hh" #include "all_includes.hh"
BatimentQuadBlock::BatimentQuadBlock(Quad _c, float _height) : Chose(), c(_c), height(_height) { BatimentQuadBlock::BatimentQuadBlock(Quad _c, Quad _ch) : Chose(), c(_c), ch(_ch) {
addEntropy(c); addEntropy(c);
addEntropy(ch);
} }
void BatimentQuadBlock::getBoundingBoxPoints() { void BatimentQuadBlock::getBoundingBoxPoints() {
addBBPoints(c); addBBPoints(c);
addBBPoints(c + Vertex(0,0,height)); // TODO addBBPoints(ch);
} }
bool BatimentQuadBlock::split() { bool BatimentQuadBlock::split() {
Quad me = c.insetOpp(E,28); Quad me = c.insetOpp(E,28);
Quad ms = c.inset(E,-28).inset(W,-28).insetOpp(S,28); Quad ms = c.inset(E,28).inset(W,28).insetOpp(S,28);
Quad mw = c.insetOpp(W,28); Quad mw = c.insetOpp(W,28);
Quad mn = c.inset(E,-28).inset(W,-28).insetOpp(N,28); Quad mn = c.inset(E,28).inset(W,28).insetOpp(N,28);
Quad meh = ch.insetOpp(E,28);
Quad msh = ch.inset(E,28).inset(W,28).insetOpp(S,28);
Quad mwh = ch.insetOpp(W,28);
Quad mnh = ch.inset(E,28).inset(W,28).insetOpp(N,28);
addChild(new BatimentQuadMur(me,height)); addChild(new BatimentQuadMur(me,meh));
addChild(new BatimentQuadMur(mw,height)); addChild(new BatimentQuadMur(mw,mwh));
addChild(new BatimentQuadMur(mn,height)); addChild(new BatimentQuadMur(mn,mnh));
addChild(new BatimentQuadMur(ms,height)); addChild(new BatimentQuadMur(ms,msh));
return true; return true;
} }
void BatimentQuadBlock::triangulation() { void BatimentQuadBlock::triangulation() {
addGPUOcto(c, c + Vertex(0,0,height), 0xF1, 0xE0, 0xE0); addGPUOcto(c,ch, 0xF1, 0xE0, 0xE0);
} }

View File

@ -7,10 +7,10 @@
class BatimentQuadBlock : public Chose { class BatimentQuadBlock : public Chose {
private : private :
Quad c; Quad c;
float height; Quad ch;
public : public :
BatimentQuadBlock(Quad c, float height); BatimentQuadBlock(Quad c, Quad ch);
virtual bool split(); virtual bool split();
virtual void triangulation(); virtual void triangulation();
virtual void getBoundingBoxPoints(); virtual void getBoundingBoxPoints();

View File

@ -9,6 +9,17 @@ void BatimentQuadMaison::getBoundingBoxPoints() {
addBBPoints(c + Vertex(0,0,maxHeight + maxHeight/2)); // TODO addBBPoints(c + Vertex(0,0,maxHeight + maxHeight/2)); // TODO
} }
bool BatimentQuadMaison::split() {
float h = floatInRange(seed,0,minHeight,maxHeight);
float htoit = floatInRange(seed,0,minHeight/2,maxHeight/2);
Quad ch = c + Vertex(0,0,h);
Vertex toit = (ch[NE] + ch[SE] + ch[SW] + ch[NW]) / 4 + Vertex(0,0,htoit);
addChild(new BatimentQuadBlock(c,ch));
addChild(new BatimentQuadToit(ch,1));
return true;
}
void BatimentQuadMaison::triangulation() { void BatimentQuadMaison::triangulation() {
triangles.reserve(12); triangles.reserve(12);
@ -17,10 +28,9 @@ void BatimentQuadMaison::triangulation() {
Quad ch = c + Vertex(0,0,h); Quad ch = c + Vertex(0,0,h);
Vertex toit = (ch[NE] + ch[SE] + ch[SW] + ch[NW]) / 4 + Vertex(0,0,htoit); Vertex toit = (ch[NE] + ch[SE] + ch[SW] + ch[NW]) / 4 + Vertex(0,0,htoit);
addGPUOcto(c,ch,0xf1,0xe3,0xad);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
// Mur
addGPUQuad(c[NE+i],c[SE+i],ch[SE+i],ch[NE+i],0xf1,0xe3,0xad);
// Pan du toit
addGPUTriangle(ch[SE+i],toit,ch[NE+i],0x96,0x16,0x18); addGPUTriangle(ch[SE+i],toit,ch[NE+i],0x96,0x16,0x18);
} }
} }

View File

@ -14,6 +14,7 @@ class BatimentQuadMaison : public Chose {
BatimentQuadMaison(Quad c); BatimentQuadMaison(Quad c);
virtual void triangulation(); virtual void triangulation();
virtual bool split();
virtual void getBoundingBoxPoints(); virtual void getBoundingBoxPoints();
}; };

View File

@ -21,11 +21,11 @@ bool BatimentQuadMaisonPont::split() {
Quad qh = q; Quad qh = q;
addChild(new BatimentQuadJardin(c)); addChild(new BatimentQuadJardin(c));
addChild(new BatimentQuadBlock(qa,partHeight)); addChild(new BatimentQuadBlock(qa,qa + Vertex(0,0,partHeight)));
addChild(new BatimentQuadBlock(qb,partHeight)); addChild(new BatimentQuadBlock(qb,qb + Vertex(0,0,partHeight)));
addChild(new BatimentQuadBlock((qh + Vertex(0,0,partHeight)),partHeight)); addChild(new BatimentQuadBlock((qh + Vertex(0,0,partHeight)),qh + Vertex(0,0,2*partHeight)));
addChild(new BatimentQuadPont(qc,partHeight)); addChild(new BatimentQuadPont(qc,partHeight));
addChild(new BatimentQuadToit(qh + Vertex(0,0,2*partHeight),150)); addChild(new BatimentQuadToit(qh + Vertex(0,0,2*partHeight),160));
return true; return true;
} }

View File

@ -1,13 +1,14 @@
#include "all_includes.hh" #include "all_includes.hh"
BatimentQuadMur::BatimentQuadMur(Quad _c, float _height) : Chose(), c(_c), height(_height) { BatimentQuadMur::BatimentQuadMur(Quad _c, Quad _ch) : Chose(), c(_c), ch(_ch) {
addEntropy(c); addEntropy(c);
addEntropy(ch);
this->window = false; this->window = false;
} }
void BatimentQuadMur::getBoundingBoxPoints() { void BatimentQuadMur::getBoundingBoxPoints() {
addBBPoints(c); addBBPoints(c);
addBBPoints(c + Vertex(0,0,height)); addBBPoints(ch);
} }
void BatimentQuadMur::setWindow(Quad w) { void BatimentQuadMur::setWindow(Quad w) {
@ -24,11 +25,11 @@ bool BatimentQuadMur::split() {
Quad top = c; Quad top = c;
Quad bottom = c; Quad bottom = c;
//addChild(BatimentQuadMur())
return true; return false;
} }
void BatimentQuadMur::triangulation() { void BatimentQuadMur::triangulation() {
//addGPUOcto(c, c + Vertex(0,0,height), 0xF1, 0xE0, 0xE0); addGPUOcto(c, ch, 0xf1,0xe3,0xad);
addGPUOcto(c, c + Vertex(0,0,height), 0x60, 0x60, 0xFF);
} }

View File

@ -6,13 +6,13 @@
class BatimentQuadMur: public Chose { class BatimentQuadMur: public Chose {
private : private :
Quad c; Quad c;
float height; Quad ch;
bool window; // Contient une fenêtre ou non. bool window; // Contient une fenêtre ou non.
Quad windowPos; Quad windowPos;
public : public :
BatimentQuadMur(Quad c, float height); BatimentQuadMur(Quad c, Quad ch);
virtual void triangulation(); virtual void triangulation();
virtual bool split(); virtual bool split();
virtual void getBoundingBoxPoints(); virtual void getBoundingBoxPoints();

View File

@ -1,6 +1,6 @@
#include "all_includes.hh" #include "all_includes.hh"
BatimentQuadToit::BatimentQuadToit(Quad _c, float _height) : Chose(), c(_c), height(_height) { BatimentQuadToit::BatimentQuadToit(Quad _c, int _type) : Chose(), c(_c), type(_type) {
addEntropy(c); addEntropy(c);
} }
@ -10,12 +10,19 @@ void BatimentQuadToit::getBoundingBoxPoints() {
} }
void BatimentQuadToit::triangulation() { void BatimentQuadToit::triangulation() {
Vertex ce = c[SE] + (c[NE] - c[SE])/2 + Vertex(0,0,height / 3.f); if(type == 1) {
Vertex cw = c[SW] + (c[NW] - c[SW])/2 + Vertex(0,0,height / 3.f); if(c.minLengthNS() < c.minLengthEW())
c = c << 1;
c = c.inset(S, -20).inset(S,-20);
height = c.minLengthEW() / 5;
Vertex ce = c[SE] + (c[NE] - c[SE])/2 + Vertex(0,0,height);
Vertex cw = c[SW] + (c[NW] - c[SW])/2 + Vertex(0,0,height);
addGPUTriangle(c[NW],cw,c[SW],0xF1,0xE0,0xE0); addGPUTriangle(c[NW],cw,c[SW],0xF1,0xE0,0xE0);
addGPUTriangle(c[SE],ce,c[NE],0xF1,0xE0,0xE0); addGPUTriangle(c[SE],ce,c[NE],0xF1,0xE0,0xE0);
addGPUQuad(c[NE],c[NW],cw,ce,0xE0,0x20,0x00); addGPUQuad(c,0xF1,0xE0,0xE0);
addGPUQuad(c[SW],c[SE],ce,cw,0xE0,0x20,0x00); addGPUQuad(c[NE],c[NW],cw,ce,0xE0,0x20,0x00);
addGPUQuad(c[SW],c[SE],ce,cw,0xE0,0x20,0x00);
}
} }

View File

@ -8,10 +8,11 @@ class BatimentQuadToit: public Chose {
private : private :
Quad c; Quad c;
float height; float height;
int type;
public : public :
BatimentQuadToit(Quad c, float height); BatimentQuadToit(Quad c, int type);
virtual void triangulation(); virtual void triangulation();
virtual void getBoundingBoxPoints(); virtual void getBoundingBoxPoints();
}; };