www

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

commit 831d9e36209d56e875f6be198115917b5c68ba9d
parent 1cdc6d28873dbbc576aa27dc1b320289d238bdaa
Author: Yoann <yoann.b87@voila.fr>
Date:   Wed, 21 Dec 2011 15:10:31 +0100

Suite des maison avec pont, ajout d'une classe pour représenter les
blocks de maison.

Diffstat:
Mall_includes.hh | 1+
Arules/batiment/batimentquadmaisonblock.cpp | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Arules/batiment/batimentquadmaisonblock.hh | 27+++++++++++++++++++++++++++
Mrules/batiment/batimentquadmaisonpont.cpp | 54+++++++++++++++++++++++-------------------------------
Mrules/batiment/batimentquadpont.cpp | 35++++++++++++++++++-----------------
5 files changed, 119 insertions(+), 48 deletions(-)

diff --git a/all_includes.hh b/all_includes.hh @@ -34,6 +34,7 @@ class Chose; #include "rules/batiment/batimentquadjardin.hh" #include "rules/batiment/batimentquadpont.hh" #include "rules/batiment/batimentquadmaisonpont.hh" +#include "rules/batiment/batimentquadmaisonblock.hh" #include "rules/quartier/quartierquad.hh" #include "rules/quartier/quartierquadangle.hh" diff --git a/rules/batiment/batimentquadmaisonblock.cpp b/rules/batiment/batimentquadmaisonblock.cpp @@ -0,0 +1,50 @@ +#include "all_includes.hh" + +BatimentQuadMaisonBlock::BatimentQuadMaisonBlock() { +} + +BatimentQuadMaisonBlock::BatimentQuadMaisonBlock(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) : Chose() { + addEntropy(ne, se, sw, nw); + lctr = Vertex(ne.x-nw.x,se.y-ne.y,0.0f); + this->ne = ne-lctr; + this->se = se-lctr; + this-> sw = sw-lctr; + this->nw = nw-lctr; + this->height = height; + triangulation(); +} + +BatimentQuadMaisonBlock::~BatimentQuadMaisonBlock() { + for(unsigned int i = 0; i < children.size(); i++) + delete(children[i]); + children.clear(); + triangles.clear(); +} + +std::vector<Vertex*> BatimentQuadMaisonBlock::getBoundingBoxPoints() const { + std::vector<Vertex*> list; + return list; +} + +bool BatimentQuadMaisonBlock::split() { + + return true; +} + +bool BatimentQuadMaisonBlock::merge() { + for(unsigned int i = 0; i < children.size(); i++) + delete(children[i]); + children.clear(); + triangles.clear(); + return true; +} + +void BatimentQuadMaisonBlock::triangulation() { + //triangles.reserve(2); + Vertex seh = se + Vertex(0,0,height); + Vertex swh = sw + Vertex(0,0,height); + Vertex nwh = nw + Vertex(0,0,height); + Vertex neh = ne + Vertex(0,0,height); + + addOcto(lctr+se,lctr+sw,lctr+nw,lctr+ne,lctr+seh,lctr+swh,lctr+nwh,lctr+neh,0xFF,0x36,0x00); +} diff --git a/rules/batiment/batimentquadmaisonblock.hh b/rules/batiment/batimentquadmaisonblock.hh @@ -0,0 +1,27 @@ +#ifndef _RULES_BATIMENTMAISONBLOCK_HH_ +#define _RULES_BATIMENTMAISONBLOCK_HH_ + +#include "all_includes.hh" + +// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. +class BatimentQuadMaisonBlock : public Chose { + private : + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; + int height; + + public : + + BatimentQuadMaisonBlock(); + BatimentQuadMaisonBlock(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height); + virtual ~BatimentQuadMaisonBlock(); + virtual bool split(); + virtual bool merge(); + virtual void triangulation(); + Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual std::vector<Vertex*> getBoundingBoxPoints() const; +}; + +#endif diff --git a/rules/batiment/batimentquadmaisonpont.cpp b/rules/batiment/batimentquadmaisonpont.cpp @@ -27,20 +27,6 @@ std::vector<Vertex*> BatimentQuadMaisonPont::getBoundingBoxPoints() const { } bool BatimentQuadMaisonPont::split() { - - return true; -} - -bool BatimentQuadMaisonPont::merge() { - for(unsigned int i = 0; i < children.size(); i++) - delete(children[i]); - children.clear(); - triangles.clear(); - return true; -} - -void BatimentQuadMaisonPont::triangulation() { - //triangles.reserve(2); Quad q = Quad(ne,se,sw,nw); q.makeParallelogram(); if(Segment(q.corner[0],q.corner[3]).length() < Segment(q.corner[0],q.corner[1]).length()) @@ -61,34 +47,40 @@ void BatimentQuadMaisonPont::triangulation() { nw = lctr+qa.corner[2]; ne = lctr+qa.corner[3]; - Vertex seh = se + Vertex(0,0,partHeight); - Vertex swh = sw + Vertex(0,0,partHeight); - Vertex nwh = nw + Vertex(0,0,partHeight); - Vertex neh = ne + Vertex(0,0,partHeight); - - addOcto(ne,se,sw,nw,neh,seh,swh,nwh,0xFF,0x30,0x00); + addChild(new BatimentQuadMaisonBlock(ne,se,sw,nw,partHeight)); se = lctr+qb.corner[0]; sw = lctr+qb.corner[1]; nw = lctr+qb.corner[2]; ne = lctr+qb.corner[3]; - seh = se + Vertex(0,0,partHeight); - swh = sw + Vertex(0,0,partHeight); - nwh = nw + Vertex(0,0,partHeight); - neh = ne + Vertex(0,0,partHeight); - - addOcto(ne,se,sw,nw,neh,seh,swh,nwh,0xFF,0x30,0x00); + addChild(new BatimentQuadMaisonBlock(ne,se,sw,nw,partHeight)); se = lctr+qh.corner[0] + Vertex(0,0,partHeight); sw = lctr+qh.corner[1] + Vertex(0,0,partHeight); nw = lctr+qh.corner[2] + Vertex(0,0,partHeight); ne = lctr+qh.corner[3] + Vertex(0,0,partHeight); - seh = se + Vertex(0,0,partHeight); - swh = sw + Vertex(0,0,partHeight); - nwh = nw + Vertex(0,0,partHeight); - neh = ne + Vertex(0,0,partHeight); + addChild(new BatimentQuadMaisonBlock(ne,se,sw,nw,partHeight)); + + se = lctr+qc.corner[0]; + sw = lctr+qc.corner[1]; + nw = lctr+qc.corner[2]; + ne = lctr+qc.corner[3]; + + addChild(new BatimentQuadPont(se,sw,nw,ne,partHeight)); + return true; +} + +bool BatimentQuadMaisonPont::merge() { + for(unsigned int i = 0; i < children.size(); i++) + delete(children[i]); + children.clear(); + triangles.clear(); + return true; +} + +void BatimentQuadMaisonPont::triangulation() { + //triangles.reserve(2); - addOcto(ne,se,sw,nw,neh,seh,swh,nwh,0xFF,0x30,0x00); } diff --git a/rules/batiment/batimentquadpont.cpp b/rules/batiment/batimentquadpont.cpp @@ -52,12 +52,13 @@ void BatimentQuadPont::triangulation() { float var; Quad q = Quad(ne,se,sw,nw); Vertex a,b; + height -= 20; Vertex pa = nw; Vertex pb = sw; - Vertex neh = ne + Vertex(0,0,height+100); - Vertex seh = se + Vertex(0,0,height+100); - Vertex swh = sw + Vertex(0,0,height+100); - Vertex nwh = nw + Vertex(0,0,height+100); + Vertex neh = ne + Vertex(0,0,height+20); + Vertex seh = se + Vertex(0,0,height+20); + Vertex swh = sw + Vertex(0,0,height+20); + Vertex nwh = nw + Vertex(0,0,height+20); Vertex l1 = ne - nw; Vertex l2 = sw - se; @@ -68,35 +69,35 @@ void BatimentQuadPont::triangulation() { int middle = steps/2; int n; - addTriangle(new Triangle(lctr+pb,lctr+sw,lctr+swh,0x10,0xFF,0x10)); - addTriangle(new Triangle(lctr+pa,lctr+nw,lctr+nwh,0x10,0xFF,0x10)); + addTriangle(new Triangle(lctr+pb,lctr+sw,lctr+swh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+pa,lctr+nw,lctr+nwh,0xD0,0xD0,0xD0)); for(var=-1.7,n=0; var <= 1.7; var+=pas,n++) { q.offset(W,-n2); a = q.corner[3] + Vertex(0,0,nt(var,height)); b = q.corner[2] + Vertex(0,0,nt(var,height)); - addQuad(lctr+a,lctr+b,lctr+pb,lctr+pa,0xEE,0xEE,0xEE); + addQuad(lctr+b,lctr+a,lctr+pa,lctr+pb,0xD0,0xD0,0xD0); if( n < middle) { - addTriangle(new Triangle(lctr+pa,lctr+a,lctr+nwh,0xFF,0x10,0xFF)); - addTriangle(new Triangle(lctr+pb,lctr+b,lctr+swh,0xFF,0x10,0xFF)); + addTriangle(new Triangle(lctr+a,lctr+pa,lctr+nwh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+pb,lctr+b,lctr+swh,0xD0,0xD0,0xD0)); } else if(n == middle) { - addTriangle(new Triangle(lctr+pa,lctr+a,lctr+nwh,0x10,0x10,0xFF)); - addTriangle(new Triangle(lctr+pb,lctr+b,lctr+swh,0x10,0x10,0xFF)); - addTriangle(new Triangle(lctr+a,lctr+neh,lctr+nwh,0x10,0x10,0xFF)); - addTriangle(new Triangle(lctr+b,lctr+seh,lctr+swh,0x10,0x10,0xFF)); + addTriangle(new Triangle(lctr+a,lctr+pa,lctr+nwh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+pb,lctr+b,lctr+swh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+a,lctr+nwh,lctr+neh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+b,lctr+seh,lctr+swh,0xD0,0xD0,0xD0)); } else { - addTriangle(new Triangle(lctr+pa,lctr+a,lctr+neh,0x10,0xFF,0xFF)); - addTriangle(new Triangle(lctr+pb,lctr+b,lctr+seh,0x10,0xFF,0xFF)); + addTriangle(new Triangle(lctr+a,lctr+pa,lctr+neh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+pb,lctr+b,lctr+seh,0xD0,0xD0,0xD0)); } pa = a; pb = b; } - addTriangle(new Triangle(lctr+se,lctr+pb,lctr+seh,0x10,0xFF,0x10)); - addTriangle(new Triangle(lctr+ne,lctr+pa,lctr+neh,0x10,0xFF,0x10)); + addTriangle(new Triangle(lctr+se,lctr+pb,lctr+seh,0xD0,0xD0,0xD0)); + addTriangle(new Triangle(lctr+ne,lctr+pa,lctr+neh,0xD0,0xD0,0xD0)); }