-
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.
- Loading branch information
Showing
7 changed files
with
168 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "camera.h" | ||
|
||
ce::Camera::Camera() | ||
:m_transform(NULL) | ||
{ | ||
m_transform = new Transform(); | ||
} | ||
|
||
ce::Camera::~Camera() | ||
{ | ||
delete m_transform; | ||
} | ||
|
||
glm::mat4 ce::Camera::getView() | ||
{ | ||
glm::vec3 | ||
pos = m_transform->getPosition(), | ||
forward = m_transform->getForward(); | ||
return glm::lookAt(pos,pos+forward,ce::Transform::getGloablUp()); | ||
} | ||
|
||
glm::vec3 ce::Camera::getRight() | ||
{ | ||
glm::vec3 | ||
forward = m_transform->getForward(), | ||
up = ce::Transform::getGloablUp(); | ||
return glm::normalize(glm::cross(forward,up)); | ||
} | ||
|
||
void ce::Camera::sendToShader(ce::Shader* shader) | ||
{ | ||
shader->setMat4("transform.view",getView()); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef _CE_CAMERA_H_ | ||
#define _CE_CAMERA_H_ | ||
|
||
#include <math/transform.h> | ||
|
||
namespace ce { | ||
class Camera { | ||
private: | ||
ce::Transform* m_transform; | ||
float speed, | ||
fov; | ||
public: | ||
Camera(); | ||
~Camera(); | ||
|
||
glm::mat4 getView(); | ||
glm::vec3 getRight(); | ||
void sendToShader(ce::Shader* shader); | ||
Transform* getTransform(){return m_transform;} | ||
}; | ||
} | ||
|
||
#endif //_CE_CAMERA_H_ |