Quelques corrections sur les arches.
This commit is contained in:
parent
05836fd361
commit
5093ee45de
|
@ -1,18 +1,28 @@
|
||||||
#include "all_includes.hh"
|
#include "all_includes.hh"
|
||||||
|
|
||||||
ArcheQuad::ArcheQuad(Quad _c, float _height, float _start, float _end) : Chose(), c(_c), height(_height), start(_start), end(_end) {
|
ArcheQuad::ArcheQuad(Quad _c, float _height, float _start, float _end, Type _type) : Chose(), c(_c), height(_height), start(_start), end(_end), type(_type) {
|
||||||
addEntropy(c);
|
if (type == RANDOM) {
|
||||||
addEntropy(height);
|
addEntropy(c);
|
||||||
|
addEntropy(height);
|
||||||
|
switch (hash2(seed, 0) % 3) {
|
||||||
|
case 0: type = OGIVE; break;
|
||||||
|
case 1: type = BERCEAU; break;
|
||||||
|
case 2:
|
||||||
|
default: type = PLAT; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArcheQuad::split() {
|
bool ArcheQuad::split() {
|
||||||
|
if (type == PLAT)
|
||||||
|
return false;
|
||||||
if (std::abs(end - start) < 0.1 && std::abs(f(end) - f(start)) < 0.05)
|
if (std::abs(end - start) < 0.1 && std::abs(f(end) - f(start)) < 0.05)
|
||||||
return false;
|
return false;
|
||||||
float mid = (start + end) / 2;
|
float mid = (start + end) / 2;
|
||||||
Vertex n = (c[NW] + c[NE]) / 2.f;
|
Vertex n = (c[NW] + c[NE]) / 2.f;
|
||||||
Vertex s = (c[SE] + c[SW]) / 2.f;
|
Vertex s = (c[SE] + c[SW]) / 2.f;
|
||||||
addChild(new ArcheQuad(Quad(n, s, c[SW], c[NW]), height, start, mid));
|
addChild(new ArcheQuad(Quad(n, s, c[SW], c[NW]), height, start, mid, type));
|
||||||
addChild(new ArcheQuad(Quad(c[NE], c[SE], s, n), height, mid, end));
|
addChild(new ArcheQuad(Quad(c[NE], c[SE], s, n), height, mid, end, type));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,14 +32,7 @@ void ArcheQuad::triangulation() {
|
||||||
Quad chw = c.offsetNormal(f(start) * height * 0.9);
|
Quad chw = c.offsetNormal(f(start) * height * 0.9);
|
||||||
addGPUQuad(Quad(ch[NW], chw[NW], che[NE], ch[NE]), Couleurs::mur);
|
addGPUQuad(Quad(ch[NW], chw[NW], che[NE], ch[NE]), Couleurs::mur);
|
||||||
addGPUQuad(Quad(ch[SE], che[SE], chw[SW], ch[SW]), Couleurs::mur);
|
addGPUQuad(Quad(ch[SE], che[SE], chw[SW], ch[SW]), Couleurs::mur);
|
||||||
addGPUQuad(Quad(che[SE], che[NE], chw[NW], chw[SW]), Couleurs::cielHaut);
|
addGPUQuad(Quad(che[SE], che[NE], chw[NW], chw[SW]), Couleurs::mur);
|
||||||
/*
|
|
||||||
// Doivent être dessiné par le bâtiment englobant.
|
|
||||||
if (start == 0)
|
|
||||||
addGPUQuad(Quad(c[SW], c[NW], chw[NW], chw[SW]), Couleurs::mur);
|
|
||||||
if (end == 1)
|
|
||||||
addGPUQuad(Quad(c[NE], c[SE], che[SE], che[NE]), Couleurs::mur);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArcheQuad::getBoundingBoxPoints() {
|
void ArcheQuad::getBoundingBoxPoints() {
|
||||||
|
@ -37,19 +40,10 @@ void ArcheQuad::getBoundingBoxPoints() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float ArcheQuad::f(float x) {
|
float ArcheQuad::f(float x) {
|
||||||
return berceau(x);
|
switch(type){
|
||||||
switch(hash2(seed, 0) % 2){
|
case OGIVE: return std::sin(std::acos(std::abs(x - 0.5f) + 0.5f)) / std::sin(std::acos(0.5f));
|
||||||
case 0: return ogive(x);
|
case BERCEAU: return std::sin(std::acos(2*x-1));
|
||||||
case 1:
|
case PLAT:
|
||||||
default: return berceau(x);
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float ArcheQuad::ogive(float x) {
|
|
||||||
// TODO : mettre x à l'échelle
|
|
||||||
return sin(acos(abs(x / 2.f) + 1.f/2.f));
|
|
||||||
}
|
|
||||||
|
|
||||||
float ArcheQuad::berceau(float x) {
|
|
||||||
return sin(acos(2*x-1));
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,18 +6,23 @@
|
||||||
// Arche du nord au sud
|
// Arche du nord au sud
|
||||||
class ArcheQuad : public Chose {
|
class ArcheQuad : public Chose {
|
||||||
private:
|
private:
|
||||||
|
enum Type {
|
||||||
|
RANDOM,
|
||||||
|
OGIVE,
|
||||||
|
BERCEAU,
|
||||||
|
PLAT
|
||||||
|
};
|
||||||
Quad c;
|
Quad c;
|
||||||
float height;
|
float height;
|
||||||
float start;
|
float start;
|
||||||
float end;
|
float end;
|
||||||
|
Type type;
|
||||||
public:
|
public:
|
||||||
ArcheQuad(Quad _c, float _height, float _start = 0, float _end = 1);
|
ArcheQuad(Quad _c, float _height, float _start = 0, float _end = 1, Type _type = RANDOM);
|
||||||
virtual bool split();
|
virtual bool split();
|
||||||
virtual void triangulation();
|
virtual void triangulation();
|
||||||
virtual void getBoundingBoxPoints();
|
virtual void getBoundingBoxPoints();
|
||||||
float f(float x);
|
float f(float x);
|
||||||
float ogive(float x);
|
|
||||||
float berceau(float x);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -72,10 +72,12 @@ void BatimentQuad_::etages() {
|
||||||
Quad q = c; // c.insetNESW(30)
|
Quad q = c; // c.insetNESW(30)
|
||||||
Quad qh;
|
Quad qh;
|
||||||
for (int i = 0; i < nbEtages; i++) {
|
for (int i = 0; i < nbEtages; i++) {
|
||||||
qh = q.offsetNormal(floatInRange(seed, 1+i, Dimensions::hauteurEtage*0.9f, Dimensions::hauteurEtage*1.1f));
|
if (nbEtages > 1 && i == 0 && w[N] && w[S]) {
|
||||||
if (i == 0 && w[N] && w[S]) {
|
float h = floatInRange(seed, 1+i, Dimensions::hauteurEtage*1.4f, Dimensions::hauteurEtage*1.6f);
|
||||||
addChild(new ArcheQuad(q, Segment(qh[NE],q[NE]).length()));
|
qh = q.offsetNormal(h);
|
||||||
|
addChild(new ArcheQuad(q, h));
|
||||||
} else {
|
} else {
|
||||||
|
qh = q.offsetNormal(floatInRange(seed, 1+i, Dimensions::hauteurEtage*0.9f, Dimensions::hauteurEtage*1.1f));
|
||||||
addChild(new EtageQuad(q,qh));
|
addChild(new EtageQuad(q,qh));
|
||||||
}
|
}
|
||||||
q = qh;
|
q = qh;
|
||||||
|
|
2
view.cpp
2
view.cpp
|
@ -170,7 +170,7 @@ void View::mainLoop() {
|
||||||
short continuer = 1;
|
short continuer = 1;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_EnableKeyRepeat(40,40);
|
SDL_EnableKeyRepeat(40,40);
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
while ( SDL_PollEvent(&event) ); // empty queue.
|
while ( SDL_PollEvent(&event) ); // empty queue.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user