#include "camera.h" namespace CameraControls { void TranslateCamera(Camera& camera, const glm::vec3& translationDelta) { TransformControls::Translate(camera.transform, translationDelta); } void RotateCamera(Camera& camera, const glm::vec3& rotationDelta) { TransformControls::Rotate(camera.transform, rotationDelta); } void SetPosition(Camera& camera, const glm::vec3& position) { TransformControls::SetPosition(camera.transform, position); } void SetRotation(Camera& camera, const glm::vec3& rotation) { TransformControls::SetRotation(camera.transform, rotation); } glm::vec3 GetPosition(Camera& camera) { return camera.transform.translation; } glm::vec3 GetRotation(Camera& camera) { return camera.transform.rotation; } glm::vec3 GetCenter(Camera& camera) { glm::vec3 forward; forward.x = cos(camera.transform.rotation.y) * cos(camera.transform.rotation.x); forward.y = sin(camera.transform.rotation.x); forward.z = sin(camera.transform.rotation.y) * cos(camera.transform.rotation.x); return GetPosition(camera) + GetRotation(camera); } float GetFOV(Camera& camera) { return 2.0f * atan(camera.sensorHeight / (2.0f * camera.focalLength)); } void AdjustFocalLength(Camera& camera, float focalLength) { camera.focalLength = focalLength; } void AdjustSensorHeight(Camera& camera, float sensorHeight) { camera.sensorHeight = sensorHeight; } void AdjustNearPlane(Camera& camera, float nearPlane) { camera.nearPlane = nearPlane; } void AdjustFarPlane(Camera& camera, float farPlane) { camera.farPlane = farPlane; } glm::mat4 GetViewMatrix(Camera& camera) { //return glm::lookAt(glm::vec3(0.0f, 1.4f, 1.4f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); return glm::lookAt(GetPosition(camera), GetCenter(camera), glm::vec3(0.0f, 1.0f, 0.0f)); } }