diff --git a/all_includes.hh b/all_includes.hh index bc83d90..f362c65 100644 --- a/all_includes.hh +++ b/all_includes.hh @@ -29,6 +29,7 @@ class Chose; #include "rules/batiment/batimentquad.hh" #include "rules/batiment/batimentquadmaison.hh" +#include "rules/batiment/batimentquadjardin.hh" #include "rules/quartier/quartierquad.hh" #include "rules/quartier/quartierquadangle.hh" diff --git a/rules/batiment/batimentquad.cpp b/rules/batiment/batimentquad.cpp index 60fb599..b095120 100644 --- a/rules/batiment/batimentquad.cpp +++ b/rules/batiment/batimentquad.cpp @@ -15,7 +15,7 @@ bool BatimentQuad::subdivide() { } Chose* BatimentQuad::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw) { - //return false; + int th = 20; // Terrain height. Quad q = Quad(ne,se,sw,nw); seed = seed; n = n; @@ -24,11 +24,24 @@ Chose* BatimentQuad::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, V q.offset(S,-140); q.offset(W,-140); + addChild(new TrottoirQuadNormal(ne,se,q.corner[1],q.corner[0],th,E)); + addChild(new TrottoirQuadNormal(se,sw,q.corner[2],q.corner[1],th,E)); + addChild(new TrottoirQuadNormal(sw,nw,q.corner[3],q.corner[2],th,E)); + addChild(new TrottoirQuadNormal(nw,ne,q.corner[0],q.corner[3],th,E)); + + q.corner[0] = q.corner[0] + Vertex(0,0,th); + q.corner[1] = q.corner[1] + Vertex(0,0,th); + q.corner[2] = q.corner[2] + Vertex(0,0,th); + q.corner[3] = q.corner[3] + Vertex(0,0,th); + + addChild(new BatimentQuadJardin(q.corner[0],q.corner[1],q.corner[2],q.corner[3])); + + q.offset(N,-100); + q.offset(E,-100); + q.offset(S,-400); + q.offset(W,-100); + addChild(new BatimentQuadMaison(q.corner[0],q.corner[1],q.corner[2],q.corner[3])); - addChild(new TrottoirQuadNormal(ne,se,q.corner[1],q.corner[0],20,E)); - addChild(new TrottoirQuadNormal(se,sw,q.corner[2],q.corner[1],20,E)); - addChild(new TrottoirQuadNormal(sw,nw,q.corner[3],q.corner[2],20,E)); - addChild(new TrottoirQuadNormal(nw,ne,q.corner[0],q.corner[3],20,E)); return NULL; // pour compilation, à virer. } diff --git a/rules/batiment/batimentquadjardin.cpp b/rules/batiment/batimentquadjardin.cpp index e69de29..cfaf14a 100644 --- a/rules/batiment/batimentquadjardin.cpp +++ b/rules/batiment/batimentquadjardin.cpp @@ -0,0 +1,22 @@ +#include "all_includes.hh" + +BatimentQuadJardin::BatimentQuadJardin(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { + addEntropy(ne, se, sw, nw); + triangulation(); +} + +int BatimentQuadJardin::width() { return this->ne.x - this->sw.x; } + +int BatimentQuadJardin::height() { return this->ne.y - this->sw.y; } + +bool BatimentQuadJardin::subdivide() { + + return true; +} + +void BatimentQuadJardin::triangulation() { + triangles.reserve(2); + + addTriangle(new Triangle(ne,nw,sw,0x12,0x64,0x12)); + addTriangle(new Triangle(sw,se,ne,0x10,0x60,0x10)); +} diff --git a/rules/batiment/batimentquadjardin.hh b/rules/batiment/batimentquadjardin.hh index e69de29..b1a5440 100644 --- a/rules/batiment/batimentquadjardin.hh +++ b/rules/batiment/batimentquadjardin.hh @@ -0,0 +1,25 @@ +#ifndef _RULES_BATIMENTJARDIN_HH +#define _RULES_BATIMENTJARDIN_HH + +#include "all_includes.hh" + +// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. +class BatimentQuadJardin : public Chose { +public: + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; +public: + static const int minHeight = 400; + static const int maxHeight = 800; +public: + BatimentQuadJardin(Vertex ne, Vertex se, Vertex sw, Vertex nw); + int width(); + int height(); + virtual bool subdivide(); + virtual void triangulation(); + Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); +}; + +#endif