X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FCamera.cc;h=cdebc7a7b735b7e681e3b28f041f576aa9166d7f;hp=26e24ba358fbfd7494517a66409e75c5150f8b59;hb=72d4af22710317acffab861421c4364b1780b6fe;hpb=493ddb59a8620b49dfa0ff62ce93395ebfd02e86 diff --git a/src/Moof/Camera.cc b/src/Moof/Camera.cc index 26e24ba..cdebc7a 100644 --- a/src/Moof/Camera.cc +++ b/src/Moof/Camera.cc @@ -28,6 +28,7 @@ #include #include +#include namespace Mf { @@ -35,31 +36,47 @@ namespace Mf { void Camera::setPosition(const Vector3& point) { - //position_ = point; - Vector3 coeff[2] = {position_, point}; - pInterp_.init(coeff, 0.1); + position_ = point; + //Vector3 coeff[2] = {position_, point}; + //pInterp_.init(coeff, 0.1); } void Camera::setRotation(const Quaternion& rotation) { rotation_ = rotation; - //srcRotation_ = rotation_; - //dstRotation_ = rotation; - //tInterp_ = 0.0; } -void Camera::update(Scalar t, Scalar dt) + +void Camera::setProjection(const Matrix4& projection) { - pInterp_.update(dt); - position_ = pInterp_.getState(0.0); + projection_ = projection; +} - //tInterp_ += dt * 10.0; - //rotation_ = cml::slerp(srcRotation_, dstRotation_, cml::clamp(tInterp_, 0.0, 1.0)); - //rotation_.normalize(); +void Camera::setProjection(Scalar fovy, Scalar aspect, Scalar near, Scalar far) +{ + cml::matrix_perspective_yfov_RH(projection_, fovy, aspect, near, far, + cml::z_clip_neg_one); calculateSecondary(); } +void Camera::uploadProjectionToGL() const +{ + glMatrixMode(GL_PROJECTION); + glLoadMatrix(projection_.data()); + + glMatrixMode(GL_MODELVIEW); +} + +void Camera::update(Scalar t, Scalar dt) +{ + //pInterp_.update(dt); + //position_ = pInterp_.getState(0.0); + + //calculateSecondary(); +} + + void Camera::lookAt(const Vector3& point) { quaternion_rotation_aim_at(rotation_, position_, point); @@ -150,13 +167,15 @@ void Camera::adjustFromInput(const Event& event) void Camera::calculateSecondary() { - matrix_rotation_quaternion(transformation_, rotation_); + matrix_rotation_quaternion(modelview_, rotation_); Matrix4 translate; matrix_translation(translate, position_); - //transformation_ = translate * transformation_; - transformation_ *= translate; + //modelview_ = translate * modelview_; + modelview_ *= translate; + + frustum_.init(modelview_, projection_); }