www

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

commit df0230f1ddb919c84a3eea559a1d7b2c63ef304f
parent e5798610b0fb1eef572f7476ca2159a81ead9c4d
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Mon, 12 Dec 2011 21:22:47 +0100

Renommage de classes.

Diffstat:
MMakefile | 2+-
Mall_includes.hh | 20++++++++++----------
Abugs/open/2011-12-12-2019-todo | 42++++++++++++++++++++++++++++++++++++++++++
Mmain.cpp | 2+-
Drules/batiment/batiment.cpp | 39---------------------------------------
Drules/batiment/batiment.hh | 24------------------------
Arules/batiment/batimentquad.cpp | 39+++++++++++++++++++++++++++++++++++++++
Arules/batiment/batimentquad.hh | 24++++++++++++++++++++++++
Drules/quartier/quadangle.cpp | 56--------------------------------------------------------
Drules/quartier/quadangle.hh | 17-----------------
Drules/quartier/quadcroix.cpp | 27---------------------------
Drules/quartier/quadcroix.hh | 15---------------
Drules/quartier/quadrect.cpp | 19-------------------
Drules/quartier/quadrect.hh | 15---------------
Drules/quartier/quadrilatere.cpp | 44--------------------------------------------
Drules/quartier/quadrilatere.hh | 17-----------------
Arules/quartier/quartierquad.cpp | 44++++++++++++++++++++++++++++++++++++++++++++
Arules/quartier/quartierquad.hh | 17+++++++++++++++++
Arules/quartier/quartierquadangle.cpp | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Arules/quartier/quartierquadangle.hh | 17+++++++++++++++++
Arules/quartier/quartierquadcarre.cpp | 27+++++++++++++++++++++++++++
Arules/quartier/quartierquadcarre.hh | 15+++++++++++++++
Arules/quartier/quartierquadrect.cpp | 19+++++++++++++++++++
Arules/quartier/quartierquadrect.hh | 15+++++++++++++++
Arules/quartier/quartiertri.cpp | 25+++++++++++++++++++++++++
Arules/quartier/quartiertri.hh | 17+++++++++++++++++
Drules/quartier/tiletri.cpp | 45---------------------------------------------
Drules/quartier/tiletri.hh | 17-----------------
Drules/route/carrefour.cpp | 25-------------------------
Drules/route/carrefour.hh | 22----------------------
Drules/route/route.cpp | 38--------------------------------------
Drules/route/route.hh | 21---------------------
Arules/route/routequadcarrefour.cpp | 17+++++++++++++++++
Arules/route/routequadcarrefour.hh | 18++++++++++++++++++
Arules/route/routequadchaussee.cpp | 30++++++++++++++++++++++++++++++
Arules/route/routequadchaussee.hh | 18++++++++++++++++++
Drules/route/trottoir.cpp | 27---------------------------
Drules/route/trottoir.hh | 20--------------------
Arules/route/trottoirquadnormal.cpp | 27+++++++++++++++++++++++++++
Arules/route/trottoirquadnormal.hh | 20++++++++++++++++++++
Drules/terrain/quadherbe.cpp | 15---------------
Drules/terrain/quadherbe.hh | 17-----------------
Arules/terrain/terrainquadherbe.cpp | 29+++++++++++++++++++++++++++++
Arules/terrain/terrainquadherbe.hh | 19+++++++++++++++++++
44 files changed, 547 insertions(+), 532 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,7 +4,7 @@ CCWARN=-Wall -Wextra -Werror # -flto (nécessite GCC 4.5) -m32 ou -m64 CFLAGS=-O0 -I. $(CCWARN) -SOURCES = main.cpp view.cpp hash.cpp vertex.cpp segment.cpp triangle.cpp quad.cpp $(shell echo rules/*/*.cpp) +SOURCES = main.cpp view.cpp hash.cpp vertex.cpp segment.cpp triangle.cpp quad.cpp rules/chose.cpp $(shell echo rules/*/*.cpp) LIBS = -lm -lGL -lGLU -lSDL -lGLEW EXECUTABLE = city diff --git a/all_includes.hh b/all_includes.hh @@ -26,15 +26,15 @@ class Chose; #include "view.hh" #include "rules/chose.hh" -#include "rules/batiment/batiment.hh" -#include "rules/route/carrefour.hh" -#include "rules/route/route.hh" -#include "rules/route/trottoir.hh" -#include "rules/quartier/quadrilatere.hh" -#include "rules/quartier/quadcroix.hh" -#include "rules/quartier/quadrect.hh" -#include "rules/quartier/quadangle.hh" -#include "rules/terrain/quadherbe.hh" -#include "rules/tiletri.hh" +#include "rules/batiment/batimentquad.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/bugs/open/2011-12-12-2019-todo b/bugs/open/2011-12-12-2019-todo @@ -0,0 +1,42 @@ +Rules +===== + +* chose +* batiment + * batimentquad (sorte de factory interne, fait un addChild : trottoirs (chosit le bon type), jardin (choisir le bon type, batimentquadmaison ou batimentquadimmeuble ou …) + * batimentquadmaison + * batimentquadimmeuble + * etagequad (factory, représente un étage d'une maison ou d'un immeuble par ex). + * piecequad (factory, représente une pièce d'un étage) + * ouverturequad (factory, paramètre décide si porte ou fenêtre, génère 2 ou 3 modèles de portes ou fenêtre) + * pareil pour les tri et penta +* mobilier (intérieur et extérieur) + * escalier + * table + * statue + * banc +* quartier + * quartierquad (factory) + * quartierquadangle + * quartierquadcarre + * quartierquadrect + * quartiertri (factory) + * quartiertrihauteur (coupe le triangle selon sa hauteur) + * quartiertriverscarre (coupe un coin du triangle pour en faire un carré) + * quartiertriverspenta (coupe un coin du triangle pour en faire un pentagone) + * quartierpenta (factory) + * quelques motifs quartierpenta* +* route + * routequad (factory, paramètre indique si l'on veut un carrefour ou une chaussee ou …) + * routequadcarrefour + * routequadchaussee + * routequadparking + * trottoirquad (factory, paramètre indique s'il faut un bateau, …) + * trottoirquadnormal + * trottoirquadbas (la partie basse du bateau) + * trottoirquadpente (la pente du bateau) + * trottoirquadbateau (se subdivise en 3 trottoirquad* : pente + bas + pente) + * un motif pour faire une place +* terrain + * terrainquadherbe + * d'autres terrains… diff --git a/main.cpp b/main.cpp @@ -26,7 +26,7 @@ int main() { Vertex se(size, 0, 0); Vertex sw(0, 0, 0); Vertex nw(0, size, 0); - Chose* c = Quadrilatere::factory(Chose::initialSeed, 0, ne, se, sw, nw); + Chose* c = QuartierQuad::factory(Chose::initialSeed, 0, ne, se, sw, nw); // c->subdivide(); recursiveSubdivide(c); diff --git a/rules/batiment/batiment.cpp b/rules/batiment/batiment.cpp @@ -1,39 +0,0 @@ -#include "all_includes.hh" - -Batiment::Batiment(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { - addEntropy(ne, se, sw, nw); - triangulation(); -} - -int Batiment::width() { return this->ne.x - this->sw.x; } - -int Batiment::height() { return this->ne.y - this->sw.y; } - -bool Batiment::subdivide() { - // TODO : rien ? - return false; -} - -void Batiment::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/batiment.hh b/rules/batiment/batiment.hh @@ -1,24 +0,0 @@ -#ifndef _RULES_BATIMENT_HH_ -#define _RULES_BATIMENT_HH_ - -#include "all_includes.hh" - -// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. -class Batiment : public Chose { -public: - Vertex ne; - Vertex se; - Vertex sw; - Vertex nw; -public: - static const int minHeight = 400; - static const int maxHeight = 800; -public: - Batiment(Vertex ne, Vertex se, Vertex sw, Vertex nw); - int width(); - int height(); - virtual bool subdivide(); - virtual void triangulation(); -}; - -#endif diff --git a/rules/batiment/batimentquad.cpp b/rules/batiment/batimentquad.cpp @@ -0,0 +1,39 @@ +#include "all_includes.hh" + +BatimentQuad::BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { + addEntropy(ne, se, sw, nw); + triangulation(); +} + +int BatimentQuad::width() { return this->ne.x - this->sw.x; } + +int BatimentQuad::height() { return this->ne.y - this->sw.y; } + +bool BatimentQuad::subdivide() { + // TODO : rien ? + return false; +} + +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); + 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/batimentquad.hh b/rules/batiment/batimentquad.hh @@ -0,0 +1,24 @@ +#ifndef _RULES_BATIMENT_HH_ +#define _RULES_BATIMENT_HH_ + +#include "all_includes.hh" + +// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. +class BatimentQuad : public Chose { +public: + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; +public: + static const int minHeight = 400; + static const int maxHeight = 800; +public: + BatimentQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw); + int width(); + int height(); + virtual bool subdivide(); + virtual void triangulation(); +}; + +#endif diff --git a/rules/quartier/quadangle.cpp b/rules/quartier/quadangle.cpp @@ -1,56 +0,0 @@ -#include "all_includes.hh" - -QuadAngle::QuadAngle(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Quadrilatere(ne, se, sw, nw) { - triangulation(); -} - -bool QuadAngle::subdivide() { - for (int i = 0; i < 4; i++) { - if (Triangle(corner[NW+i], corner[NE+i], corner[SE+i]).angle() >= Angle::d2r(130)) { - Triangle t1(corner[NE+i], corner[SE+i], corner[SW+i]); - t1.offsetBase(-hrw); - Triangle t2(corner[SW+i], corner[NW+i], corner[NE+i]); - t2.offsetBase(-hrw); - addChild(TileTri::factory(seed, 0, t1.v1, t1.v2, t1.v3)); - addChild(TileTri::factory(seed, 1, t2.v1, t2.v2, t2.v3)); - addChild(new Route(t1.v1, t1.v3, t2.v1, t2.v3)); - addChild(new TileTri(t2.v3, corner[NE+i], t1.v1)); // TODO : new RouteTri - addChild(new TileTri(t1.v3, corner[SW+i], t2.v1)); // TODO : new RouteTri - return true; - } - } - - for (int i = 0; i < 4; i++) { - if (Triangle(corner[NW+i], corner[NE+i], corner[SE+i]).angle() <= Angle::d2r(50)) { - // "couper ce coin". - Vertex n = Segment(corner[NW+i], corner[NE+i]).randomPos(seed, 0, 40, 60); - Vertex e = Segment(corner[NE+i], corner[SE+i]).randomPos(seed, 1, 40, 60); - Triangle tn = Triangle(n, corner[NE+i], corner[SE+i]); - Triangle te = Triangle(corner[NW+i], corner[NE+i], e); - Quad q; - if (tn.minAngle() > te.minAngle()) { - q = Quad(n, corner[SE+i], corner[SW+i], corner[NW+i]); - Vertex oldv3 = tn.v3; - tn.offsetBase(-hrw); - q.offset(E, -hrw); - addChild(TileTri::factory(seed, 0, tn.v1, tn.v2, tn.v3)); - addChild(Quadrilatere::factory(seed, 1, q.corner[0], q.corner[1], q.corner[2], q.corner[3])); - addChild(new Route(tn.v1, tn.v3, q.corner[1], q.corner[0])); - addChild(new TileTri(tn.v3, oldv3, q.corner[1])); // TODO : new RouteTri - } else { - q = Quad(corner[NW+i], e, corner[SE+i], corner[SW+i]); - Vertex oldv1 = te.v1; - te.offsetBase(-hrw); - q.offset(E, -hrw); - addChild(TileTri::factory(seed, 0, te.v1, te.v2, te.v3)); - addChild(Quadrilatere::factory(seed, 1, q.corner[0], q.corner[1], q.corner[2], q.corner[3])); - addChild(new Route(te.v1, te.v3, q.corner[1], q.corner[0])); - addChild(new TileTri(q.corner[0], oldv1, te.v1)); // TODO : new RouteTri - } - return true; - } - } - // Ne devait jamais arriver ici ! - addChild(new QuadHerbe(corner[NE], corner[SE], corner[SW], corner[NW])); - return true; -} diff --git a/rules/quartier/quadangle.hh b/rules/quartier/quadangle.hh @@ -1,17 +0,0 @@ -#ifndef _RULES_QUAD_ANGLE_HH_ -#define _RULES_QUAD_ANGLE_HH_ - -#include "all_includes.hh" - -// QuadAngle est un quadrilatère avec des angles malfichus (< 90-40 ou > 90+40). -class QuadAngle : public Quadrilatere { -private: - static const int hrw = 150; // half road width : 2,50m. -public: - QuadAngle(Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual bool subdivide(); -private: - void cutAngle(); -}; - -#endif diff --git a/rules/quartier/quadcroix.cpp b/rules/quartier/quadcroix.cpp @@ -1,27 +0,0 @@ -#include "all_includes.hh" - -QuadCroix::QuadCroix(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Quadrilatere(ne, se, sw, nw) { -} - -bool QuadCroix::subdivide() { - Vertex middle[4]; - Quad q[4]; - - Vertex cn = Segment(corner[NW], corner[NE]).randomPos(seed, -1, 25, 75); - Vertex cs = Segment(corner[SE], corner[SW]).randomPos(seed, -2, 25, 75); - Vertex c = Segment(cn, cs).randomPos(seed, -3, 25, 75); - - for (int i = 0; i < 4; i++) { - middle[N+i] = Segment(corner[NW+i], corner[NE+i]).randomPos(seed, i, 25, 75); - } - for (int i = 0; i < 4; i++) { - q[i] = Quad(corner[NE+i], middle[E+i], c, middle[N+i]); - q[i].offset(W,-hrw); q[i].offset(S,-hrw); - } - addChild(new Carrefour(q[0].corner[SW], q[1].corner[SW], q[2].corner[SW], q[3].corner[SW])); - for (int i = 0; i < 4; i++) { - addChild(new Route(q[NE+i].corner[NW], q[NE+i].corner[SW], q[NW+i].corner[SW], q[NW+i].corner[SE])); - addChild(Quadrilatere::factory(seed, 4+i, q[i].corner[0], q[i].corner[1], q[i].corner[2], q[i].corner[3])); - } - return true; -} diff --git a/rules/quartier/quadcroix.hh b/rules/quartier/quadcroix.hh @@ -1,15 +0,0 @@ -#ifndef _RULES_QUAD_CROIX_HH_ -#define _RULES_QUAD_CROIX_HH_ - -#include "all_includes.hh" - -// Quad est un quadrilatère -class QuadCroix : public Quadrilatere { -private: - static const int hrw = 250; // half road width : 2,50m. -public: - QuadCroix(Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual bool subdivide(); -}; - -#endif diff --git a/rules/quartier/quadrect.cpp b/rules/quartier/quadrect.cpp @@ -1,19 +0,0 @@ -#include "all_includes.hh" - -QuadRect::QuadRect(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Quadrilatere(ne, se, sw, nw) { -} - -bool QuadRect::subdivide() { - Vertex n = Segment(corner[NW], corner[NE]).randomPos(seed, 0, 33, 67); - Vertex s = Segment(corner[SE], corner[SW]).randomPos(seed, 1, 33, 67); - - Quad qe = Quad(corner[NE], corner[SE], s, n); - Quad qw = Quad(corner[SW], corner[NW], n, s); - qe.offset(W,-hrw); - qw.offset(W,-hrw); - - addChild(new Route(qe.corner[NW], qe.corner[SW], qw.corner[NW], qw.corner[SW])); - addChild(Quadrilatere::factory(seed, 2, qe.corner[0], qe.corner[1], qe.corner[2], qe.corner[3])); - addChild(Quadrilatere::factory(seed, 3, qw.corner[0], qw.corner[1], qw.corner[2], qw.corner[3])); - return true; -} diff --git a/rules/quartier/quadrect.hh b/rules/quartier/quadrect.hh @@ -1,15 +0,0 @@ -#ifndef _RULES_QUAD_RECT_HH_ -#define _RULES_QUAD_RECT_HH_ - -#include "all_includes.hh" - -// Quad est un quadrilatère -class QuadRect : public Quadrilatere { -private: - static const int hrw = 250; // half road width : 2,50m. -public: - QuadRect(Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual bool subdivide(); -}; - -#endif diff --git a/rules/quartier/quadrilatere.cpp b/rules/quartier/quadrilatere.cpp @@ -1,44 +0,0 @@ -#include "all_includes.hh" - -Quadrilatere::Quadrilatere(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose() { - addEntropy(ne, se, sw, nw); - corner[NE] = ne; - corner[SE] = se; - corner[SW] = sw; - corner[NW] = nw; -} - -Chose* Quadrilatere::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw) { - Quad q = Quad(ne,se,sw,nw); - bool small = q.minLength() < 2500; - bool big = q.maxLength() >= 5000; - bool anglesAcceptable = q.minAngle() > Angle::d2r(30) && q.maxAngle() < Angle::d2r(150); - bool anglesOk = q.minAngle() > Angle::d2r(50) && q.maxAngle() < Angle::d2r(130); - bool tooWideX = q.minLengthEW() * 2 < q.maxLengthNS(); // trop allongé (côté E ou W deux fois plus petit que le côté N ou S). - bool tooWideY = q.minLengthNS() * 2 < q.maxLengthEW(); // trop allongé (côté N ou S deux fois plus petit que le côté E ou W). - if (!big && proba(seed, n, 1, 20)) { - return new QuadHerbe(ne, se, sw, nw); - } else if (small && anglesAcceptable) { - return new Batiment(ne, se, sw, nw); - } else if (!small && !anglesOk) { - return new QuadAngle(ne, se, sw, nw); - } else if (!small && tooWideY) { - return new QuadRect(nw, ne, se, sw); - } else if (!small && tooWideX) { - return new QuadRect(ne, se, sw, nw); - } else if (!small) { - return new QuadCroix(ne, se, sw, nw); - } else { - return new QuadHerbe(ne, se, sw, nw); - } -} - -bool Quadrilatere::subdivide() { - return false; -} - -void Quadrilatere::triangulation() { - triangles.reserve(2); - addTriangle(new Triangle(corner[NE], corner[NW], corner[SW], 0xc0, 0xc0, 0xc0)); - addTriangle(new Triangle(corner[SW], corner[SE], corner[NE], 0xc0, 0xc0, 0xc0)); -} diff --git a/rules/quartier/quadrilatere.hh b/rules/quartier/quadrilatere.hh @@ -1,17 +0,0 @@ -#ifndef _RULES_QUADRILATERE_HH_ -#define _RULES_QUADRILATERE_HH_ - -#include "all_includes.hh" - -// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. -class Quadrilatere : public Chose { -public: - Vertex corner[4]; -public: - Quadrilatere(Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual bool subdivide(); - virtual void triangulation(); - static Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); -}; - -#endif diff --git a/rules/quartier/quartierquad.cpp b/rules/quartier/quartierquad.cpp @@ -0,0 +1,44 @@ +#include "all_includes.hh" + +QuartierQuad::QuartierQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose() { + addEntropy(ne, se, sw, nw); + corner[NE] = ne; + corner[SE] = se; + corner[SW] = sw; + corner[NW] = nw; +} + +Chose* QuartierQuad::factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw) { + Quad q = Quad(ne,se,sw,nw); + bool small = q.minLength() < 2500; + bool big = q.maxLength() >= 5000; + bool anglesAcceptable = q.minAngle() > Angle::d2r(90-60) && q.maxAngle() < Angle::d2r(90+60); + bool anglesOk = q.minAngle() > Angle::d2r(90-40) && q.maxAngle() < Angle::d2r(90+40); + bool tooWideX = q.minLengthEW() * 2 < q.maxLengthNS(); // trop allongé (côté E ou W deux fois plus petit que le côté N ou S). + bool tooWideY = q.minLengthNS() * 2 < q.maxLengthEW(); // trop allongé (côté N ou S deux fois plus petit que le côté E ou W). + if (!big && proba(seed, n, 1, 20)) { + return new TerrainQuadHerbe(ne, se, sw, nw); + } else if (small && anglesAcceptable) { + return new BatimentQuad(ne, se, sw, nw); + } else if (!small && !anglesOk) { + return new QuartierQuadAngle(ne, se, sw, nw); + } else if (!small && tooWideY) { + return new QuartierQuadRect(nw, ne, se, sw); + } else if (!small && tooWideX) { + return new QuartierQuadRect(ne, se, sw, nw); + } else if (!small) { + return new QuartierQuadCarre(ne, se, sw, nw); + } else { + return new TerrainQuadHerbe(ne, se, sw, nw); + } +} + +bool QuartierQuad::subdivide() { + return false; +} + +void QuartierQuad::triangulation() { + triangles.reserve(2); + addTriangle(new Triangle(corner[NE], corner[NW], corner[SW], 0xc0, 0xc0, 0xc0)); + addTriangle(new Triangle(corner[SW], corner[SE], corner[NE], 0xc0, 0xc0, 0xc0)); +} diff --git a/rules/quartier/quartierquad.hh b/rules/quartier/quartierquad.hh @@ -0,0 +1,17 @@ +#ifndef _RULES_QUADRILATERE_HH_ +#define _RULES_QUADRILATERE_HH_ + +#include "all_includes.hh" + +// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. +class QuartierQuad : public Chose { +public: + Vertex corner[4]; +public: + QuartierQuad(Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual bool subdivide(); + virtual void triangulation(); + static Chose* factory(int seed, int n, Vertex ne, Vertex se, Vertex sw, Vertex nw); +}; + +#endif diff --git a/rules/quartier/quartierquadangle.cpp b/rules/quartier/quartierquadangle.cpp @@ -0,0 +1,56 @@ +#include "all_includes.hh" + +QuartierQuadAngle::QuartierQuadAngle(Vertex ne, Vertex se, Vertex sw, Vertex nw) : QuartierQuad(ne, se, sw, nw) { + triangulation(); +} + +bool QuartierQuadAngle::subdivide() { + for (int i = 0; i < 4; i++) { + if (Triangle(corner[NW+i], corner[NE+i], corner[SE+i]).angle() >= Angle::d2r(130)) { + Triangle t1(corner[NE+i], corner[SE+i], corner[SW+i]); + t1.offsetBase(-hrw); + Triangle t2(corner[SW+i], corner[NW+i], corner[NE+i]); + t2.offsetBase(-hrw); + addChild(QuartierTri::factory(seed, 0, t1.v1, t1.v2, t1.v3)); + addChild(QuartierTri::factory(seed, 1, t2.v1, t2.v2, t2.v3)); + addChild(new RouteQuadChaussee(t1.v1, t1.v3, t2.v1, t2.v3)); + addChild(new QuartierTri(t2.v3, corner[NE+i], t1.v1)); // TODO : new RouteTri + addChild(new QuartierTri(t1.v3, corner[SW+i], t2.v1)); // TODO : new RouteTri + return true; + } + } + + for (int i = 0; i < 4; i++) { + if (Triangle(corner[NW+i], corner[NE+i], corner[SE+i]).angle() <= Angle::d2r(50)) { + // "couper ce coin". + Vertex n = Segment(corner[NW+i], corner[NE+i]).randomPos(seed, 0, 40, 60); + Vertex e = Segment(corner[NE+i], corner[SE+i]).randomPos(seed, 1, 40, 60); + Triangle tn = Triangle(n, corner[NE+i], corner[SE+i]); + Triangle te = Triangle(corner[NW+i], corner[NE+i], e); + Quad q; + if (tn.minAngle() > te.minAngle()) { + q = Quad(n, corner[SE+i], corner[SW+i], corner[NW+i]); + Vertex oldv3 = tn.v3; + tn.offsetBase(-hrw); + q.offset(E, -hrw); + addChild(QuartierTri::factory(seed, 0, tn.v1, tn.v2, tn.v3)); + addChild(QuartierQuad::factory(seed, 1, q.corner[0], q.corner[1], q.corner[2], q.corner[3])); + addChild(new RouteQuadChaussee(tn.v1, tn.v3, q.corner[1], q.corner[0])); + addChild(new QuartierTri(tn.v3, oldv3, q.corner[1])); // TODO : new RouteTri + } else { + q = Quad(corner[NW+i], e, corner[SE+i], corner[SW+i]); + Vertex oldv1 = te.v1; + te.offsetBase(-hrw); + q.offset(E, -hrw); + addChild(QuartierTri::factory(seed, 0, te.v1, te.v2, te.v3)); + addChild(QuartierQuad::factory(seed, 1, q.corner[0], q.corner[1], q.corner[2], q.corner[3])); + addChild(new RouteQuadChaussee(te.v1, te.v3, q.corner[1], q.corner[0])); + addChild(new QuartierTri(q.corner[0], oldv1, te.v1)); // TODO : new RouteTri + } + return true; + } + } + // Ne devait jamais arriver ici ! + addChild(new TerrainQuadHerbe(corner[NE], corner[SE], corner[SW], corner[NW])); + return true; +} diff --git a/rules/quartier/quartierquadangle.hh b/rules/quartier/quartierquadangle.hh @@ -0,0 +1,17 @@ +#ifndef _RULES_QUAD_ANGLE_HH_ +#define _RULES_QUAD_ANGLE_HH_ + +#include "all_includes.hh" + +// QuadAngle est un quadrilatère avec des angles malfichus (< 90-40 ou > 90+40). +class QuartierQuadAngle : public QuartierQuad { +private: + static const int hrw = 150; // half road width : 2,50m. +public: + QuartierQuadAngle(Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual bool subdivide(); +private: + void cutAngle(); +}; + +#endif diff --git a/rules/quartier/quartierquadcarre.cpp b/rules/quartier/quartierquadcarre.cpp @@ -0,0 +1,27 @@ +#include "all_includes.hh" + +QuartierQuadCarre::QuartierQuadCarre(Vertex ne, Vertex se, Vertex sw, Vertex nw) : QuartierQuad(ne, se, sw, nw) { +} + +bool QuartierQuadCarre::subdivide() { + Vertex middle[4]; + Quad q[4]; + + Vertex cn = Segment(corner[NW], corner[NE]).randomPos(seed, -1, 25, 75); + Vertex cs = Segment(corner[SE], corner[SW]).randomPos(seed, -2, 25, 75); + Vertex c = Segment(cn, cs).randomPos(seed, -3, 25, 75); + + for (int i = 0; i < 4; i++) { + middle[N+i] = Segment(corner[NW+i], corner[NE+i]).randomPos(seed, i, 25, 75); + } + for (int i = 0; i < 4; i++) { + q[i] = Quad(corner[NE+i], middle[E+i], c, middle[N+i]); + q[i].offset(W,-hrw); q[i].offset(S,-hrw); + } + addChild(new RouteQuadCarrefour(q[0].corner[SW], q[1].corner[SW], q[2].corner[SW], q[3].corner[SW])); + for (int i = 0; i < 4; i++) { + addChild(new RouteQuadChaussee(q[NE+i].corner[NW], q[NE+i].corner[SW], q[NW+i].corner[SW], q[NW+i].corner[SE])); + addChild(QuartierQuad::factory(seed, 4+i, q[i].corner[0], q[i].corner[1], q[i].corner[2], q[i].corner[3])); + } + return true; +} diff --git a/rules/quartier/quartierquadcarre.hh b/rules/quartier/quartierquadcarre.hh @@ -0,0 +1,15 @@ +#ifndef _RULES_QUAD_CROIX_HH_ +#define _RULES_QUAD_CROIX_HH_ + +#include "all_includes.hh" + +// Quad est un quadrilatère +class QuartierQuadCarre : public QuartierQuad { +private: + static const int hrw = 250; // half road width : 2,50m. +public: + QuartierQuadCarre(Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual bool subdivide(); +}; + +#endif diff --git a/rules/quartier/quartierquadrect.cpp b/rules/quartier/quartierquadrect.cpp @@ -0,0 +1,19 @@ +#include "all_includes.hh" + +QuartierQuadRect::QuartierQuadRect(Vertex ne, Vertex se, Vertex sw, Vertex nw) : QuartierQuad(ne, se, sw, nw) { +} + +bool QuartierQuadRect::subdivide() { + Vertex n = Segment(corner[NW], corner[NE]).randomPos(seed, 0, 33, 67); + Vertex s = Segment(corner[SE], corner[SW]).randomPos(seed, 1, 33, 67); + + Quad qe = Quad(corner[NE], corner[SE], s, n); + Quad qw = Quad(corner[SW], corner[NW], n, s); + qe.offset(W,-hrw); + qw.offset(W,-hrw); + + addChild(new RouteQuadChaussee(qe.corner[NW], qe.corner[SW], qw.corner[NW], qw.corner[SW])); + addChild(QuartierQuad::factory(seed, 2, qe.corner[0], qe.corner[1], qe.corner[2], qe.corner[3])); + addChild(QuartierQuad::factory(seed, 3, qw.corner[0], qw.corner[1], qw.corner[2], qw.corner[3])); + return true; +} diff --git a/rules/quartier/quartierquadrect.hh b/rules/quartier/quartierquadrect.hh @@ -0,0 +1,15 @@ +#ifndef _RULES_QUAD_RECT_HH_ +#define _RULES_QUAD_RECT_HH_ + +#include "all_includes.hh" + +// Quad est un quadrilatère +class QuartierQuadRect : public QuartierQuad { +private: + static const int hrw = 250; // half road width : 2,50m. +public: + QuartierQuadRect(Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual bool subdivide(); +}; + +#endif diff --git a/rules/quartier/quartiertri.cpp b/rules/quartier/quartiertri.cpp @@ -0,0 +1,25 @@ +#include "all_includes.hh" + +QuartierTri::QuartierTri(Vertex left, Vertex top, Vertex right) : Chose() { + addEntropy(left, top, right); + corner[0] = left; + corner[1] = top; + corner[2] = right; + triangulation(); +} + +Chose* QuartierTri::factory(int seed, int n, Vertex left, Vertex top, Vertex right) { + (void)seed; + (void)n; + // TODO + return new QuartierTri(left, top, right); +} + +bool QuartierTri::subdivide() { + return false; +} + +void QuartierTri::triangulation() { + triangles.reserve(1); + addTriangle(new Triangle(corner[0], corner[1], corner[2], 0xf0, 0xc0, 0xc0)); +} diff --git a/rules/quartier/quartiertri.hh b/rules/quartier/quartiertri.hh @@ -0,0 +1,17 @@ +#ifndef _RULES_TRIANGLE_HH_ +#define _RULES_TRIANGLE_HH_ + +#include "all_includes.hh" + +// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. +class QuartierTri : public Chose { +public: + Vertex corner[3]; +public: + QuartierTri(Vertex left, Vertex top, Vertex right); + virtual bool subdivide(); + virtual void triangulation(); + static Chose* factory(int seed, int n, Vertex left, Vertex top, Vertex right); +}; + +#endif diff --git a/rules/quartier/tiletri.cpp b/rules/quartier/tiletri.cpp @@ -1,45 +0,0 @@ -#include "all_includes.hh" - -TileTri::TileTri(Vertex left, Vertex top, Vertex right) : Chose() { - addEntropy(left, top, right); - corner[0] = left; - corner[1] = top; - corner[2] = right; - triangulation(); -} - -Chose* TileTri::factory(int seed, int n, Vertex left, Vertex top, Vertex right) { - (void)seed; - (void)n; - return new TileTri(left, top, right); - // Quad q = Quad(ne,se,sw,nw); - // bool small = q.minLength() < 2500; - // bool big = q.maxLength() >= 5000; - // bool anglesOk = q.minAngle() > Angle::d2r(50) && q.maxAngle() < Angle::d2r(130); - // bool tooWideX = q.minLengthEW() * 2 < q.maxLengthNS(); // trop allongé (côté E ou W deux fois plus petit que le côté N ou S). - // bool tooWideY = q.minLengthNS() * 2 < q.maxLengthEW(); // trop allongé (côté N ou S deux fois plus petit que le côté E ou W). - // if (!big && proba(seed, n, 1, 20)) { - // return new QuadHerbe(ne, se, sw, nw); - // } else if (small && anglesOk) { - // return new Batiment(ne, se, sw, nw); - // } else if (!anglesOk) { - // return new QuadAngle(ne, se, sw, nw); - // } else if (!small && tooWideY) { - // return new QuadRect(nw, ne, se, sw); - // } else if (!small && tooWideX) { - // return new QuadRect(ne, se, sw, nw); - // } else if (!small) { - // return new QuadCroix(ne, se, sw, nw); - // } else { - // return new QuadHerbe(ne, se, sw, nw); - // } -} - -bool TileTri::subdivide() { - return false; -} - -void TileTri::triangulation() { - triangles.reserve(1); - addTriangle(new Triangle(corner[0], corner[1], corner[2], 0xf0, 0xc0, 0xc0)); -} diff --git a/rules/quartier/tiletri.hh b/rules/quartier/tiletri.hh @@ -1,17 +0,0 @@ -#ifndef _RULES_TRIANGLE_HH_ -#define _RULES_TRIANGLE_HH_ - -#include "all_includes.hh" - -// RectangleRoutes est un quadrilatère de routes avec des angles aux coins égaux à 90°. -class TileTri : public Chose { -public: - Vertex corner[3]; -public: - TileTri(Vertex left, Vertex top, Vertex right); - virtual bool subdivide(); - virtual void triangulation(); - static Chose* factory(int seed, int n, Vertex left, Vertex top, Vertex right); -}; - -#endif diff --git a/rules/route/carrefour.cpp b/rules/route/carrefour.cpp @@ -1,25 +0,0 @@ -#include "all_includes.hh" - -Carrefour::Carrefour(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { - addEntropy(ne,se,sw,nw); - triangulation(); -} - -bool Carrefour::subdivide() { - // TODO - return false; -} - -std::ostream& operator<<(std::ostream& os, const Carrefour* c) { - return os << *c; -} - -std::ostream& operator<<(std::ostream& os, const Carrefour& c) { - return os << "Carrefour " << c.ne << "-" << c.se << "-" << c.sw << "-" << c.nw; -} - -void Carrefour::triangulation() { - triangles.reserve(2); - addTriangle(new Triangle(ne, nw, sw, 0x36, 0x36, 0x36)); - addTriangle(new Triangle(sw, se, ne, 0x36, 0x36, 0x36)); -} diff --git a/rules/route/carrefour.hh b/rules/route/carrefour.hh @@ -1,22 +0,0 @@ -#ifndef _CARREFOUR_ROUTE_HH_ -#define _CARREFOUR_ROUTE_HH_ - -#include "all_includes.hh" - -class Carrefour : public Chose { -public: - Vertex ne; - Vertex se; - Vertex sw; - Vertex nw; -public: - Carrefour(Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual bool subdivide(); - virtual void triangulation(); - // TODO : Carrefour::replacePoint (pour pouvoir transformer un carrefour 4 en carrefour 5 et +). -public: - friend std::ostream& operator<<(std::ostream& os, const Carrefour& c); - friend std::ostream& operator<<(std::ostream& os, const Carrefour* c); -}; - -#endif diff --git a/rules/route/route.cpp b/rules/route/route.cpp @@ -1,38 +0,0 @@ -#include "all_includes.hh" - -Route::Route(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { - triangulation(); -} - -bool Route::subdivide() { - // TODO - return false; -} - -std::ostream& operator<<(std::ostream& os, const Route* r) { - return os << *r; -} - -std::ostream& operator<<(std::ostream& os, const Route& r) { - return os << "Route " << r.ne << "-" << r.se << "-" << r.sw << "-" << r.nw; -} - -void Route::triangulation() { - triangles.reserve(2); - addTriangle(new Triangle(ne, nw, sw, 0x36, 0x36, 0x36)); - addTriangle(new Triangle(sw, se, ne, 0x36, 0x36, 0x36)); -} - -// Version avec trottoirs. -/*void Route::triangulation() { - triangles.reserve(2); - Vertex nne, nnw, nse, nsw; // Nouvel emplacement de la route. - - nnw = nw + ((ne - nw)/6); - nsw = sw + ((se - sw)/6); - nne = ne - ((ne - nw)/6); - nse = se - ((se - sw)/6); - - addChild(new TrottoirRoute(nnw, nsw, sw, nw, 20)); - addChild(new TrottoirRoute(ne, se, nse, nne,20)); -}*/ diff --git a/rules/route/route.hh b/rules/route/route.hh @@ -1,21 +0,0 @@ -#ifndef _RULES_ROUTE_HH_ -#define _RULES_ROUTE_HH_ - -#include "all_includes.hh" - -class Route : public Chose { -public: - Vertex ne; - Vertex se; - Vertex sw; - Vertex nw; -public: - Route(Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual bool subdivide(); - virtual void triangulation(); -public: - friend std::ostream& operator<<(std::ostream& os, const Route& r); - friend std::ostream& operator<<(std::ostream& os, const Route* r); -}; - -#endif diff --git a/rules/route/routequadcarrefour.cpp b/rules/route/routequadcarrefour.cpp @@ -0,0 +1,17 @@ +#include "all_includes.hh" + +RouteQuadCarrefour::RouteQuadCarrefour(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { + addEntropy(ne,se,sw,nw); + triangulation(); +} + +bool RouteQuadCarrefour::subdivide() { + // TODO + return false; +} + +void RouteQuadCarrefour::triangulation() { + triangles.reserve(2); + addTriangle(new Triangle(ne, nw, sw, 0x36, 0x36, 0x36)); + addTriangle(new Triangle(sw, se, ne, 0x36, 0x36, 0x36)); +} diff --git a/rules/route/routequadcarrefour.hh b/rules/route/routequadcarrefour.hh @@ -0,0 +1,18 @@ +#ifndef _CARREFOUR_ROUTE_HH_ +#define _CARREFOUR_ROUTE_HH_ + +#include "all_includes.hh" + +class RouteQuadCarrefour : public Chose { +public: + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; +public: + RouteQuadCarrefour(Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual bool subdivide(); + virtual void triangulation(); +}; + +#endif diff --git a/rules/route/routequadchaussee.cpp b/rules/route/routequadchaussee.cpp @@ -0,0 +1,30 @@ +#include "all_includes.hh" + +RouteQuadChaussee::RouteQuadChaussee(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), ne(ne), se(se), sw(sw), nw(nw) { + triangulation(); +} + +bool RouteQuadChaussee::subdivide() { + // TODO + return false; +} + +void RouteQuadChaussee::triangulation() { + triangles.reserve(2); + addTriangle(new Triangle(ne, nw, sw, 0x36, 0x36, 0x36)); + addTriangle(new Triangle(sw, se, ne, 0x36, 0x36, 0x36)); +} + +// Version avec trottoirs. +/*void RouteQuadChaussee::triangulation() { + triangles.reserve(2); + Vertex nne, nnw, nse, nsw; // Nouvel emplacement de la route. + + nnw = nw + ((ne - nw)/6); + nsw = sw + ((se - sw)/6); + nne = ne - ((ne - nw)/6); + nse = se - ((se - sw)/6); + + addChild(new TrottoirRoute(nnw, nsw, sw, nw, 20)); + addChild(new TrottoirRoute(ne, se, nse, nne,20)); +}*/ diff --git a/rules/route/routequadchaussee.hh b/rules/route/routequadchaussee.hh @@ -0,0 +1,18 @@ +#ifndef _RULES_ROUTE_HH_ +#define _RULES_ROUTE_HH_ + +#include "all_includes.hh" + +class RouteQuadChaussee : public Chose { +public: + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; +public: + RouteQuadChaussee(Vertex ne, Vertex se, Vertex sw, Vertex nw); + virtual bool subdivide(); + virtual void triangulation(); +}; + +#endif diff --git a/rules/route/trottoir.cpp b/rules/route/trottoir.cpp @@ -1,27 +0,0 @@ -#include "all_includes.hh" - -TrottoirRoute::TrottoirRoute(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) { - this->ne = ne; - this->nw = nw; - this->se = se; - this->sw = sw; - this->height = height; - triangulation(); -} - -bool TrottoirRoute::subdivide() { - // TODO - return false; -} - -void TrottoirRoute::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(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)); -} diff --git a/rules/route/trottoir.hh b/rules/route/trottoir.hh @@ -1,20 +0,0 @@ -#ifndef _RULES_TROTTOIRROUTE_HH_ -#define _RULES_TRTTOIRROUTE_HH_ - -#include "all_includes.hh" - -class TrottoirRoute : public Chose { - private : - Vertex ne; - Vertex se; - Vertex sw; - Vertex nw; - int height; - - public : - TrottoirRoute(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height); - virtual bool subdivide(); - virtual void triangulation(); -}; - -#endif diff --git a/rules/route/trottoirquadnormal.cpp b/rules/route/trottoirquadnormal.cpp @@ -0,0 +1,27 @@ +#include "all_includes.hh" + +TrottoirQuadNormal::TrottoirQuadNormal(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) { + this->ne = ne; + this->nw = nw; + this->se = se; + this->sw = sw; + this->height = height; + triangulation(); +} + +bool TrottoirQuadNormal::subdivide() { + // TODO + return false; +} + +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(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)); +} diff --git a/rules/route/trottoirquadnormal.hh b/rules/route/trottoirquadnormal.hh @@ -0,0 +1,20 @@ +#ifndef _RULES_TROTTOIRROUTE_HH_ +#define _RULES_TRTTOIRROUTE_HH_ + +#include "all_includes.hh" + +class TrottoirQuadNormal : public Chose { + private : + Vertex ne; + Vertex se; + Vertex sw; + Vertex nw; + int height; + + public : + TrottoirQuadNormal(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height); + virtual bool subdivide(); + virtual void triangulation(); +}; + +#endif diff --git a/rules/terrain/quadherbe.cpp b/rules/terrain/quadherbe.cpp @@ -1,15 +0,0 @@ -#include "all_includes.hh" - -QuadHerbe::QuadHerbe(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Quadrilatere(ne, se, sw, nw), red(0x11) { - triangulation(); -} - -QuadHerbe::QuadHerbe(int red, Vertex ne, Vertex se, Vertex sw, Vertex nw) : Quadrilatere(ne, se, sw, nw), red(red) { - triangulation(); -} - -void QuadHerbe::triangulation() { - triangles.reserve(2); - addTriangle(new Triangle(corner[NE], corner[NW], corner[SW], red, 0xaa, 0x22)); - addTriangle(new Triangle(corner[SW], corner[SE], corner[NE], red, 0xaa, 0x22)); -} diff --git a/rules/terrain/quadherbe.hh b/rules/terrain/quadherbe.hh @@ -1,17 +0,0 @@ -#ifndef _RULES_QUAD_HERBE_HH_ -#define _RULES_QUAD_HERBE_HH_ - -#include "all_includes.hh" - -// Quad est un quadrilatère -class QuadHerbe : public Quadrilatere { -private: - int red; -public: - QuadHerbe(Vertex ne, Vertex se, Vertex sw, Vertex nw); - QuadHerbe(int red, Vertex ne, Vertex se, Vertex sw, Vertex nw); - virtual void triangulation(); -}; - - -#endif diff --git a/rules/terrain/terrainquadherbe.cpp b/rules/terrain/terrainquadherbe.cpp @@ -0,0 +1,29 @@ +#include "all_includes.hh" + +TerrainQuadHerbe::TerrainQuadHerbe(Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), red(0x11) { + addEntropy(ne, se, sw, nw); + corner[NE] = ne; + corner[SE] = se; + corner[SW] = sw; + corner[NW] = nw; + triangulation(); +} + +TerrainQuadHerbe::TerrainQuadHerbe(int red, Vertex ne, Vertex se, Vertex sw, Vertex nw) : Chose(), red(red) { + addEntropy(ne, se, sw, nw); + corner[NE] = ne; + corner[SE] = se; + corner[SW] = sw; + corner[NW] = nw; + triangulation(); +} + +bool TerrainQuadHerbe::subdivide() { + return false; +} + +void TerrainQuadHerbe::triangulation() { + triangles.reserve(2); + addTriangle(new Triangle(corner[NE], corner[NW], corner[SW], red, 0xaa, 0x22)); + addTriangle(new Triangle(corner[SW], corner[SE], corner[NE], red, 0xaa, 0x22)); +} diff --git a/rules/terrain/terrainquadherbe.hh b/rules/terrain/terrainquadherbe.hh @@ -0,0 +1,19 @@ +#ifndef _RULES_QUAD_HERBE_HH_ +#define _RULES_QUAD_HERBE_HH_ + +#include "all_includes.hh" + +// Quad est un quadrilatère +class TerrainQuadHerbe : public Chose { +private: + Vertex corner[4]; + int red; // DEBUG +public: + TerrainQuadHerbe(Vertex ne, Vertex se, Vertex sw, Vertex nw); + TerrainQuadHerbe(int red, Vertex ne, Vertex se, Vertex sw, Vertex nw); // DEBUG + virtual bool subdivide(); + virtual void triangulation(); +}; + + +#endif