~ | Camera FOV and Bounce

This commit is contained in:
TheRedShip
2025-01-11 01:37:25 +01:00
parent b19b50c60b
commit 5c4819738a
8 changed files with 163 additions and 21 deletions

View File

@ -100,19 +100,23 @@ glm::vec2 Camera::getDirection()
return (glm::vec2(_pitch, _yaw));
}
glm::vec2 Camera::getDOV()
glm::vec3 Camera::getViewSetting()
{
return (glm::vec2(_aperture_size, _focus_distance));
return (glm::vec3(_aperture_size, _focus_distance, _fov));
}
GPUCamera Camera::getGPUData()
{
GPUCamera data;
data.view_matrix = getViewMatrix();
data.camera_position = _position;
data.aperture_size = _aperture_size;
data.focus_distance = _focus_distance;
data.camera_position = _position;
data.view_matrix = getViewMatrix();
data.fov = _fov;
data.bounce = _bounce;
return (data);
}
@ -122,6 +126,11 @@ float Camera::getVelocity()
return (glm::length(_velocity));
}
int Camera::getBounce()
{
return (_bounce);
}
void Camera::setPosition(glm::vec3 position)
{
_position = position;
@ -137,4 +146,14 @@ void Camera::setDOV(float aperture, float focus)
{
_aperture_size = aperture;
_focus_distance = focus;
}
void Camera::setBounce(int bounce)
{
_bounce = bounce;
}
void Camera::setFov(float fov)
{
_fov = fov;
}

View File

@ -93,7 +93,8 @@ void SceneParser::parseCamera(std::stringstream &line)
{
float x,y,z;
float yaw, pitch;
float aperture, focus;
float aperture, focus, fov;
int bounce;
if (!(line >> x >> y >> z))
throw std::runtime_error("Camera: Missing camera properties");
@ -104,17 +105,25 @@ void SceneParser::parseCamera(std::stringstream &line)
pitch = -90;
}
if (!(line >> aperture >> focus))
if (!(line >> aperture >> focus >> fov))
{
aperture = 0.0;
focus = 1.0;
fov = 90.0f;
}
if (!(line >> bounce))
bounce = 5;
_scene->getCamera()->setPosition(glm::vec3(x, y, z));
_scene->getCamera()->setDirection(yaw, pitch);
_scene->getCamera()->setDOV(aperture, focus);
_scene->getCamera()->updateCameraVectors();
_scene->getCamera()->setDOV(aperture, focus);
_scene->getCamera()->setFov(fov);
_scene->getCamera()->setBounce(bounce);
}
bool SceneParser::parseLine(const std::string &line)

View File

@ -113,11 +113,12 @@ void Window::keyCallback(GLFWwindow *window, int key, int scancode, int action,
{
glm::vec3 pos = win->_scene->getCamera()->getPosition();
glm::vec2 dir = win->_scene->getCamera()->getDirection();
glm::vec2 dov = win->_scene->getCamera()->getDOV();
glm::vec3 settings = win->_scene->getCamera()->getViewSetting();
int bounce = win->_scene->getCamera()->getBounce();
std::cout << "\nCAM\t" << pos.x << " " << pos.y << " " << pos.z << "\t"
<< dir.x << " " << dir.y << " " << "\t"
<< dov.x << " " << dov.y << " " << "\t"
<< settings.x << " " << settings.y << " " << settings.z << "\t" << bounce
<< std::endl;
}
}