2011-m2s3-city-builder/rules/batiment/batimentquadmaison.cpp
Georges Dupéron c87e38b4bb Corrections.
2012-01-13 16:01:03 +01:00

37 lines
1018 B
C++

#include "all_includes.hh"
BatimentQuadMaison::BatimentQuadMaison(Quad _c) : Chose(), c(_c) {
addEntropy(c);
}
void BatimentQuadMaison::getBoundingBoxPoints() {
addBBPoints(c);
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() {
triangles.reserve(12);
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);
addGPUOcto(c,ch,Couleurs::mur);
for (int i = 0; i < 4; i++) {
addGPUTriangle(ch[SE+i],toit,ch[NE+i],0x961618);
}
}