www

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

commit 9b31b112a598ab9cda4158a603779d55707b0dea
parent 80aa4e35d56fdb412f44efef87319633762a0663
Author: Yoann <yoann.b87@voila.fr>
Date:   Wed, 30 Nov 2011 19:56:36 +0100

Merge branch 'master' of https://github.com/jsmaniac/2011-m2s3-city-builder

Diffstat:
Mrules/batiment.cpp | 42++++++++++++++----------------------------
Mrules/batiment.hh | 7+++----
Mrules/rectangleroutes.cpp | 2+-
3 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/rules/batiment.cpp b/rules/batiment.cpp @@ -1,6 +1,6 @@ #include "all_includes.hh" -Batiment::Batiment(Vertex ne, Vertex sw) : Chose(), ne(ne), sw(sw) { +Batiment::Batiment(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { addEntropy(ne, sw); triangulation(); } @@ -17,36 +17,22 @@ bool Batiment::subdivide() { void Batiment::triangulation() { triangles.reserve(12); - // abcd sont les quatre coins du bâtiment. - Vertex a = this->ne; - Vertex b = Vertex(this->ne.x, this->sw.y, 0); - Vertex c = Vertex(this->sw.x, this->ne.y, 0); - Vertex d = this->sw; - int h = hashInRange(seed,0,4,8); - Vertex ah = a + Vertex(0,0,h); - Vertex bh = b + Vertex(0,0,h); - Vertex ch = c + Vertex(0,0,h); - Vertex dh = d + Vertex(0,0,h); - Vertex toit = (ah + bh + ch + dh) / 4 + Vertex(0,0,h/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,h/2); // 4 Murs - addTriangle(new Triangle(ah,bh,a,0xf1,0xe3,0xad)); addTriangle(new Triangle(bh,b,a,0xf1,0xe3,0xad)); // a-b-bh-ah - addTriangle(new Triangle(bh,dh,b,0xf1,0xe3,0xad)); addTriangle(new Triangle(dh,d,b,0xf1,0xe3,0xad)); // b-d-dh-bh - addTriangle(new Triangle(dh,ch,d,0xf1,0xe3,0xad)); addTriangle(new Triangle(ch,c,d,0xf1,0xe3,0xad)); // d-c-ch-dh - addTriangle(new Triangle(ch,ah,c,0xf1,0xe3,0xad)); addTriangle(new Triangle(ah,a,c,0xf1,0xe3,0xad)); // c-a-ah-ch + 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(ah,toit,bh,0x8a,0x48,0x3c)); - addTriangle(new Triangle(bh,toit,dh,0x8a,0x48,0x3c)); - addTriangle(new Triangle(dh,toit,ch,0x8a,0x48,0x3c)); - addTriangle(new Triangle(ch,toit,ah,0x8a,0x48,0x3c)); -} - -std::ostream& operator<<(std::ostream& os, const Batiment* r) { - return os << *r; -} - -std::ostream& operator<<(std::ostream& os, const Batiment& r) { - return os << "Batiment " << r.ne << "-" << r.sw; + addTriangle(new Triangle(neh,toit,seh,0x8a,0x48,0x3c)); + addTriangle(new Triangle(seh,toit,swh,0x8a,0x48,0x3c)); + addTriangle(new Triangle(swh,toit,nwh,0x8a,0x48,0x3c)); + addTriangle(new Triangle(nwh,toit,neh,0x8a,0x48,0x3c)); } diff --git a/rules/batiment.hh b/rules/batiment.hh @@ -7,16 +7,15 @@ class Batiment : public Chose { public: Vertex ne; + Vertex se; Vertex sw; + Vertex nw; public: - Batiment(Vertex ne, Vertex sw); + Batiment(Vertex ne, Vertex se, Vertex sw, Vertex nw); int width(); int height(); virtual bool subdivide(); virtual void triangulation(); }; -std::ostream& operator<<(std::ostream& os, const Batiment& r); -std::ostream& operator<<(std::ostream& os, const Batiment* r); - #endif diff --git a/rules/rectangleroutes.cpp b/rules/rectangleroutes.cpp @@ -56,7 +56,7 @@ void RectangleRoutes::triangulation() { Chose* RectangleRoutes::sub(Vertex ne, Vertex sw) { Segment rect = Segment(ne,sw); if (rect.width() < 10 || rect.height() < 10) { - return new Batiment(ne, sw); + return new Batiment(ne, Vertex(ne.x, sw.y, 0), sw, Vertex(sw.x, ne.y, 0)); } else { return new RectangleRoutes(ne, sw); }