-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.cpp
44 lines (35 loc) · 953 Bytes
/
Camera.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Camera.h"
const kmuvcl::math::vec3f Camera::center_position() const
{
kmuvcl::math::vec3f center_position(position_(0) + front_dir_(0),
position_(1) + front_dir_(1),
position_(2) + front_dir_(2));
return center_position;
}
// TODO: fill up the following functions properly
void Camera::move_forward(float delta)
{
position_ += delta * front_dir_;
}
void Camera::move_backward(float delta)
{
position_ -= delta * front_dir_;
}
void Camera::move_left(float delta)
{
position_ -= delta * right_dir_;
}
void Camera::move_right(float delta)
{
position_ += delta * right_dir_;
}
void Camera::rotate_left(float delta)
{
front_dir_ -= delta * right_dir_;
right_dir_ = kmuvcl::math::cross(front_dir_, up_dir_);
}
void Camera::rotate_right(float delta)
{
front_dir_ += delta * right_dir_;
right_dir_ = kmuvcl::math::cross(front_dir_, up_dir_);
}