summaryrefslogtreecommitdiffstats
path: root/DisplayClass.cpp
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-02-10 22:30:18 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-02-10 22:30:18 +0100
commit22b2912bbdd637c1a206b30f7d02c8e560ff9850 (patch)
tree33889a87dc0bce5e5380d0d88b95c9fb623b7685 /DisplayClass.cpp
parent897a54945c4a9112ee5c97e2eb8937adc57f17fe (diff)
downloadc3d-22b2912bbdd637c1a206b30f7d02c8e560ff9850.tar
c3d-22b2912bbdd637c1a206b30f7d02c8e560ff9850.zip
veränderungen
Diffstat (limited to 'DisplayClass.cpp')
-rw-r--r--DisplayClass.cpp116
1 files changed, 56 insertions, 60 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index b34156b..a031946 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -2,13 +2,8 @@
DisplayClass::Renderer DisplayClass::render;
-DisplayClass::DisplayClass(int x, int y, int z) : angle(0) {
-
-// Temparray temp(20, x, y, z);
-// triangles=temp.getTriangles();
-this->x=x;
-this->y=y;
-this->z=z;
+DisplayClass::DisplayClass(int x0, int y0, int z0) : angleY(0), angleX(0), distance(20),
+ x(x0), y(y0), z(z0) {
//tree = new BSPTree(triangles);
}
@@ -16,26 +11,22 @@ DisplayClass::~DisplayClass() {
//delete tree;
}
-void DisplayClass::renderScene(unsigned long delta, std::bitset<256>& keys) {
- angle += delta*0.005;
- if(angle >= 360)
- angle -= 360;
+void DisplayClass::renderScene(unsigned long delta, const Keyset &keys) {
+ handleKeys(delta, keys);
- static bool on = true;
+ /*static bool on = true;
static float angle2 =5;
if (angle2 <= 10 && on){angle2 += 0.5;}
else if (angle2 >=0 && !on){angle2 -= 0.5;}
else if (angle2 >=10)on=false;
- else if (angle2 <=0)on=true;
+ else if (angle2 <=0)on=true;*/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-// keyhandler(keys);
-
glLoadIdentity(); // Clean up matrix
- glTranslatef(0.0, -2.0, -12.0); // Then set up transformation
- glRotatef(angle2, 1.0, 0.0, 0.0);
- glRotatef(angle, 0.0, 1.0, 0.0);
+ glTranslatef(0.0, -distanceh, -distance); // Then set up transformation
+ glRotatef(angleX, 1.0, 0.0, 0.0);
+ glRotatef(angleY, 0.0, 1.0, 0.0);
// glRotatef(angle*2, 1.0, 0.0, 0.0);
// glRotatef(angle*3, 1.0, 0.5, 0.0);
// glRotatef(-angle*5, 1.0, 1.0, 0.0);
@@ -45,7 +36,7 @@ void DisplayClass::renderScene(unsigned long delta, std::bitset<256>& keys) {
static House house(20, x, y, z, 100, 400, 53.55, 0.82, 2.82, 0.0047, 40, 45, 1900, 3, 11500);
triangles=house.getTriangles();
house.controller();
-//// temp.calcTemp();
+// temp.calcTemp();
//vmml::mat4f transform, inverseTransform;
//glGetFloatv(GL_MODELVIEW_MATRIX, transform.array);
@@ -65,46 +56,51 @@ void DisplayClass::renderScene(unsigned long delta, std::bitset<256>& keys) {
glFlush();
}
-void DisplayClass::keyhandler(std::bitset<256>& keys){
- static float abstand = 0;
- if(keys.any()) {
- glLoadIdentity();
-
- static float rotm[16] = {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1};
- char h = '2';
- if(keys.test(50))
- glRotatef(3, 1, 0, 0);
-
- h = '4';
- if(keys.test(52))
- glRotatef(-3, 0, 1, 0);
-
- h = '6';
- if(keys.test(54))
- glRotatef(3, 0, 1, 0);
-
- h = '8';
- if(keys.test(56))
- glRotatef(-3, 1, 0, 0);
-
- h = '+';
- if(keys.test(43))
- abstand -= 0.2;
-
- h = '-';
- if(keys.test(45))
- abstand += 0.2;
-
- glMultMatrixf(rotm);
- glGetFloatv(GL_MODELVIEW_MATRIX, rotm);
-
- glLoadIdentity();
- glTranslatef(0, 0, abstand);
- glMultMatrixf(rotm);
-// glutPostRedisplay();
+void DisplayClass::handleKeys(unsigned long delta, const Keyset &keys) {
+ /*angle += delta*0.005;
+ if(angle >= 360)
+ angle -= 360;*/
+
+ if(keys.test(KEY_UP)) {
+ angleX += 0.005*delta;
+ }
+
+ if(keys.test(KEY_DOWN)) {
+ angleX -= 0.005*delta;
+ }
+
+ if(keys.test(KEY_LEFT)) {
+ angleY += 0.005*delta;
+ }
+
+ if(keys.test(KEY_RIGHT)) {
+ angleY -= 0.005*delta;
}
+
+ if(keys.test(KEY_ZOOM_IN)) {
+ distance -= 0.005*delta;
+ }
+
+ if(keys.test(KEY_ZOOM_OUT)) {
+ distance += 0.005*delta;
+ }
+
+ if(keys.test(KEY_TOP)) {
+ distanceh -= 0.0005*delta;
+ }
+
+ if(keys.test(KEY_BOTTOM)) {
+ distanceh += 0.0005*delta;
+ }
+
+
+ if(angleX >= 360)
+ angleX -= 360;
+ else if(angleX < 0)
+ angleX += 360;
+
+ if(angleY >= 360)
+ angleY -= 360;
+ else if(angleY < 0)
+ angleY += 360;
}