www

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

commit 9b8dfc1c7de103cb959003b2a617eedbc6ca3160
parent 4a69a391f66c6ceaec9696ee58d8f4b4dd4c53c3
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Thu, 12 Jan 2012 00:21:54 +0100

Ajout de architecture/arche.cpp .

Diffstat:
Mall_includes.hh | 1+
Arules/architecture/arche.cpp | 43+++++++++++++++++++++++++++++++++++++++++++
Arules/architecture/arche.hh | 27+++++++++++++++++++++++++++
Mrules/chose.cpp | 10++++++++++
Mrules/chose.hh | 2++
5 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/all_includes.hh b/all_includes.hh @@ -34,6 +34,7 @@ class Chose; #include "rules/chose.hh" +#include "rules/architecture/arche.hh" #include "rules/architecture/toit.hh" #include "rules/batiment/batimentquad.hh" diff --git a/rules/architecture/arche.cpp b/rules/architecture/arche.cpp @@ -0,0 +1,43 @@ +#include "all_includes.hh" + +ArcheQuad::ArcheQuad(Quad _c, float _height, float _start, float _end) : c(_c), height(_height), start(_start), end(_end) { + addEntropy(c); + addEntropy(height); +} + +bool ArcheQuad::split() { + if (std::abs(end - start) < 0.01) + return false; + float mid = (start + end) / 2; + addChild(new ArcheQuad(c, height, start, mid)); + addChild(new ArcheQuad(c, height, mid, end)); + return true; +} + +void ArcheQuad::triangulation() { + Quad che = c.offsetNormal(f(end) * height); + Quad chw = c.offsetNormal(f(start) * height); + addGPUOcto(c, Quad(che[NE], che[SE], chw[SW], chw[NW]), r, g, b); +} + +void ArcheQuad::getBoundingBoxPoints() { + addBBPoints(c, height); +} + +float ArcheQuad::f(float x) { + switch(hash2(seed, 0) % 2){ + case 0: return ogive(x); + case 1: + default: return berceau(x); + } +} + +// Fonction fausse +float ArcheQuad::ogive(float x) { + return sin(acos(abs(x / 2.f) + 1.f/2.f)); +} + +// Fonction fausse +float ArcheQuad::berceau(float x) { + return sin(acos(x)); +} diff --git a/rules/architecture/arche.hh b/rules/architecture/arche.hh @@ -0,0 +1,27 @@ +#ifndef _RULES_ARCHITECTURE_ARCHE_HH_ +#define _RULES_ARCHITECTURE_ARCHE_HH_ + +#include "all_includes.hh" + +class ArcheQuad : public Chose { +private: + Quad c; + float height; + float start; + float end; +public: + ArcheQuad(Quad _c, float _height, float _start = 0, float _end = 1); + virtual bool split(); + virtual void triangulation(); + virtual void getBoundingBoxPoints(); + float f(float x); + float ogive(float x); + float berceau(float x); +private: + // TODO : couleur de l'arche + static const char r = 0xF1; + static const char g = 0xE0; + static const char b = 0xE0; +}; + +#endif diff --git a/rules/chose.cpp b/rules/chose.cpp @@ -102,6 +102,11 @@ void Chose::addBBPoints(const Triangle t) { addBBPoint(t[RIGHT]); } +void Chose::addBBPoints(const Triangle t, float height) { + addBBPoints(t); + addBBPoints(t.offsetNormal(height)); +} + void Chose::addBBPoints(const Quad q) { addBBPoint(q[NE]); addBBPoint(q[SE]); @@ -109,6 +114,11 @@ void Chose::addBBPoints(const Quad q) { addBBPoint(q[NW]); } +void Chose::addBBPoints(const Quad q, float height) { + addBBPoints(q); + addBBPoints(q.offsetNormal(height)); +} + void Chose::updateAABB() { lod.firstBBPoint = true; getBoundingBoxPoints(); diff --git a/rules/chose.hh b/rules/chose.hh @@ -24,7 +24,9 @@ class Chose { protected : void addBBPoint(const Vertex v); void addBBPoints(const Triangle t); + void addBBPoints(const Triangle t, float height); void addBBPoints(const Quad q); + void addBBPoints(const Quad q, float height); virtual void getBoundingBoxPoints() = 0; Chose(); ~Chose();