X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fmoof%2Fcamera.hh;fp=src%2Fmoof%2Fcamera.hh;h=b3aac0e080cd06a00e1c8a9b87d10f8c71b9e667;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hp=0000000000000000000000000000000000000000;hpb=299af4f2047e767e5d79501c26444473bda64c64;p=chaz%2Fyoink diff --git a/src/moof/camera.hh b/src/moof/camera.hh new file mode 100644 index 0000000..b3aac0e --- /dev/null +++ b/src/moof/camera.hh @@ -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 +#include +#include +#include + + +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_ +