www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit e75e9e5ba46f85256095e0c124ee8591ae045c21
parent 45e89f26493ee79ccff07977716c2c4f1851c2f5
Author: Yoann <yoann.b87@voila.fr>
Date:   Tue, 13 Dec 2011 10:20:15 +0100

Ajout des trottoirs autour des maisons.

Diffstat:
Mall_includes.hh | 5+++++
Mrules/batiment/batimentquad.cpp | 21+++++++++++++--------
Mrules/batiment/batimentquadmaison.cpp | 39+++++++++++++++++++++++++++++++++++++++
Mrules/batiment/batimentquadmaison.hh | 25+++++++++++++++++++++++++
Mrules/route/trottoirquadnormal.cpp | 11++++++++---
5 files changed, 90 insertions(+), 11 deletions(-)

diff --git a/all_includes.hh b/all_includes.hh @@ -26,15 +26,20 @@ class Chose; #include "view.hh" #include "rules/chose.hh" + #include "rules/batiment/batimentquad.hh" +#include "rules/batiment/batimentquadmaison.hh" + #include "rules/quartier/quartierquad.hh" #include "rules/quartier/quartierquadangle.hh" #include "rules/quartier/quartierquadcarre.hh" #include "rules/quartier/quartierquadrect.hh" #include "rules/quartier/quartiertri.hh" + #include "rules/route/routequadcarrefour.hh" #include "rules/route/routequadchaussee.hh" #include "rules/route/trottoirquadnormal.hh" + #include "rules/terrain/terrainquadherbe.hh" #endif diff --git a/rules/batiment/batimentquad.cpp b/rules/batiment/batimentquad.cpp @@ -10,26 +10,31 @@ int BatimentQuad::width() { return this->ne.x - this->sw.x; } int BatimentQuad::height() { return this->ne.y - this->sw.y; } bool BatimentQuad::subdivide() { - + factory(1,1,ne,se,sw,nw); return true; } Chose* BatimentQuad::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw) { - return false; + //return false; Quad q = Quad(ne,se,sw,nw); seed = seed; n = n; - q.offset(N,20); - q.offset(E,20); - q.offset(S,20); - q.offset(W,20); - + q.offset(N,-140); + q.offset(E,-140); + q.offset(S,-140); + q.offset(W,-140); + + addChild(new BatimentQuadMaison(q.corner[0],q.corner[1],q.corner[2],q.corner[3])); + addChild(new TrottoirQuadNormal(q.corner[0],ne,se,q.corner[1],20)); + addChild(new TrottoirQuadNormal(q.corner[1],se,sw,q.corner[2],20)); + addChild(new TrottoirQuadNormal(q.corner[2],sw,nw,q.corner[3],20)); + addChild(new TrottoirQuadNormal(q.corner[3],nw,ne,q.corner[0],20)); return NULL; // pour compilation, à virer. } void BatimentQuad::triangulation() { triangles.reserve(12); - + int h = hashInRange(seed,0,minHeight,maxHeight); int htoit = hashInRange(seed,0,minHeight/2,maxHeight/2); Vertex neh = ne + Vertex(0,0,h); diff --git a/rules/batiment/batimentquadmaison.cpp b/rules/batiment/batimentquadmaison.cpp @@ -0,0 +1,39 @@ +#include "all_includes.hh" + +BatimentQuadMaison::BatimentQuadMaison(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { + addEntropy(ne, se, sw, nw); + triangulation(); +} + +int BatimentQuadMaison::width() { return this->ne.x - this->sw.x; } + +int BatimentQuadMaison::height() { return this->ne.y - this->sw.y; } + +bool BatimentQuadMaison::subdivide() { + + return true; +} + +void BatimentQuadMaison::triangulation() { + triangles.reserve(12); + + int h = hashInRange(seed,0,minHeight,maxHeight); + int htoit = hashInRange(seed,0,minHeight/2,maxHeight/2); + Vertex neh = ne + Vertex(0,0,h); + Vertex seh = se + Vertex(0,0,h); + Vertex nwh = nw + Vertex(0,0,h); + Vertex swh = sw + Vertex(0,0,h); + Vertex toit = (neh + seh + nwh + swh) / 4 + Vertex(0,0,htoit); + + // 4 Murs + addTriangle(new Triangle(neh,seh,ne,0xf1,0xe3,0xad)); addTriangle(new Triangle(seh,se,ne,0xf1,0xe3,0xad)); // ne-se-seh-neh + addTriangle(new Triangle(seh,swh,se,0xf1,0xe3,0xad)); addTriangle(new Triangle(swh,sw,se,0xf1,0xe3,0xad)); // se-sw-swh-seh + addTriangle(new Triangle(swh,nwh,sw,0xf1,0xe3,0xad)); addTriangle(new Triangle(nwh,nw,sw,0xf1,0xe3,0xad)); // sw-nw-nwh-swh + addTriangle(new Triangle(nwh,neh,nw,0xf1,0xe3,0xad)); addTriangle(new Triangle(neh,ne,nw,0xf1,0xe3,0xad)); // nw-ne-neh-nwh + + // 1 Toit + addTriangle(new Triangle(neh,toit,seh,0x9a,0x48,0x3c)); + addTriangle(new Triangle(seh,toit,swh,0x9a,0x48,0x3c)); + addTriangle(new Triangle(swh,toit,nwh,0x9a,0x48,0x3c)); + addTriangle(new Triangle(nwh,toit,neh,0x9a,0x48,0x3c)); +} diff --git a/rules/batiment/batimentquadmaison.hh b/rules/batiment/batimentquadmaison.hh @@ -0,0 +1,25 @@ +#ifndef _RULES_BATIMENTMAISON_HH_ +#define _RULES_BATIMENTMAISON_HH_ + +#include "all_includes.hh" + +// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. +class BatimentQuadMaison : public Chose { +public: + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; +public: + static const int minHeight = 400; + static const int maxHeight = 800; +public: + BatimentQuadMaison(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 diff --git a/rules/route/trottoirquadnormal.cpp b/rules/route/trottoirquadnormal.cpp @@ -17,11 +17,16 @@ bool TrottoirQuadNormal::subdivide() { void TrottoirQuadNormal::triangulation() { addTriangle(new Triangle(ne + Vertex(0,0,height), nw + Vertex(0,0,height) , sw + Vertex(0,0,height), 0x66, 0x66, 0x66)); addTriangle(new Triangle(sw + Vertex(0,0,height), se + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66)); - addTriangle(new Triangle(ne + Vertex(0,0,height), nw + Vertex(0,0,height), sw + Vertex(0,0,height), 0x66, 0x66, 0x66)); - addTriangle(new Triangle(sw + Vertex(0,0,height), se + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66)); - + //addTriangle(new Triangle(ne + Vertex(0,0,height), nw + Vertex(0,0,height), sw + Vertex(0,0,height), 0x66, 0x66, 0x66)); + //addTriangle(new Triangle(sw + Vertex(0,0,height), se + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66)); + addTriangle(new Triangle(nw + Vertex(0,0,height), nw, sw, 0x66, 0x66, 0x66)); addTriangle(new Triangle(sw, sw + Vertex(0,0,height), nw + Vertex(0,0,height), 0x66, 0x66, 0x66)); addTriangle(new Triangle(ne, ne + Vertex(0,0,height), se + Vertex(0,0,height), 0x66, 0x66, 0x66)); addTriangle(new Triangle(se + Vertex(0,0,height), se, ne, 0x66, 0x66, 0x66)); + + addTriangle(new Triangle(ne + Vertex(0,0,height), ne, nw, 0x66, 0x66, 0x66)); + addTriangle(new Triangle(nw, nw + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66)); + addTriangle(new Triangle(sw, sw + Vertex(0,0,height), se + Vertex(0,0,height), 0x66, 0x66, 0x66)); + addTriangle(new Triangle(se + Vertex(0,0,height), se, sw, 0x66, 0x66, 0x66)); }