+ #ifdef FLYING_CAMERA
+ switch (theKey)
+ {
+ case 'W':
+ case 'w':
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ eye.p[i] += eye.x[i];
+ break;
+ case 'S':
+ case 's':
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ eye.p[i] -= eye.x[i];
+ break;
+ case 'A':
+ case 'a':
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ eye.p[i] += eye.y[i];
+ break;
+ case 'D':
+ case 'd':
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ eye.p[i] -= eye.y[i];
+ break;
+ case 'Z':
+ case 'z':
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ eye.p[i] += eye.z[i];
+ break;
+ case 'C':
+ case 'c':
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ eye.p[i] -= eye.z[i];
+ break;
+
+ case 'I':
+ case 'i':
+ {
+ float theta = M_PI/80.0;
+ Camera old = eye;
+
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.z[i] = old.z[i] * cos(theta) + old.x[i] * sin(theta);
+ eye.x[i] = old.x[i] * cos(theta) - old.z[i] * sin(theta);
+ }
+ break;
+ }
+ case 'K':
+ case 'k':
+ {
+ float theta = -M_PI/80.0;
+ Camera old = eye;
+
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.z[i] = old.z[i] * cos(theta) + old.x[i] * sin(theta);
+ eye.x[i] = old.x[i] * cos(theta) - old.z[i] * sin(theta);
+ }
+ break;
+ }
+
+ case 'J':
+ case 'j':
+ {
+ float theta = -M_PI/80.0;
+ Camera old = eye;
+
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.y[i] = old.y[i] * cos(theta) + old.x[i] * sin(theta);
+ eye.x[i] = old.x[i] * cos(theta) - old.y[i] * sin(theta);
+ }
+ break;
+ }
+
+ case 'L':
+ case 'l':
+ {
+ float theta = M_PI/80.0;
+ Camera old = eye;
+
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.y[i] = old.y[i] * cos(theta) + old.x[i] * sin(theta);
+ eye.x[i] = old.x[i] * cos(theta) - old.y[i] * sin(theta);
+ }
+ break;
+ }
+
+ case 'Q':
+ case 'q':
+ {
+ float theta = M_PI/80.0;
+ Camera old = eye;
+
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.z[i] = old.z[i] * cos(theta) + old.y[i] * sin(theta);
+ eye.y[i] = old.y[i] * cos(theta) - old.z[i] * sin(theta);
+ }
+ break;
+ }
+ case 'E':
+ case 'e':
+ {
+ float theta = -M_PI/80.0;
+ Camera old = eye;
+
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.z[i] = old.z[i] * cos(theta) + old.y[i] * sin(theta);
+ eye.y[i] = old.y[i] * cos(theta) - old.z[i] * sin(theta);
+ }
+ break;
+ }
+ }
+
+ /*
+ float x = 0; float y = 0; float z = 0;
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ x += eye.x[i] * eye.x[i];
+ y += eye.y[i] * eye.y[i];
+ z += eye.z[i] * eye.z[i];
+ }
+ for (unsigned i = 0; i < DIMENSIONS; ++i)
+ {
+ eye.x[i] /= sqrt(x);
+ eye.y[i] /= sqrt(y);
+ eye.z[i] /= sqrt(z);
+ }
+ */
+ system("clear");
+ printf("Camera status:\n");
+ printf("Position: %f %f %f\n", eye.p[0], eye.p[1], eye.p[2]);
+ printf("x: %f %f %f (%f)\n", eye.x[0], eye.x[1], eye.x[2], sqrt(eye.x[0]*eye.x[0] + eye.x[1]*eye.x[1] + eye.x[2]*eye.x[2]));
+ printf("y: %f %f %f (%f)\n", eye.y[0], eye.y[1], eye.y[2], sqrt(eye.y[0]*eye.y[0] + eye.y[1]*eye.y[1] + eye.y[2]*eye.y[2]));
+ printf("z: %f %f %f (%f)\n", eye.z[0], eye.z[1], eye.z[2], sqrt(eye.z[0]*eye.z[0] + eye.z[1]*eye.z[1] + eye.z[2]*eye.z[2]));
+
+ #else
+
+
+