Added projection setters and made constructors more uniform

This commit is contained in:
NaifBanana 2024-11-22 01:21:41 -06:00
parent 785de6f1f6
commit b1daa922ef
2 changed files with 10 additions and 9 deletions

View File

@ -153,7 +153,7 @@ OrthographicCamera::OrthographicCamera(
float near, float near,
float far float far
) : Camera(pos, tar, up), _leftPlane(left), _rightPlane(right), _bottomPlane(bottom), _topPlane(top), _nearPlane(near), _farPlane(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); setProjection(glm::ortho(_leftPlane, _rightPlane, _bottomPlane, _topPlane, _nearPlane, _farPlane));
} }
float OrthographicCamera::getLeftPlane() const { return _leftPlane; } float OrthographicCamera::getLeftPlane() const { return _leftPlane; }
@ -170,15 +170,15 @@ float OrthographicCamera::getFarPlane() const { return _farPlane; }
// PerspectiveCamera class // PerspectiveCamera class
PerspectiveCamera::PerspectiveCamera( PerspectiveCamera::PerspectiveCamera(
const Vec3& pos=Vec3(1.0f, 0.0f, 0.0f), const Vec3& pos,
const Vec3& tar=Vec3(0.0f, 0.0f, 0.0f), const Vec3& tar,
const Vec3& up =Vec3(0.0f, 1.0f, 0.0f), const Vec3& up ,
float fov = 45.0f, float fov,
float aspectRatio = 1.0f, float aspectRatio,
float near = -1.0f, float near,
float far = 1.0f float far
) : Camera(pos, tar, up), _fov(fov), _ratio(aspectRatio), _nearPlane(near), _farPlane(far) { ) : Camera(pos, tar, up), _fov(fov), _ratio(aspectRatio), _nearPlane(near), _farPlane(far) {
_proj = glm::perspective(glm::radians(_fov), _ratio, _nearPlane, _farPlane); setProjection(glm::perspective(glm::radians(_fov), _ratio, _nearPlane, _farPlane));
} }
} }

View File

@ -103,6 +103,7 @@ public:
void setTopPlane(float); void setTopPlane(float);
void setNearPlane(float); void setNearPlane(float);
void setFarPlane(float); void setFarPlane(float);
void setOrthographicProjection(float left=-1.0, float right=1.0, float bottom=-1.0, float top=1.0, float near=-1.0, float far=1.0);
private: private:
float _leftPlane, _rightPlane, _topPlane, _bottomPlane, _nearPlane, _farPlane; float _leftPlane, _rightPlane, _topPlane, _bottomPlane, _nearPlane, _farPlane;