summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-01-07 17:06:32 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-01-07 17:06:32 +0100
commitfd1179672c60358ee6caf538d686dab264a84582 (patch)
tree6d5d2e674ffcfc3bd87aaf7ab46a5d35f6113e28
parent85f21b7ff3c227c73e8182b0480b6cbf8cb3f28d (diff)
downloadc3d-fd1179672c60358ee6caf538d686dab264a84582.tar
c3d-fd1179672c60358ee6caf538d686dab264a84582.zip
Dynamische Arrays geändert([a][b][c][d] zu [a*b*c*d])
-rw-r--r--DisplayClass.cpp7
-rw-r--r--DisplayClass.h3
-rw-r--r--Temparray.cpp37
-rw-r--r--Temparray.h24
4 files changed, 53 insertions, 18 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index af71dcc..0a833c9 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -5,7 +5,7 @@
DisplayClass::Renderer DisplayClass::renderer;
DisplayClass::DisplayClass() : angle(0) {
- cubehole0 = Cubehole(3.0, 6.0, 3.0, 0.0, 0.0, 0.0, 2.5, 2.5,
+ /*cubehole0 = Cubehole(3.0, 6.0, 3.0, 0.0, 0.0, 0.0, 2.5, 2.5,
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
@@ -46,7 +46,10 @@ DisplayClass::DisplayClass() : angle(0) {
std::list<Triangle> t4 = cubehole4.getTriangles();
triangles.splice(triangles.end(), t4);
std::list<Triangle> t5 = cubehole5.getTriangles();
- triangles.splice(triangles.end(), t5);
+ triangles.splice(triangles.end(), t5);*/
+
+ Temparray temp(20, 5, 5, 5);
+ std::list<Triangle> triangles=temp.getTriangles();
tree = new BSPTree(triangles);
}
diff --git a/DisplayClass.h b/DisplayClass.h
index 693587d..1efd945 100644
--- a/DisplayClass.h
+++ b/DisplayClass.h
@@ -2,6 +2,7 @@
#define _DISPLAYCLASS_H_
#include "Cubehole.h"
+#include "Temparray.h"
#include "BSPTree.h"
class DisplayClass
@@ -22,7 +23,7 @@ class DisplayClass
static Renderer renderer;
float angle;
- Cubehole cubehole0, cubehole1, cubehole2, cubehole3, cubehole4, cubehole5;
+ //Cubehole cubehole0, cubehole1, cubehole2, cubehole3, cubehole4, cubehole5;
BSPTree *tree;
};
#endif /*_DISPLAYCLASS_H_*/
diff --git a/Temparray.cpp b/Temparray.cpp
index 06db986..ebedb07 100644
--- a/Temparray.cpp
+++ b/Temparray.cpp
@@ -1,5 +1,40 @@
#include "Temparray.h"
-void Temparray::display(){
+Temparray::Temparray(float initialtemp, int x0, int y0, int z0){
+ float *temperature = new float[x0*y0*z0*6*4];
+ Cubehole *cubearray = new Cubehole[x0*y0*z0*6];
+ tempInit(initialtemp, x0, y0, z0);
+ size[0] = x0; size[1] = y0; size[2] = z0;
+ static const float pos[5] = {-2.0, -1.0, 0.0, 1.0, 2.0};
+ for(int i = 0; i < x0; ++i) {
+ for(int j = 0; j < y0; ++j) {
+ for(int k = 0; k < z0; ++k) {
+ for(int l = 0; l < 6; ++l) {
+ cubearray[i*y0*z0*6 + j*z0*6 + k*6 + l].setSize((6-l)/6, (6-l)/6, (6-l)/6, (5-l)/6, (5-l)/6);
+ cubearray[i*y0*z0*6 + j*z0*6 + k*6 + l].setPos(pos[k], pos[j], pos[i]);
+ cubearray[i*y0*z0*6 + j*z0*6 + k*6 + l].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));
+ }
+ }
+ }
+ }
+}
+
+std::list<Triangle> Temparray::getTriangles(){
+ std::list<Triangle> triangles;
+
+ for(int i = 0; i < size[0]; ++i) {
+ for(int j = 0; j < size[1]; ++j) {
+ for(int k = 0; k < size[2]; ++k) {
+ for(int l = 0; l < 6; ++l) {
+ std::list<Triangle> t = cubearray[i*size[1]*size[2]*6 + j*size[2]*6 + k*6 + l].getTriangles();
+ triangles.splice(triangles.end(), t);
+ }
+ }
+ }
+ }
+ return triangles;
}
diff --git a/Temparray.h b/Temparray.h
index e730e07..e15ea22 100644
--- a/Temparray.h
+++ b/Temparray.h
@@ -3,33 +3,30 @@
#include "Cubehole.h"
#include "gl.h"
+#include <list>
class Temparray
{
public:
- Temparray(float initialtemp, int x0, int y0, int z0){
- float *temperature = new float[x0, y0, z0, 6, 4];
- Cubehole *cubearray = new Cubehole[x0, y0, z0, 6];
- tempInit(initialtemp, x0, y0, z0);
- size[0] = x0; size[1] = y0; size[2] = z0;
- }
+ Temparray(float initialtemp, int x0, int y0, int z0);
~Temparray(){
delete[] temperature;
delete[] cubearray;
}
void setTemp(float temp, int x, int y, int z, int line, int pos){
- temperature[x, y, z, line, pos] = temp;
+ temperature[x*size[1]*size[2]*6*4 + y*size[2]*6*4 + z*6*4 + line*4 + pos] = temp;
calcAverage();
}
-/* void deactivateCube(int x, int y, int z){
+ void deactivateCube(int x, int y, int z){
for(int i=0; i<6; i++){
for(int j=0; j<4; j++){
setTemp(-100, x, y, z, i, j);
}
}
- }*/
- void display();
+ }
+ std::list<Triangle> getTriangles();
+ void calcTemp();
private:
float *temperature;
@@ -37,8 +34,7 @@ class Temparray
int size[3];
float averagetemp;
- void setColor(){
-
+ void setColor(int x, int y, int z, int line){
}
void tempInit(float temp0, int x0, int y0, int z0){
for(int i=0; i<x0; i++){
@@ -61,8 +57,8 @@ class Temparray
for(int k=0; k<size[2]; k++){
for(int l=0; l<6; l++){
for(int m=0; m<4; m++){
- if(temperature[i, j, k, l, m] != -100){
- tempcache += temperature[i, j, k, l, m];
+ if(temperature[i*size[1]*size[2]*6*4 + j*size[2]*6*4 + k*6*4 + l*4 + m] != -100){
+ tempcache += temperature[i*size[1]*size[2]*6*4 + j*size[2]*6*4 + k*6*4 + l*4 + m];
++times;
}
}