diff options
author | Constantin Riß <constantin.riss@dre.de> | 2010-02-08 23:07:48 +0100 |
---|---|---|
committer | Constantin Riß <constantin.riss@dre.de> | 2010-02-08 23:07:48 +0100 |
commit | 8fd9c234206718b4f3b3b07ac06a47d4d6c90a18 (patch) | |
tree | 931050b85a1cdda8bfa6ac34935c9497bb1ed683 | |
parent | 3b4db495c6fe7452fddc096d3085e44470830694 (diff) | |
download | c3d-8fd9c234206718b4f3b3b07ac06a47d4d6c90a18.tar c3d-8fd9c234206718b4f3b3b07ac06a47d4d6c90a18.zip |
kleinere fehler da...
-rw-r--r-- | DisplayClass.cpp | 2 | ||||
-rw-r--r-- | Temparray.cpp | 81 | ||||
-rw-r--r-- | Temparray.h | 17 | ||||
-rw-r--r-- | main.cpp | 2 |
4 files changed, 84 insertions, 18 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp index 91f0888..5940cfe 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, 60, 300, 53.55, 0.82, 2.82, 0.0047, 40, 45, 1900, 3, 11500); + static House house(20, x, y, z, 80, 300, 53.55, 0.82, 2.82, 0.0047, 40, 45, 1900, 3, 11500); triangles=house.getTriangles(); house.controller(); //// temp.calcTemp(); diff --git a/Temparray.cpp b/Temparray.cpp index ae75583..1d8f8b7 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -4,6 +4,7 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){ temparraynew = new float[x0*y0*z0*6*4]; temparrayold = new float[x0*y0*z0*6*4]; cubearray = new Cubehole[x0*y0*z0*6]; + weight1 = new int[x0*y0*z0]; sx = x0; sy = y0; @@ -35,18 +36,7 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){ } } } -/* cubehole(2, 2, 2, 1).setColor(vmml::vec4f(0.0, 0.0, 0.0, 1.0), - vmml::vec4f(0.0, 0.0, 0.0, 1.0), - vmml::vec4f(0.0, 0.0, 0.0, 1.0), - vmml::vec4f(0.0, 0.0, 0.0, 1.0)); - cubehole(2, 2, 2, 2).setColor(vmml::vec4f(1.0, 1.0, 1.0, 1.0), - vmml::vec4f(1.0, 1.0, 1.0, 1.0), - vmml::vec4f(1.0, 1.0, 1.0, 1.0), - vmml::vec4f(1.0, 1.0, 1.0, 1.0)); - cubehole(2, 2, 2, 3).setColor(vmml::vec4f(0.5, 0.5, 0.5, 1.0), - vmml::vec4f(0.5, 0.5, 0.5, 1.0), - vmml::vec4f(0.5, 0.5, 0.5, 1.0), - vmml::vec4f(0.5, 0.5, 0.5, 1.0));*/ + calcweight(); } void Temparray::calcTemp(){ @@ -113,7 +103,7 @@ void Temparray::calcTemp(){ } } } - for(int h = 0; h < 10; ++h) { + for(int h = 0; h <= maxweight; ++h) { for(int i = 0; i < sx; ++i) { for(int j = 0; j < sy; ++j) { for(int k = 0; k < sz; ++k) { @@ -147,7 +137,7 @@ void Temparray::calcTemp(){ tau12 = capacity * thermalresistance; - if(input>=0){ + if(input>=0 && weight(i, j, k)==h){ if(loadableenergy <= 0) inputpower = 0; else if (input >= loadableenergy) { @@ -165,7 +155,7 @@ void Temparray::calcTemp(){ *thermalresistance*factor*(1-exp(-(1/tau12))); } } - if (input < 0){ + if (input < 0 && maxweight-weight(i, j, k)==h){ if(unloadableenergy <= 0) inputpower = 0; else if (input > unloadableenergy) { @@ -533,3 +523,64 @@ void Temparray::coloring() { } } } + +void Temparray::calcweight() { + int dist, disth, disth2, posx, posy, posz, posx2, posy2, posz2; + maxweight = 0; + for(int i=0; i < sx; ++i) { + for(int j=0; j < sy; ++j) { + for(int k=0; k < sz; ++k) { + dist = 0; + if (sx%2 == 0) { + posx = sx/2.0-1; posx2 = sx/2.0; + disth = abs(posx-i); disth2 = abs(posx2-i); + if(disth < disth2) dist += disth; else dist += disth2; + if (sy%2 == 0) { + posy = sy/2.0-1; posy2 = sy/2.0; + disth = abs(posy-j); disth2 = abs(posy2-j); + if(disth < disth2) dist += disth; else dist += disth2; + } + else if (sy%2 == 1) { + posy = sy/2.0-0.5; + dist += abs(posy-j); + if (sz%2 == 0) { + posz = sz/2.0-1; posz2 = sz/2.0; + disth = abs(posz-k); disth2 = abs(posz2-k); + if(disth < disth2) dist += disth; else dist += disth2; + } + else if (sz%2 == 1) { + posz = sz/2.0-0.5; + dist += abs(posz-k); + } + } + } + + else if (sx%2 == 1) { + posx = sx/2.0-1; posx2 = sx/2.0; + disth = abs(posx-i); disth2 = abs(posx2-i); + if(disth < disth2) dist += disth; else dist += disth2; + if (sy%2 == 0) { + posy = sy/2.0-1; posy2 = sy/2.0; + disth = abs(posy-j); disth2 = abs(posy2-j); + if(disth < disth2) dist += disth; else dist += disth2; + } + else if (sy%2 == 1) { + posy = sy/2.0-0.5; + dist += abs(posy-j); + if (sz%2 == 0) { + posz = sz/2.0-1; posz2 = sz/2.0; + disth = abs(posz-k); disth2 = abs(posz2-k); + if(disth < disth2) dist += disth; else dist += disth2; + } + else if (sz%2 == 1) { + posz = sz/2.0-0.5; + dist += abs(posz-k); + } + } + } + weight(i, j, k) = dist; + if (dist > maxweight) maxweight = dist; + } + } + } +} diff --git a/Temparray.h b/Temparray.h index 409b780..19040a2 100644 --- a/Temparray.h +++ b/Temparray.h @@ -31,12 +31,15 @@ class Temparray private: float *temparrayold, *temparraynew; Cubehole *cubearray; - int sx, sy, sz; + int sx, sy, sz, *weight1, maxweight; float averagetemp, earthtemp, probetemp, input, inputpower, factor; Cubehole& cubehole(int x, int y, int z, int line) { return cubearray[x*sy*sz*6 + y*sz*6 + z*6 + line]; } + int& weight(int x, int y, int z){ + return weight1[x*sy*sz + y*sz + z]; + } void mergetemperature(){ for(int i=0; i<sx; i++){ for(int j=0; j<sy; j++){ @@ -77,6 +80,18 @@ class Temparray averagetemp = tempcache/times; // std::cerr << averagetemp << std::endl; } + void calcweight(); + int howmanyweights(int weight0) { + int counter = 0; + for(int i=0; i<sx; ++i){ + for(int j=0; j<sy; ++j){ + for(int k=0; k<sz; ++k){ + if(weight(i, j, k) == weight0) ++counter; + } + } + } + return counter; + } }; #endif /* _TEMPARRAY_H_ */ @@ -237,7 +237,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine ticks += delta; - static DisplayClass render(3, 3, 3); + static DisplayClass render(4, 4, 4); render.renderScene(delta); SwapBuffers(hDC); } |