Merge branch 'master' of https://github.com/jsmaniac/2011-m2s3-city-builder
This commit is contained in:
commit
b9e164aa0f
|
@ -30,11 +30,9 @@ Quad Quad::insetNESW(float offset) const {
|
|||
}
|
||||
|
||||
Quad Quad::insetOpp(Cardinal side, float offset) const {
|
||||
Quad q = (*this) << int(side);
|
||||
Quad qb = (*this) << int(side);
|
||||
|
||||
qb = qb.inset(N,offset);
|
||||
return Quad(q[NE],qb[NE],qb[NW],q[NW]);
|
||||
Quad q = (*this) << side;
|
||||
Quad qi = q.inset(N,offset);
|
||||
return (Quad(q[NE],qi[NE],qi[NW],q[NW]) >> side);
|
||||
}
|
||||
|
||||
Quad Quad::makeParallelogram() const {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
Arbre::Arbre(Vertex _start, Triangle plane) : start(_start), type(ARBRE) {
|
||||
void Arbre::initPlane(Vertex _start, Triangle plane) {
|
||||
start = _start;
|
||||
type = ARBRE;
|
||||
addEntropy(start);
|
||||
addEntropy(plane);
|
||||
|
||||
|
@ -14,6 +16,14 @@ Arbre::Arbre(Vertex _start, Triangle plane) : start(_start), type(ARBRE) {
|
|||
length = floatInRange(seed, -5, 3*100, 4*100);
|
||||
}
|
||||
|
||||
Arbre::Arbre(Vertex _start, Triangle plane) {
|
||||
initPlane(_start, plane);
|
||||
}
|
||||
|
||||
Arbre::Arbre(Vertex _start, Quad plane) {
|
||||
initPlane(_start, Triangle(plane[NE], plane[SE], plane[SW]));
|
||||
}
|
||||
|
||||
Arbre::Arbre(Vertex _start, Angle3D _rotation, float _length, Type _type) : start(_start), rotation(_rotation), length(_length), type(_type) {
|
||||
addEntropy(start, rotation.h, rotation.l, rotation.u);
|
||||
addEntropy(length);
|
||||
|
|
|
@ -19,8 +19,10 @@ private:
|
|||
static float tauxMax();
|
||||
static float calcLimitLengthFactor();
|
||||
static const float limitLengthFactor;
|
||||
void initPlane(Vertex _start, Triangle plane);
|
||||
public:
|
||||
static float maxRadius(float length);
|
||||
Arbre(Vertex _start, Quad plane);
|
||||
Arbre(Vertex _start, Triangle plane);
|
||||
Arbre(Vertex _start, Angle3D _rotation, float _length, Type _type = ARBRE);
|
||||
virtual bool split();
|
||||
|
|
|
@ -135,18 +135,6 @@ void QuartierQuad::batiments() {
|
|||
addChild(new BatimentQuad_(qbatiments));
|
||||
} else {
|
||||
addChild(new TerrainQuad(qbatiments));
|
||||
Vertex p1 = qbatiments.insetProportionnal(0.7).randomPoint(seed, 1);
|
||||
Vertex p2 = qbatiments.insetProportionnal(0.7).randomPoint(seed, 2);
|
||||
Vertex p3 = qbatiments.insetProportionnal(0.7).randomPoint(seed, 3);
|
||||
if (proba(seed, 4, 3, 4)) {
|
||||
addChild(new Arbre(p1, Triangle(qbatiments[NE], qbatiments[SE], qbatiments[SW])));
|
||||
if (proba(seed, 5, 3, 4) && Segment(p1,p2).length() > 3 * 100) {
|
||||
addChild(new Arbre(p2, Triangle(qbatiments[NE], qbatiments[SE], qbatiments[SW])));
|
||||
if (proba(seed, 6, 3, 4) && Segment(p2,p3).length() > 3 * 100 && Segment(p1,p3).length() > 3 * 100) {
|
||||
addChild(new Arbre(p3, Triangle(qbatiments[NE], qbatiments[SE], qbatiments[SW])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,35 @@
|
|||
#include "all_includes.hh"
|
||||
|
||||
TerrainQuad::TerrainQuad(Quad _c) : Chose(), c(_c) {
|
||||
TerrainQuad::TerrainQuad(Quad _c, bool _addTrees) : Chose(), c(_c), addTrees(_addTrees) {
|
||||
addEntropy(c);
|
||||
}
|
||||
|
||||
bool TerrainQuad::split() {
|
||||
if (!addTrees) return false;
|
||||
|
||||
addChild(new TerrainQuad(c, false));
|
||||
|
||||
int maxNArbres = 10;
|
||||
Vertex p[maxNArbres];
|
||||
int pi = 0;
|
||||
int nArbres = hash2(seed, -1) % (maxNArbres + 1);
|
||||
for (int essai = 0; essai < nArbres * 2 && pi < nArbres; essai++) {
|
||||
p[pi] = c.insetProportionnal(0.7).randomPoint(seed, essai);
|
||||
bool success = true;
|
||||
for (int j = 0; j < pi; j++) {
|
||||
if (Segment(p[j], p[pi]).length() < 3 * 100) {
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (success) pi++;
|
||||
}
|
||||
for (int i = 0; i < pi; i++) {
|
||||
addChild(new Arbre(p[i], c));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TerrainQuad::getBoundingBoxPoints() {
|
||||
addBBPoints(c);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,11 @@ class TerrainTri : public Chose {
|
|||
class TerrainQuad : public Chose {
|
||||
private :
|
||||
Quad c;
|
||||
bool addTrees;
|
||||
|
||||
public :
|
||||
TerrainQuad(Quad _c);
|
||||
TerrainQuad(Quad _c, bool _addTrees = true);
|
||||
virtual bool split();
|
||||
virtual void triangulation();
|
||||
virtual void getBoundingBoxPoints();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user