--- a/src/scene.h Mon Nov 26 23:12:40 2007 +0100
+++ b/src/scene.h Thu Nov 29 18:30:16 2007 +0100
@@ -24,6 +24,40 @@
o(ao), dir(adir) {};
};
+class Quaternion
+{
+public:
+ float a,b,c,d;
+ Quaternion(): a(0), b(0), c(0), d(0) {};
+ Quaternion(const float aa, const float ab, const float ac, const float ad):
+ a(aa), b(ab), c(ac), d(ad) {};
+ Quaternion(const Vector3& v): a(1), b(v.x), c(v.y), d(v.z) {};
+
+ Vector3 toVector() { return Vector3(b/a, c/a, d/a); };
+
+ Quaternion normalize()
+ {
+ float f = 1.0f / sqrtf(a * a + b * b + c * c + d * d);
+ a *= f;
+ b *= f;
+ c *= f;
+ d *= f;
+ return *this;
+ };
+ friend Quaternion operator*(const Quaternion &q1, const Quaternion &q2)
+ {
+ return Quaternion(
+ q1.a*q2.a - q1.b*q2.b - q1.c*q2.c - q1.d*q2.d,
+ q1.a*q2.b + q1.b*q2.a + q1.c*q2.d - q1.d*q2.c,
+ q1.a*q2.c + q1.c*q2.a + q1.d*q2.b - q1.b*q2.d,
+ q1.a*q2.d + q1.d*q2.a + q1.b*q2.c - q1.c*q2.b);
+ };
+ friend Quaternion conjugate(const Quaternion &q)
+ {
+ return Quaternion(q.a, -q.b, -q.c, -q.d);
+ }
+};
+
class Camera
{
public:
@@ -34,7 +68,9 @@
Camera(const Vector3 &C, const Vector3 &ap, const Vector3 &au, const Vector3 &av):
eye(C), p(ap), u(au), v(av), f(3.14/4.0) {};
void setEye(const Vector3 &aeye) { eye = aeye; };
- void setFocusLength(const float af) { f = af; };
+ void setFocalLength(const float af) { f = af; };
+ void rotate(const Quaternion &q);
+ void move(const float fw, const float left, const float up);
};
/* axis-aligned bounding box */
@@ -90,8 +126,8 @@
texture.colour = acolour;
ambient = 0.1;
diffuse = 0.5;
- specular = 1.0;
- shininess = 20.0;
+ specular = 0.1;
+ shininess = 0.5;
reflection = 0.5;
}
};