Ajout des arches.
This commit is contained in:
parent
46f1cf4e43
commit
05836fd361
|
@ -31,3 +31,7 @@ Vertex Segment::randomPos(int seed, int n, float a, float b) {
|
||||||
float pos = floatInRange(seed, n, a, b);
|
float pos = floatInRange(seed, n, a, b);
|
||||||
return (u * pos + v * (1-pos));
|
return (u * pos + v * (1-pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Segment operator+(const Segment& s, const Vertex& voff) {
|
||||||
|
return Segment(s.u + voff, s.v + voff);
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Segment {
|
||||||
Vertex at(float);
|
Vertex at(float);
|
||||||
Segment reduce(float value);
|
Segment reduce(float value);
|
||||||
Vertex randomPos(int seed, int n, float a, float b); // Renvoie un vertex sur le segment [u,v], à une position entre a et b.
|
Vertex randomPos(int seed, int n, float a, float b); // Renvoie un vertex sur le segment [u,v], à une position entre a et b.
|
||||||
|
friend Segment operator+(const Segment& t, const Vertex& v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,19 +6,23 @@ ArcheQuad::ArcheQuad(Quad _c, float _height, float _start, float _end) : Chose()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArcheQuad::split() {
|
bool ArcheQuad::split() {
|
||||||
if (std::abs(end - start) < 0.01)
|
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;
|
||||||
addChild(new ArcheQuad(c, height, start, mid));
|
Vertex n = (c[NW] + c[NE]) / 2.f;
|
||||||
addChild(new ArcheQuad(c, height, mid, end));
|
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(c[NE], c[SE], s, n), height, mid, end));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArcheQuad::triangulation() {
|
void ArcheQuad::triangulation() {
|
||||||
Quad che = c.offsetNormal(f(end) * height);
|
Quad ch = c.offsetNormal(height);
|
||||||
Quad chw = c.offsetNormal(f(start) * height);
|
Quad che = c.offsetNormal(f(end) * height * 0.9);
|
||||||
addGPUQuad(Quad(c[NW], c[NE], che[NE], chw[NW]), Couleurs::mur);
|
Quad chw = c.offsetNormal(f(start) * height * 0.9);
|
||||||
addGPUQuad(Quad(c[SE], c[SW], chw[SW], che[SE]), 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(che[SE], che[NE], chw[NW], chw[SW]), Couleurs::cielHaut);
|
||||||
/*
|
/*
|
||||||
// Doivent être dessiné par le bâtiment englobant.
|
// Doivent être dessiné par le bâtiment englobant.
|
||||||
if (start == 0)
|
if (start == 0)
|
||||||
|
@ -33,6 +37,7 @@ void ArcheQuad::getBoundingBoxPoints() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float ArcheQuad::f(float x) {
|
float ArcheQuad::f(float x) {
|
||||||
|
return berceau(x);
|
||||||
switch(hash2(seed, 0) % 2){
|
switch(hash2(seed, 0) % 2){
|
||||||
case 0: return ogive(x);
|
case 0: return ogive(x);
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -41,9 +46,10 @@ float ArcheQuad::f(float x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float ArcheQuad::ogive(float x) {
|
float ArcheQuad::ogive(float x) {
|
||||||
|
// TODO : mettre x à l'échelle
|
||||||
return sin(acos(abs(x / 2.f) + 1.f/2.f));
|
return sin(acos(abs(x / 2.f) + 1.f/2.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
float ArcheQuad::berceau(float x) {
|
float ArcheQuad::berceau(float x) {
|
||||||
return sin(acos(x));
|
return sin(acos(2*x-1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "all_includes.hh"
|
#include "all_includes.hh"
|
||||||
|
|
||||||
|
// Arche du nord au sud
|
||||||
class ArcheQuad : public Chose {
|
class ArcheQuad : public Chose {
|
||||||
private:
|
private:
|
||||||
Quad c;
|
Quad c;
|
||||||
|
|
|
@ -73,7 +73,11 @@ void BatimentQuad_::etages() {
|
||||||
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));
|
qh = q.offsetNormal(floatInRange(seed, 1+i, Dimensions::hauteurEtage*0.9f, Dimensions::hauteurEtage*1.1f));
|
||||||
|
if (i == 0 && w[N] && w[S]) {
|
||||||
|
addChild(new ArcheQuad(q, Segment(qh[NE],q[NE]).length()));
|
||||||
|
} else {
|
||||||
addChild(new EtageQuad(q,qh));
|
addChild(new EtageQuad(q,qh));
|
||||||
|
}
|
||||||
q = qh;
|
q = qh;
|
||||||
}
|
}
|
||||||
addChild(new ToitQuad(qh, Dimensions::hauteurToit));
|
addChild(new ToitQuad(qh, Dimensions::hauteurToit));
|
||||||
|
|
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_ON);
|
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
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