From 3b4db495c6fe7452fddc096d3085e44470830694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Ri=C3=9F?= Date: Sun, 7 Feb 2010 22:20:40 +0100 Subject: Temperaturverlauf in farbe --- DisplayClass.cpp | 2 +- House.cpp | 7 ++++--- Temparray.cpp | 50 +++++++++++++++++++++++++++++++++++++++----------- main.cpp | 8 ++++---- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/DisplayClass.cpp b/DisplayClass.cpp index c7de909..91f0888 100644 --- a/DisplayClass.cpp +++ b/DisplayClass.cpp @@ -75,7 +75,7 @@ void DisplayClass::renderScene(unsigned long delta) { // static Temparray temp(20, x, y, z); - static House house(20, x, y, z, 70, 300, 53.55, 0.82, 2.82, 0.0047, 40, 45, 1900, 3, 11500); + static House house(20, x, y, z, 60, 300, 53.55, 0.82, 2.82, 0.0047, 40, 45, 1900, 3, 11500); triangles=house.getTriangles(); house.controller(); //// temp.calcTemp(); diff --git a/House.cpp b/House.cpp index dca8d44..2242c53 100644 --- a/House.cpp +++ b/House.cpp @@ -471,21 +471,22 @@ void House::calcprobeinput(int day, int time, int month) { if(E>=collectoroutput && collectoroutput>0) {E -= collectoroutput; collectoroutput=0;} else if(E0) {collectoroutput -= E; E=0;}*/ calccollectoroutput(day, time, month); - std::cerr << "Time: " << time << " Output: " << collectoroutput << " Watt" << std::endl; +// std::cerr << "Time: " << time << " Output: " << collectoroutput << " Watt" << std::endl; // std::cerr << sun.elevationangle(day, time) << std::endl; collectoroutput-=neededenergy[month][time]; } void House::controller(){ - static int day=0, time=0, month=0; + static int day=90, time=0, month=0; calcprobeinput(day, time, month); temp.setprobetemp(collectortemp); temp.setinput(collectoroutput); temp.calcTemp(); + std::cerr << day << " " << time << " " << temp.getaverage() << std::endl; + ++time; if(time > 23){ - std::cerr << day << " " << temp.getaverage() << std::endl; time = 0; ++day; } diff --git a/Temparray.cpp b/Temparray.cpp index 0686ef0..ae75583 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -481,25 +481,53 @@ std::list Temparray::getTriangles(){ void Temparray::coloring() { calcAverage(); - float r[4], g[4], b[4]; + float r[4], g[4], b[4], percent, factor; for(int i=0; i b[m]){ + factor = 1 + (1-g[m]) / g[m]; + } + else { + factor = 1 + (1-b[m]) / b[m]; + } + g[m] *= factor; + b[m] *= factor; + } + else if (percent == 0.5) { + r[m] = 0; + g[m] = 1; + b[m] = 0; + } + else if (percent > 0.5) { + r[m] = (percent-0.5)*2; + g[m] = 1-(percent-0.5)*2; + b[m] = 0; + + if(r[m] > g[m]){ + factor = 1 + (1-r[m]) / r[m]; + } + else { + factor = 1 + (1-g[m]) / g[m]; + } + r[m] *= factor; + g[m] *= factor; + } - //if(temperaturenew(i, j, k, l, m) >= 100-averagetemp/2) r[m] = 1; -// r[m]=0; + cubehole(i, j, k, l).setColor(vmml::vec4f(r[0], g[0], b[0], 1.0), + vmml::vec4f(r[1], g[1], b[1], 1.0), + vmml::vec4f(r[2], g[2], b[2], 1.0), + vmml::vec4f(r[3], g[3], b[3], 1.0)); } - cubehole(i, j, k, l).setColor(vmml::vec4f(r[0], g[0], b[0], 1.0), - vmml::vec4f(r[1], g[1], b[1], 1.0), - vmml::vec4f(r[2], g[2], b[2], 1.0), - vmml::vec4f(r[3], g[3], b[3], 1.0)); } } } diff --git a/main.cpp b/main.cpp index 32206e8..4bfbf85 100644 --- a/main.cpp +++ b/main.cpp @@ -14,10 +14,10 @@ #define MIN_FRAME_DELTA 16 //#define MIN_FRAME_DELTA 41 -//#define DEFAULT_WIDTH 640 -//#define DEFAULT_HEIGHT 640 -#define DEFAULT_HEIGHT 40 -#define DEFAULT_WIDTH 40 +#define DEFAULT_WIDTH 640 +#define DEFAULT_HEIGHT 640 +//#define DEFAULT_HEIGHT 200 +//#define DEFAULT_WIDTH 200 void initGL(bool multisample); void resize(int width, int height); -- cgit v1.2.3