From 785de6f1f6000523d11ae3178e5e41a8b0a99312 Mon Sep 17 00:00:00 2001 From: NaifBanana <30419422+NaifBanana@users.noreply.github.com> Date: Fri, 22 Nov 2024 01:17:28 -0600 Subject: [PATCH] Added ortho cam getters --- Camera.cpp | 37 ++++++++++++++++++++++++------------- include/Camera.h | 14 ++++++++++++++ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Camera.cpp b/Camera.cpp index 4c74c14..74df939 100644 --- a/Camera.cpp +++ b/Camera.cpp @@ -156,18 +156,29 @@ OrthographicCamera::OrthographicCamera( _proj = glm::ortho(_leftPlane, _rightPlane, _bottomPlane, _topPlane, _nearPlane, _farPlane); } +float OrthographicCamera::getLeftPlane() const { return _leftPlane; } + +float OrthographicCamera::getRightPlane() const { return _rightPlane; } + +float OrthographicCamera::getBottomPlane() const { return _bottomPlane; } + +float OrthographicCamera::getTopPlane() const { return _topPlane; } + +float OrthographicCamera::getNearPlane() const { return _nearPlane; } + +float OrthographicCamera::getFarPlane() const { return _farPlane; } + // PerspectiveCamera class -/* PerspectiveCamera::PerspectiveCamera( - const Vec3& pos, - const Vec3& tar, - const Vec3& up, - float left, - float right, - float bottom, - float top, - float near, - float far -) : Camera(pos, tar, up), _leftPlane(left), _rightPlane(right), _bottomPlane(bottom), _topPlane(top), _nearPlane(near), _farPlane(far) { - _proj = glm::ortho(_leftPlane, _rightPlane, _bottomPlane, _topPlane, _nearPlane, _farPlane); -} */ +PerspectiveCamera::PerspectiveCamera( + const Vec3& pos=Vec3(1.0f, 0.0f, 0.0f), + const Vec3& tar=Vec3(0.0f, 0.0f, 0.0f), + const Vec3& up =Vec3(0.0f, 1.0f, 0.0f), + float fov = 45.0f, + float aspectRatio = 1.0f, + float near = -1.0f, + float far = 1.0f +) : Camera(pos, tar, up), _fov(fov), _ratio(aspectRatio), _nearPlane(near), _farPlane(far) { + _proj = glm::perspective(glm::radians(_fov), _ratio, _nearPlane, _farPlane); +} + } \ No newline at end of file diff --git a/include/Camera.h b/include/Camera.h index 4d68b2f..1336f28 100644 --- a/include/Camera.h +++ b/include/Camera.h @@ -90,6 +90,20 @@ public: float far = 1.0f ); + float getLeftPlane() const; + float getRightPlane() const; + float getBottomPlane() const; + float getTopPlane() const; + float getNearPlane() const; + float getFarPlane() const; + + void setLeftPlane(float); + void setRightPlane(float); + void setBottomPlane(float); + void setTopPlane(float); + void setNearPlane(float); + void setFarPlane(float); + private: float _leftPlane, _rightPlane, _topPlane, _bottomPlane, _nearPlane, _farPlane;