-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
20 changed files
with
143 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
#include "camera.h" | ||
|
||
ce::Camera::Camera() | ||
:m_transform(NULL) | ||
{ | ||
: m_transform(NULL) { | ||
m_transform = new Transform(); | ||
} | ||
|
||
ce::Camera::~Camera() | ||
{ | ||
ce::Camera::~Camera() { | ||
delete m_transform; | ||
} | ||
|
||
glm::mat4 ce::Camera::getView() | ||
{ | ||
glm::mat4 ce::Camera::getView() { | ||
glm::vec3 | ||
pos = m_transform->getPosition(), | ||
forward = m_transform->getForward(); | ||
return glm::lookAt(pos,pos+forward,ce::Transform::GetGlobalUp()); | ||
return glm::lookAt(pos, pos + forward, ce::Transform::GetGlobalUp()); | ||
} | ||
|
||
glm::vec3 ce::Camera::getRight() | ||
{ | ||
glm::vec3 ce::Camera::getRight() { | ||
glm::vec3 | ||
forward = m_transform->getForward(), | ||
up = ce::Transform::GetGlobalUp(); | ||
return glm::normalize(glm::cross(forward,up)); | ||
return glm::normalize(glm::cross(forward, up)); | ||
} | ||
|
||
void ce::Camera::sendToShader(ce::Shader* shader) | ||
{ | ||
shader->setMat4("transform.view",getView()); | ||
void ce::Camera::sendToShader(ce::Shader* shader) { | ||
shader->setMat4("transform.view", getView()); | ||
} | ||
|
||
void ce::Camera::boundPitch() | ||
{ | ||
void ce::Camera::boundPitch() { | ||
float cameraPitch = m_transform->getPitch(); | ||
if (cameraPitch > 89.9f) // TODO: fix broken 90 degree pitch | ||
cameraPitch = 89.9f; | ||
if (cameraPitch < -89.9f) | ||
cameraPitch = -89.9f; | ||
m_transform->setPitch(cameraPitch); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.