]> Dogcows Code - chaz/yoink/blobdiff - src/moof/camera.hh
the massive refactoring effort
[chaz/yoink] / src / moof / camera.hh
diff --git a/src/moof/camera.hh b/src/moof/camera.hh
new file mode 100644 (file)
index 0000000..b3aac0e
--- /dev/null
@@ -0,0 +1,86 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#ifndef _MOOF_CAMERA_HH_
+#define _MOOF_CAMERA_HH_
+
+/**
+ * \file camera.hh
+ * Classes related to managing the modelview and perspective matrices.
+ */
+
+#include <moof/event.hh>
+#include <moof/frustum.hh>
+#include <moof/math.hh>
+#include <moof/rigid_body.hh>
+
+
+namespace moof {
+
+
+class camera : public rigid_body3
+{
+public:
+
+       camera()
+       {
+               state_.init();
+               prev_state_.init();
+
+               quaternion_rotation_world_y(state_.orientation, SCALAR(0.0));
+       }
+
+       void position(const vector3& position);
+       void rotation(const quaternion& rotation);
+
+       void look_at(const vector3& point);
+
+       void projection(const matrix4& projection);
+       void projection(scalar fovy, scalar aspect, scalar near, scalar far);
+
+       const matrix4& modelview() const
+       {
+               return modelview_;
+       }
+
+       const matrix4& projection() const
+       {
+               return projection_;
+       }
+
+       const class frustum& frustum() const
+       {
+               return frustum_;
+       }
+
+
+       void upload_to_gl(scalar alpha = 0) const;
+
+       void update(scalar t, scalar dt);
+       void draw(scalar alpha = 0) const;
+       void handle_event(const event& event);
+
+
+private:
+
+       void calculate(scalar alpha) const;
+
+       mutable matrix4                 modelview_;
+       matrix4                                 projection_;
+
+       mutable class frustum   frustum_;
+};
+
+
+} // namespace moof
+
+#endif // _MOOF_CAMERA_HH_
+
This page took 0.022698 seconds and 4 git commands to generate.