1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#include "DisplayClass.h"
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;
//tree = new BSPTree(triangles);
}
DisplayClass::~DisplayClass() {
//delete tree;
}
void DisplayClass::renderScene(unsigned long delta, std::bitset<256>& keys) {
/*angle += delta*0.025;
if(angle >= 360)
angle -= 360;*/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Clean up matrix
glTranslatef(0.0, -2.0, -20.0); // Then set up transformation
// glRotatef(10, 1.0, 0.0, 0.0);
// glRotatef(angle, 0.0, 1.0, 0.0);
// glRotatef(angle*2, 1.0, 0.0, 0.0);
// glRotatef(angle*3, 0.0, 0.0, 1.0);
// glRotatef(-angle*5, 1.0, 1.0, 1.0);
// static Temparray temp(20, x, y, z);
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();
//vmml::mat4f transform, inverseTransform;
//glGetFloatv(GL_MODELVIEW_MATRIX, transform.array);
//transform.inverse(inverseTransform);
//vmml::vec3f viewPoint = inverseTransform*vmml::vec3f::ZERO;
glBegin(GL_TRIANGLES);
//tree->visit(render, viewPoint);
for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
render(*t);
}
glEnd();
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(h))
glRotatef(3, 1, 0, 0);
h = '4';
if(keys.test(h))
glRotatef(-3, 0, 1, 0);
h = '6';
if(keys.test(h))
glRotatef(3, 0, 1, 0);
h = '8';
if(keys.test(h))
glRotatef(-3, 1, 0, 0);
h = '+';
if(keys.test(h))
abstand -= 0.2;
h = '-';
if(keys.test(h))
abstand += 0.2;
glMultMatrixf(rotm);
glGetFloatv(GL_MODELVIEW_MATRIX, rotm);
glLoadIdentity();
glTranslatef(0, 0, abstand);
glMultMatrixf(rotm);
// glutPostRedisplay();
}
}
|