Added projection setters and made constructors more uniform
This commit is contained in:
parent
785de6f1f6
commit
b1daa922ef
18
Camera.cpp
18
Camera.cpp
@ -153,7 +153,7 @@ OrthographicCamera::OrthographicCamera(
|
||||
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);
|
||||
setProjection(glm::ortho(_leftPlane, _rightPlane, _bottomPlane, _topPlane, _nearPlane, _farPlane));
|
||||
}
|
||||
|
||||
float OrthographicCamera::getLeftPlane() const { return _leftPlane; }
|
||||
@ -170,15 +170,15 @@ float OrthographicCamera::getFarPlane() const { return _farPlane; }
|
||||
|
||||
// PerspectiveCamera class
|
||||
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
|
||||
const Vec3& pos,
|
||||
const Vec3& tar,
|
||||
const Vec3& up ,
|
||||
float fov,
|
||||
float aspectRatio,
|
||||
float near,
|
||||
float 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));
|
||||
}
|
||||
|
||||
}
|
||||
@ -103,6 +103,7 @@ public:
|
||||
void setTopPlane(float);
|
||||
void setNearPlane(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:
|
||||
float _leftPlane, _rightPlane, _topPlane, _bottomPlane, _nearPlane, _farPlane;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user