-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcamera.cpp
42 lines (35 loc) · 1.11 KB
/
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
#include "camera.h"
Camera::Camera( void )
{}
Camera::Camera( const glm::ivec2 &resolution,
const glm::vec3 &position,
const glm::vec3 &up,
const glm::vec3 &look_at ) :
resolution_{ resolution },
up_{ up },
look_at_{ look_at },
position_{ position },
direction_{ glm::normalize( look_at - position ) }
{
// Sets up the camera's ONB.
onb_.setFromUW( glm::normalize( glm::cross( up_, -direction_ ) ), -direction_ );
}
Camera::~Camera( void )
{}
void Camera::setPosition( const glm::vec3 &position )
{
position_ = position;
direction_ = glm::normalize( look_at_ - position_ );
onb_.setFromUW( glm::normalize( glm::cross( up_, -direction_ ) ), -direction_ );
}
void Camera::setUp( const glm::vec3 &up )
{
up_ = up;
onb_.setFromUW( glm::normalize( glm::cross( up_, -direction_ ) ), -direction_ );
}
void Camera::setLookAt( const glm::vec3 &look_at )
{
look_at_ = look_at;
direction_ = glm::normalize( look_at_ - position_ );
onb_.setFromUW( glm::normalize( glm::cross( up_, -direction_ ) ), -direction_ );
}