summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-02-07 22:20:40 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-02-07 22:20:40 +0100
commit3b4db495c6fe7452fddc096d3085e44470830694 (patch)
tree9511d4fb43621d1e52e2d9a8dfc8b36a21361140
parentf53113f02ea5369e50bd33232db3d2b48f64cc1c (diff)
downloadc3d-3b4db495c6fe7452fddc096d3085e44470830694.tar
c3d-3b4db495c6fe7452fddc096d3085e44470830694.zip
Temperaturverlauf in farbe
-rw-r--r--DisplayClass.cpp2
-rw-r--r--House.cpp7
-rw-r--r--Temparray.cpp50
-rw-r--r--main.cpp8
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(E<collectoroutput && collectoroutput>0) {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<Triangle> 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<sx; ++i){
for(int j=0; j<sy; ++j){
for(int k=0; k<sz; ++k){
for(int l=0; l<6; ++l){
for(int m=0; m<4; ++m){
- //if(temperaturenew(i, j, k, l, m) <= averagetemp/2) b[m] = 1;
- //else if(temperaturenew(i, j, k, l, m) < averagetemp)
- b[m] = 1;//1/(averagetemp/2+temperaturenew(i, j, k, l, m));
+ percent = temperatureold(i, j, k, l, m)/100;
+
+ if (percent < 0.5){
+ r[m] = 0;
+ g[m] = percent*2;
+ b[m] = 1-percent*2;
- g[m]=1;
+ if(g[m] > 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);