Added getters for camera properties
Added world translation for camera Renamed previous translation to local_translate
This commit is contained in:
parent
9a52587149
commit
9568b54b87
3 changed files with 34 additions and 8 deletions
|
@ -36,30 +36,30 @@ void manage_inputs()
|
|||
if (InputStatus::is_special_key_pressed(GLUT_KEY_RIGHT))
|
||||
{
|
||||
timer_ticks += 5;
|
||||
OGLE::camera.translate({0,0,0.1});
|
||||
OGLE::camera.local_translate({0, 0, 0.1});
|
||||
}
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_LEFT))
|
||||
{
|
||||
timer_ticks -= 5;
|
||||
OGLE::camera.translate({0,0,-0.1});
|
||||
OGLE::camera.local_translate({0, 0, -0.1});
|
||||
}
|
||||
if (InputStatus::is_key_pressed(' '))
|
||||
{
|
||||
OGLE::camera.translate({0,0.1,0});
|
||||
OGLE::camera.local_translate({0, 0.1, 0});
|
||||
}
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_PAGE_DOWN))
|
||||
{
|
||||
OGLE::camera.translate({0,-0.1,0});
|
||||
OGLE::camera.local_translate({0, -0.1, 0});
|
||||
}
|
||||
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_UP))
|
||||
{
|
||||
OGLE::camera.translate({0.1,0,0});
|
||||
OGLE::camera.local_translate({0.1, 0, 0});
|
||||
}
|
||||
|
||||
if (InputStatus::is_special_key_pressed(GLUT_KEY_DOWN))
|
||||
{
|
||||
OGLE::camera.translate({-0.1,0,0});
|
||||
OGLE::camera.local_translate({-0.1, 0, 0});
|
||||
}
|
||||
|
||||
// Get mouse delta since last frame
|
||||
|
|
|
@ -17,7 +17,11 @@ Camera::Camera(const Vec3d& eye_pos, const Vec3d& look_direction, const Vec3d& u
|
|||
compute_base_change();
|
||||
}
|
||||
|
||||
void Camera::translate(const Vec3d& translation)
|
||||
void Camera::translate(const Vec3d &translation) {
|
||||
eye = eye + translation;
|
||||
}
|
||||
|
||||
void Camera::local_translate(const Vec3d& translation)
|
||||
{
|
||||
eye = eye + translation * rotation_quaternion;
|
||||
}
|
||||
|
@ -55,6 +59,21 @@ void Camera::set_position(const Vec3d& eye_pos)
|
|||
gaze = eye_pos;
|
||||
}
|
||||
|
||||
const Vec3d& Camera::get_eyepos() const
|
||||
{
|
||||
return eye;
|
||||
}
|
||||
|
||||
const Vec3d& Camera::get_gaze() const
|
||||
{
|
||||
return gaze;
|
||||
}
|
||||
|
||||
const Vec3d& Camera::get_gazeup() const
|
||||
{
|
||||
return gaze_up;
|
||||
}
|
||||
|
||||
void Camera::compute_base_change()
|
||||
{
|
||||
// Third vector of the base, should already be normalized
|
||||
|
|
|
@ -15,9 +15,12 @@ class Camera {
|
|||
public:
|
||||
Camera(const Vec3d& eye_pos,const Vec3d& look_direction,const Vec3d& up_vector);
|
||||
|
||||
/// Translates the camera according to the world axises.
|
||||
/// \param translation Translation in the world coordinates system.
|
||||
void translate(const Vec3d& translation);
|
||||
/// Translates the camera relative to its current position and look direction.
|
||||
/// \param translation Translation where x is pointing in the direction of vision.
|
||||
void translate(const Vec3d& translation);
|
||||
void local_translate(const Vec3d& translation);
|
||||
/// Rotates the gaze around its local x and z but around global y, relatively to the current orientation.
|
||||
/// This is to provide a coherent movement in regards to mouse movement.
|
||||
/// \param rotation Angles are radians to rotate about each axis.
|
||||
|
@ -27,6 +30,10 @@ public:
|
|||
void look();
|
||||
|
||||
void set_position(const Vec3d& eye_pos);
|
||||
|
||||
const Vec3d& get_eyepos() const;
|
||||
const Vec3d& get_gaze() const;
|
||||
const Vec3d& get_gazeup() const;
|
||||
private:
|
||||
Vec3d eye;
|
||||
Vec3d gaze;
|
||||
|
|
Loading…
Add table
Reference in a new issue