Refactor.
This commit is contained in:
parent
8044fbc971
commit
46f1cf4e43
4
Makefile
4
Makefile
|
@ -6,8 +6,8 @@ CCWARN=-Wall -Wextra -Werror
|
|||
# -g -rdynamic uniquement pour le debug.
|
||||
CFLAGS=-O0 -g -rdynamic -I. $(CCWARN)
|
||||
|
||||
SOURCES = $(shell echo *.cpp geometry/*.cpp rules/*.cpp rules/*/*.cpp)
|
||||
HEADERS = $(shell echo *.hh geometry/*.hh rules/*.hh rules/*/*.hh)
|
||||
SOURCES = $(shell echo *.cpp geometry/*.cpp rules/*.cpp)
|
||||
HEADERS = $(shell echo *.hh geometry/*.hh rules/*.hh)
|
||||
LIBS = -lm -lGL -lGLU -lSDL -lGLEW
|
||||
EXECUTABLE = city
|
||||
|
||||
|
|
|
@ -36,27 +36,16 @@ class Chose;
|
|||
#include "view.hh"
|
||||
|
||||
#include "rules/chose.hh"
|
||||
#include "rules/architecture/couleursDimensions.hh"
|
||||
#include "rules/couleursDimensions.hh"
|
||||
|
||||
#include "rules/architecture/arbre.hh"
|
||||
#include "rules/architecture/arche.hh"
|
||||
#include "rules/architecture/batiment.hh"
|
||||
#include "rules/architecture/quartier.hh"
|
||||
#include "rules/architecture/routetrottoir.hh"
|
||||
#include "rules/architecture/terrain.hh"
|
||||
#include "rules/architecture/toit.hh"
|
||||
#include "rules/architecture/etage.hh"
|
||||
#include "rules/architecture/mur.hh"
|
||||
|
||||
#include "rules/batiment/batimentquad.hh"
|
||||
#include "rules/batiment/batimentquadmaison.hh"
|
||||
#include "rules/batiment/batimentquadjardin.hh"
|
||||
#include "rules/batiment/batimentquadpont.hh"
|
||||
#include "rules/batiment/batimentquadmaisonpont.hh"
|
||||
#include "rules/batiment/batimentquadblock.hh"
|
||||
#include "rules/batiment/batimentquadtoit.hh"
|
||||
#include "rules/batiment/batimenttri.hh"
|
||||
#include "rules/batiment/batimentquadmur.hh"
|
||||
#include "rules/batiment/batimentquadfenetre.hh"
|
||||
#include "rules/arbre.hh"
|
||||
#include "rules/arche.hh"
|
||||
#include "rules/batiment.hh"
|
||||
#include "rules/quartier.hh"
|
||||
#include "rules/routetrottoir.hh"
|
||||
#include "rules/terrain.hh"
|
||||
#include "rules/toit.hh"
|
||||
#include "rules/etage.hh"
|
||||
#include "rules/mur.hh"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_ARBRE_HH_
|
||||
#define _RULES_ARCHITECTURE_ARBRE_HH_
|
||||
#ifndef _RULES_ARBRE_HH_
|
||||
#define _RULES_ARBRE_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_ARCHE_HH_
|
||||
#define _RULES_ARCHITECTURE_ARCHE_HH_
|
||||
#ifndef _RULES_ARCHE_HH_
|
||||
#define _RULES_ARCHE_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_BATIMENT_HH_
|
||||
#define _RULES_ARCHITECTURE_BATIMENT_HH_
|
||||
#ifndef _RULES_BATIMENT_HH_
|
||||
#define _RULES_BATIMENT_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuad::BatimentQuad(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentQuad::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,maxHeight + maxHeight/2)); // TODO
|
||||
}
|
||||
|
||||
bool BatimentQuad::split() {
|
||||
if(proba(seed, 0, 0.1f)) {
|
||||
addChild(new BatimentQuadMaisonPont(c,3));
|
||||
} else {
|
||||
addChild(new BatimentQuadJardin(c));
|
||||
|
||||
addChild(new BatimentQuadMaison(c.inset(N,400)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BatimentQuad::triangulation() {
|
||||
triangles.reserve(12);
|
||||
|
||||
float h = floatInRange(seed,1,minHeight,maxHeight);
|
||||
float htoit = floatInRange(seed,2,minHeight/2,maxHeight/2);
|
||||
|
||||
addGPUOcto(c, c + Vertex(0,0,h + htoit), 0xFFFFFF);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUAD_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUAD_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentQuad : public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
|
||||
public :
|
||||
static const int minHeight = 400;
|
||||
static const int maxHeight = 800;
|
||||
|
||||
BatimentQuad(Quad c);
|
||||
virtual bool split();
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,40 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadBlock::BatimentQuadBlock(Quad _c, Quad _ch) : Chose(), c(_c), ch(_ch) {
|
||||
addEntropy(c);
|
||||
addEntropy(ch);
|
||||
}
|
||||
|
||||
void BatimentQuadBlock::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(ch);
|
||||
}
|
||||
|
||||
bool BatimentQuadBlock::split() {
|
||||
Quad me = c.insetOpp(E,28);
|
||||
Quad ms = c.inset(E,28).inset(W,28).insetOpp(S,28);
|
||||
Quad mw = c.insetOpp(W,28);
|
||||
Quad mn = c.inset(E,28).inset(W,28).insetOpp(N,28);
|
||||
Quad meh = ch.insetOpp(E,28);
|
||||
Quad msh = ch.inset(E,28).inset(W,28).insetOpp(S,28);
|
||||
Quad mwh = ch.insetOpp(W,28);
|
||||
Quad mnh = ch.inset(E,28).inset(W,28).insetOpp(N,28);
|
||||
|
||||
BatimentQuadMur *mme = new BatimentQuadMur(me,meh);
|
||||
BatimentQuadMur *mmn = new BatimentQuadMur(mn,mnh);
|
||||
BatimentQuadMur *mmw = new BatimentQuadMur(mw,mwh);
|
||||
BatimentQuadMur *mms = new BatimentQuadMur(ms,msh);
|
||||
mme->setWindow(true);
|
||||
//mmn->setWindow(true);
|
||||
mmw->setWindow(true);
|
||||
mms->setWindow(true);
|
||||
addChild(mme);
|
||||
addChild(mmw);
|
||||
addChild(mmn);
|
||||
addChild(mms);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BatimentQuadBlock::triangulation() {
|
||||
addGPUOcto(c,ch, 0xF1E0E0);
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADBLOCK_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADBLOCK_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentQuadBlock : public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
Quad ch;
|
||||
|
||||
public :
|
||||
BatimentQuadBlock(Quad c, Quad ch);
|
||||
virtual bool split();
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadFenetre::BatimentQuadFenetre(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentQuadFenetre::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,height));
|
||||
}
|
||||
|
||||
void BatimentQuadFenetre::triangulation() {
|
||||
// Vide laisse un trou à la place de la fenêtre.
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADFENETRE_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADFENETRE_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
class BatimentQuadFenetre: public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
float height;
|
||||
|
||||
public :
|
||||
|
||||
BatimentQuadFenetre(Quad c, float height);
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadJardin::BatimentQuadJardin(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentQuadJardin::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,200)); // TODO
|
||||
}
|
||||
|
||||
void BatimentQuadJardin::triangulation() {
|
||||
triangles.reserve(2);
|
||||
|
||||
addGPUQuad(c, 0x126412);
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADJARDIN_HH
|
||||
#define _RULES_BATIMENT_BATIMENTQUADJARDIN_HH
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentQuadJardin : public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
|
||||
public :
|
||||
static const int minHeight = 400;
|
||||
static const int maxHeight = 800;
|
||||
|
||||
BatimentQuadJardin(Quad c);
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadMaison::BatimentQuadMaison(Quad _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentQuadMaison::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,maxHeight + maxHeight/2)); // TODO
|
||||
}
|
||||
|
||||
bool BatimentQuadMaison::split() {
|
||||
float h = floatInRange(seed,0,minHeight,maxHeight);
|
||||
float htoit = floatInRange(seed,0,minHeight/2,maxHeight/2);
|
||||
Quad ch = c + Vertex(0,0,h);
|
||||
Vertex toit = (ch[NE] + ch[SE] + ch[SW] + ch[NW]) / 4 + Vertex(0,0,htoit);
|
||||
|
||||
addChild(new BatimentQuadBlock(c,ch));
|
||||
addChild(new BatimentQuadToit(ch,1));
|
||||
return true;
|
||||
}
|
||||
|
||||
void BatimentQuadMaison::triangulation() {
|
||||
triangles.reserve(12);
|
||||
|
||||
float h = floatInRange(seed,0,minHeight,maxHeight);
|
||||
float htoit = floatInRange(seed,0,minHeight/2,maxHeight/2);
|
||||
Quad ch = c + Vertex(0,0,h);
|
||||
Vertex toit = (ch[NE] + ch[SE] + ch[SW] + ch[NW]) / 4 + Vertex(0,0,htoit);
|
||||
|
||||
addGPUOcto(c,ch,Couleurs::mur);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
addGPUTriangle(ch[SE+i],toit,ch[NE+i],0x961618);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADMAISON_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADMAISON_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentQuadMaison : public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
|
||||
public :
|
||||
static const int minHeight = 250;
|
||||
static const int maxHeight = 350;
|
||||
|
||||
BatimentQuadMaison(Quad c);
|
||||
virtual void triangulation();
|
||||
virtual bool split();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadMaisonPont::BatimentQuadMaisonPont(Quad _c, int level) : Chose(), c(_c), level(level) {
|
||||
addEntropy(c);
|
||||
levelHeight = 300;
|
||||
}
|
||||
|
||||
void BatimentQuadMaisonPont::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(10,10,level*levelHeight)); // TODO
|
||||
}
|
||||
|
||||
bool BatimentQuadMaisonPont::split() {
|
||||
int ih;
|
||||
Quad q = c.makeParallelogram();
|
||||
if(Segment(q[NE],q[NW]).length() < Segment(q[NE],q[SE]).length())
|
||||
q = q << 1;
|
||||
float partLength = Segment(q[NE],q[NW]).length() / 3;
|
||||
Quad qa = q.inset(E,2*partLength);
|
||||
Quad qb = q.inset(W,2*partLength);
|
||||
Quad qc = q.inset(E, partLength).inset(W, partLength);
|
||||
Quad qh = q;
|
||||
|
||||
addChild(new BatimentQuadJardin(c));
|
||||
addChild(new BatimentQuadBlock(qa,qa + Vertex(0,0,levelHeight)));
|
||||
addChild(new BatimentQuadBlock(qb,qb + Vertex(0,0,levelHeight)));
|
||||
for(ih=1;ih<level;ih++)
|
||||
addChild(new BatimentQuadBlock((qh + Vertex(0,0,ih*levelHeight)),qh + Vertex(0,0,(ih+1)*levelHeight)));
|
||||
//addChild(new BatimentQuadPont(qc,levelHeight));
|
||||
addChild(new BatimentQuadToit(qh + Vertex(0,0,(ih+1)*levelHeight),160));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BatimentQuadMaisonPont::triangulation() {
|
||||
float h = level*levelHeight / 3.f;
|
||||
Quad q = c.makeParallelogram();
|
||||
Quad qh = q + Vertex(0,0,h);
|
||||
float htoit = Segment(q[SE],q[NE]).length() / 5;
|
||||
|
||||
addGPUQuad(c,0x808080);
|
||||
addGPUOcto(q,qh,Couleurs::mur);
|
||||
|
||||
Vertex ce = qh[SE] + (qh[NE] - qh[SE])/2 + Vertex(0,0,htoit);
|
||||
Vertex cw = qh[SW] + (qh[NW] - qh[SW])/2 + Vertex(0,0,htoit);
|
||||
|
||||
addGPUTriangle(qh[NW],cw,qh[SW],Couleurs::mur);
|
||||
addGPUTriangle(qh[SE],ce,qh[NE],Couleurs::mur);
|
||||
|
||||
addGPUQuad(qh[NE],qh[NW],cw,ce,Couleurs::toit);
|
||||
addGPUQuad(qh[SW],qh[SE],ce,cw,Couleurs::toit);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADMAISONPONT_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADMAISONPONT_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentQuadMaisonPont: public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
int level;
|
||||
float levelHeight;
|
||||
|
||||
public :
|
||||
|
||||
BatimentQuadMaisonPont(Quad c, int level);
|
||||
virtual bool split();
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,50 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadMur::BatimentQuadMur(Quad _c, Quad _ch) : Chose(), c(_c), ch(_ch) {
|
||||
addEntropy(c);
|
||||
addEntropy(ch);
|
||||
this->window = false;
|
||||
}
|
||||
|
||||
void BatimentQuadMur::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(ch);
|
||||
}
|
||||
|
||||
void BatimentQuadMur::setWindow(bool val) {
|
||||
val = val;
|
||||
this->window = val;
|
||||
Quad q = Quad(ch[NE],c[NE],c[NW],ch[NW]);
|
||||
int lr = (q.length(S) - 120)/2;
|
||||
|
||||
Quad wFront = q.insetNESW(40,lr,120,lr);
|
||||
Quad wBack = wFront.offsetNormal(28);
|
||||
windowPos = Quad(wFront[SE],wBack[SE],wBack[SW],wFront[SW]);
|
||||
windowPosh = Quad(wFront[NE],wBack[NE],wBack[NW],wFront[NW]);
|
||||
}
|
||||
|
||||
bool BatimentQuadMur::split() {
|
||||
if(!window)
|
||||
return false;
|
||||
|
||||
Quad right = Quad(windowPos[NW],windowPos[SW],c[SW],c[NW]);
|
||||
Quad righth = Quad(windowPosh[NW],windowPosh[SW],ch[SW],ch[NW]);
|
||||
Quad left = Quad(c[NE],c[SE],windowPos[SE],windowPos[NE]);
|
||||
Quad lefth = Quad(ch[NE],ch[SE],windowPosh[SE],windowPosh[NE]);
|
||||
Quad top = Quad(windowPosh[NE],windowPosh[NW],windowPosh[SW],windowPosh[SE]);
|
||||
|
||||
addChild(new BatimentQuadMur(c,windowPos));
|
||||
addChild(new BatimentQuadMur(windowPosh,ch));
|
||||
addChild(new BatimentQuadMur(left,lefth));
|
||||
addChild(new BatimentQuadMur(right,righth));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BatimentQuadMur::triangulation() {
|
||||
if(!window)
|
||||
addGPUOcto(c, ch, Couleurs::mur);
|
||||
//else
|
||||
//addGPUOcto(c, ch, 0xFF,0x10,0x00);
|
||||
//addGPUQuad(windowPosh,0xFF,0xFF,0x00);
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADMUR_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADMUR_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
class BatimentQuadMur: public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
Quad ch;
|
||||
bool window; // Contient une fenêtre ou non.
|
||||
Quad windowPos;
|
||||
Quad windowPosh;
|
||||
|
||||
public :
|
||||
|
||||
BatimentQuadMur(Quad c, Quad ch);
|
||||
virtual void triangulation();
|
||||
virtual bool split();
|
||||
virtual void getBoundingBoxPoints();
|
||||
void setWindow(bool val);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadPont::BatimentQuadPont(Quad _c, float _height) : Chose(), c(_c), height(_height) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentQuadPont::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,height)); // TODO
|
||||
}
|
||||
|
||||
float BatimentQuadPont::ct(float x) {
|
||||
return (float)(1 - cosh(x / 1.f));
|
||||
}
|
||||
|
||||
float BatimentQuadPont::nt(float x, float _height) {
|
||||
return (ct(x) + -ct(-1.7f))/(ct(0)+ -ct(-1.7f)) * _height;
|
||||
}
|
||||
|
||||
void BatimentQuadPont::triangulation() {
|
||||
//triangles.reserve(2);
|
||||
float var;
|
||||
Quad q = c;
|
||||
Vertex a,b;
|
||||
height -= 20;
|
||||
Vertex pa = c[NW];
|
||||
Vertex pb = c[SW];
|
||||
Quad ch = c + Vertex(0,0,height+20);
|
||||
Vertex l1 = c[NE] - c[NW];
|
||||
Vertex l2 = c[SW] - c[SE];
|
||||
|
||||
float pas = 0.1f;
|
||||
int steps = (int)(Angle::Pi / pas);
|
||||
float n2 = l2.norm()/(Angle::Pi / pas);
|
||||
n2=n2;
|
||||
int middle = steps/2;
|
||||
int n;
|
||||
|
||||
addGPUTriangle(c[SW],pb,ch[SW],0xD0D0D0);
|
||||
addGPUTriangle(pa,c[NW],ch[NW],0xD0D0D0);
|
||||
|
||||
for(var=-1.7f, n=0; var <= 1.7f; var+=pas, n++) {
|
||||
q = q.inset(W,n2);
|
||||
a = q[NW] + Vertex(0,0,nt(var,height));
|
||||
b = q[SW] + Vertex(0,0,nt(var,height));
|
||||
|
||||
addGPUQuad(a,b,pb,pa,0xD0D0D0);
|
||||
|
||||
if( n < middle) {
|
||||
addGPUTriangle(pa,a,ch[NW],0xD0D0D0);
|
||||
addGPUTriangle(b,pb,ch[SW],0xD0D0D0);
|
||||
}
|
||||
else if(n == middle) {
|
||||
addGPUTriangle(pa,a,ch[NW],0xD0D0D0);
|
||||
addGPUTriangle(b,pb,ch[SW],0xD0D0D0);
|
||||
addGPUTriangle(a,ch[NE],ch[NW],0xD0D0D0);
|
||||
addGPUTriangle(b,ch[SW],ch[SE],0xD0D0D0);
|
||||
}
|
||||
else {
|
||||
addGPUTriangle(pa,a,ch[NE],0xD0D0D0);
|
||||
addGPUTriangle(b,pb,ch[SE],0xD0D0D0);
|
||||
}
|
||||
|
||||
pa = a;
|
||||
pb = b;
|
||||
}
|
||||
|
||||
addGPUTriangle(c[SE],pb,ch[SE],0xD0D0D0);
|
||||
addGPUTriangle(c[NE],pa,ch[NE],0xD0D0D0);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADPONT_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADPONT_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentQuadPont: public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
float height;
|
||||
|
||||
public :
|
||||
BatimentQuadPont(Quad c, float height);
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
private:
|
||||
float ct(float x);
|
||||
float nt(float x, float height);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentQuadToit::BatimentQuadToit(Quad _c, int _type) : Chose(), c(_c), type(_type) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentQuadToit::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,200)); // TODO
|
||||
}
|
||||
|
||||
void BatimentQuadToit::triangulation() {
|
||||
if(type == 1) {
|
||||
if(c.minLengthNS() < c.minLengthEW())
|
||||
c = c << 1;
|
||||
c = c.inset(N, -20).inset(S,-20);
|
||||
height = c.minLengthEW() / 5;
|
||||
Vertex ce = c[SE] + (c[NE] - c[SE])/2 + Vertex(0,0,height);
|
||||
Vertex cw = c[SW] + (c[NW] - c[SW])/2 + Vertex(0,0,height);
|
||||
|
||||
addGPUTriangle(c[NW],cw,c[SW],0xF1E0E0);
|
||||
addGPUTriangle(c[SE],ce,c[NE],0xF1E0E0);
|
||||
|
||||
//addGPUQuad(c[NE],c[NW],c[SW],c[SE],0xF1E0E0);
|
||||
addGPUQuad(c[NE],c[NW],cw,ce,0xE02000);
|
||||
addGPUQuad(c[SW],c[SE],ce,cw,0xE02000);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTQUADTOIT_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTQUADTOIT_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
// TOTO en faire un classe abstraite et définir des classe filles pour les différents types de toits.
|
||||
class BatimentQuadToit: public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
float height;
|
||||
int type;
|
||||
|
||||
public :
|
||||
|
||||
BatimentQuadToit(Quad c, int type);
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,49 +0,0 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
BatimentTri::BatimentTri(Triangle _c) : Chose(), c(_c) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
void BatimentTri::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
addBBPoints(c + Vertex(0,0,maxHeight + maxHeight/2)); // TODO
|
||||
}
|
||||
|
||||
bool BatimentTri::split() {
|
||||
return false;
|
||||
// if(proba(seed, 0, 1, 10)) {
|
||||
// Quad q = Quad(c[NE],c[SE],c[SW],c[NW]);
|
||||
// // TODO ajouter une classe surface.
|
||||
// //addQuad(c[SE],c[SW],c[NW],c[NE],0xDD,0xDD,0xDD);
|
||||
// addChild(new BatimentQuadMaisonPont(q,800));
|
||||
// } else {
|
||||
// int th = 20; // Terrain height.
|
||||
// Quad q = Quad(c[NE],c[SE],c[SW],c[NW]);
|
||||
// q.offset(N,-Dimensions::largeurTrottoir);
|
||||
// q.offset(E,-Dimensions::largeurTrottoir);
|
||||
// q.offset(S,-Dimensions::largeurTrottoir);
|
||||
// q.offset(W,-Dimensions::largeurTrottoir);
|
||||
|
||||
// addChild(new TrottoirQuadNormal(Quad(c[NE],c[SE],q[SE],q[NE]),th,E));
|
||||
// addChild(new TrottoirQuadNormal(Quad(c[SE],c[SW],q[SW],q[SE]),th,E));
|
||||
// addChild(new TrottoirQuadNormal(Quad(c[SW],c[NW],q[NW],q[SW]),th,E));
|
||||
// addChild(new TrottoirQuadNormal(Quad(c[NW],c[NE],q[NE],q[NW]),th,E));
|
||||
|
||||
// Quad qh = q + Vertex(0,0,th);
|
||||
// addChild(new BatimentQuadJardin(qh));
|
||||
|
||||
// qh.offset(this->entry,-400);
|
||||
// addChild(new BatimentQuadMaison(qh));
|
||||
// }
|
||||
// return true;
|
||||
}
|
||||
|
||||
void BatimentTri::triangulation() {
|
||||
float h = floatInRange(seed,1,minHeight,maxHeight);
|
||||
// float htoit = hashInRange(seed,2,minHeight/2,maxHeight/2);
|
||||
|
||||
Triangle ch = c + Vertex(0,0,h);
|
||||
addGPUTriangle(ch, Couleurs::toit);
|
||||
for (int i = 0; i < 3; i++)
|
||||
addGPUQuad(c[LEFT+i], c[TOP+i], ch[TOP+i], ch[LEFT+i], Couleurs::mur);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef _RULES_BATIMENT_BATIMENTTRI_HH_
|
||||
#define _RULES_BATIMENT_BATIMENTTRI_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
||||
|
||||
class BatimentTri : public Chose {
|
||||
private :
|
||||
Triangle c;
|
||||
|
||||
public :
|
||||
static const int minHeight = 400;
|
||||
static const int maxHeight = 800;
|
||||
|
||||
BatimentTri(Triangle c);
|
||||
virtual bool split();
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_COLULEURSDIMENSIONS_HH_
|
||||
#define _RULES_ARCHITECTURE_COLULEURSDIMENSIONS_HH_
|
||||
#ifndef _RULES_COLULEURSDIMENSIONS_HH_
|
||||
#define _RULES_COLULEURSDIMENSIONS_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_BATIMENT_EtageQuad_HH_
|
||||
#define _RULES_BATIMENT_EtageQuad_HH_
|
||||
#ifndef _RULES_ETAGE_HH_
|
||||
#define _RULES_ETAGE_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_BATIMENT_Mur_HH_
|
||||
#define _RULES_BATIMENT_Mur_HH_
|
||||
#ifndef _RULES_MUR_HH_
|
||||
#define _RULES_MUR_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_QUARTIER_HH_
|
||||
#define _RULES_ARCHITECTURE_QUARTIER_HH_
|
||||
#ifndef _RULES_QUARTIER_HH_
|
||||
#define _RULES_QUARTIER_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_ROUTE_HH_
|
||||
#define _RULES_ARCHITECTURE_ROUTE_HH_
|
||||
#ifndef _RULES_ROUTETROTTOIR_HH_
|
||||
#define _RULES_ROUTETROTTOIR_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_TERRAIN_HH_
|
||||
#define _RULES_ARCHITECTURE_TERRAIN_HH_
|
||||
#ifndef _RULES_TERRAIN_HH_
|
||||
#define _RULES_TERRAIN_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _RULES_ARCHITECTURE_TOIT_HH_
|
||||
#define _RULES_ARCHITECTURE_TOIT_HH_
|
||||
#ifndef _RULES_TOIT_HH_
|
||||
#define _RULES_TOIT_HH_
|
||||
|
||||
#include "all_includes.hh"
|
||||
|
Loading…
Reference in New Issue
Block a user