www

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

commit f7d889008a59cbe4a8860974bb9a229831853847
parent 419db20c4a118d93bbfcf305056acc1ccf44dfcf
Author: Yoann <yoann.b87@voila.fr>
Date:   Sun, 18 Dec 2011 19:08:36 +0100

Ajout de l'attribut lctr (local center) qui permet d'avoir un repère
local à l'objet.

Diffstat:
Mrules/batiment/batimentquad.cpp | 23++++++++++++-----------
Mrules/chose.hh | 1+
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/rules/batiment/batimentquad.cpp b/rules/batiment/batimentquad.cpp @@ -2,12 +2,13 @@ BatimentQuad::BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw, Cardinal entry) : Chose(), ne(ne) { addEntropy(ne, se, sw, nw); - this->ne = ne; - this->se = se; - this-> sw = sw; - this->nw = nw; this->entry = entry; - triangulation(); + 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; + triangulation(); } BatimentQuad::~BatimentQuad() { @@ -48,21 +49,21 @@ 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)); + addChild(new TrottoirQuadNormal(lctr+ne,lctr+se,lctr+q.corner[1],lctr+q.corner[0],th,E)); + addChild(new TrottoirQuadNormal(lctr+se,lctr+sw,lctr+q.corner[2],lctr+q.corner[1],th,E)); + addChild(new TrottoirQuadNormal(lctr+sw,lctr+nw,lctr+q.corner[3],lctr+q.corner[2],th,E)); + addChild(new TrottoirQuadNormal(lctr+nw,lctr+ne,lctr+q.corner[0],lctr+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])); + addChild(new BatimentQuadJardin(lctr+q.corner[0],lctr+q.corner[1],lctr+q.corner[2],lctr+q.corner[3])); q.offset(this->entry,-400); - addChild(new BatimentQuadMaison(q.corner[0],q.corner[1],q.corner[2],q.corner[3])); + addChild(new BatimentQuadMaison(lctr+q.corner[0],lctr+q.corner[1],lctr+q.corner[2],lctr+q.corner[3])); return NULL; // pour compilation, à virer. } diff --git a/rules/chose.hh b/rules/chose.hh @@ -13,6 +13,7 @@ class Chose { int inCounter; int splitCube[6]; int mergeCube[6]; + Vertex lctr; // Local center; public : void display();