Rör på kameran!!! :D
This commit is contained in:
@@ -37,6 +37,15 @@ public:
|
|||||||
|
|
||||||
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
|
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
|
||||||
void ViewMatrix(glm::mat4 val) { m_ViewMatrix = val; }
|
void ViewMatrix(glm::mat4 val) { m_ViewMatrix = val; }
|
||||||
|
|
||||||
|
float FOV() const { return m_FOV; }
|
||||||
|
void FOV(float val) { m_FOV = val; }
|
||||||
|
|
||||||
|
float NearClip() const { return m_NearClip; }
|
||||||
|
void NearClip(float val) { m_NearClip = val; }
|
||||||
|
|
||||||
|
float FarClip() const { return m_FarClip; }
|
||||||
|
void FarClip(float val) { m_FarClip = val; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateProjectionMatrix();
|
void UpdateProjectionMatrix();
|
||||||
@@ -46,6 +55,7 @@ private:
|
|||||||
float m_AspectRatio;
|
float m_AspectRatio;
|
||||||
float m_NearClip;
|
float m_NearClip;
|
||||||
float m_FarClip;
|
float m_FarClip;
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 m_Position;
|
glm::vec3 m_Position;
|
||||||
glm::quat m_Orientation;
|
glm::quat m_Orientation;
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ namespace Components
|
|||||||
|
|
||||||
struct Camera : Component
|
struct Camera : Component
|
||||||
{
|
{
|
||||||
int FOV;
|
float FOV;
|
||||||
int NearClip;
|
float NearClip;
|
||||||
int FarClip;
|
float FarClip;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,11 +60,26 @@ void GameWorld::Initialize()
|
|||||||
//AddSystem("SoundSystem");
|
//AddSystem("SoundSystem");
|
||||||
AddSystem("RenderSystem");
|
AddSystem("RenderSystem");
|
||||||
|
|
||||||
EntityID ent = CreateEntity();
|
std::shared_ptr<Components::Transform> transform;
|
||||||
auto transform = AddComponent<Components::Transform>(ent, "Transform");
|
std::shared_ptr<Components::Model> model;
|
||||||
|
std::shared_ptr<Components::Camera> camera;
|
||||||
|
EntityID ent;
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
auto model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model->ModelFile = "ship.obj";
|
model->ModelFile = "ship.obj";
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
|
SetProperty(ent, "Name", "Camera");
|
||||||
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transform->Position = glm::vec3(0.f, 0.f, 10.f);
|
||||||
|
camera = AddComponent<Components::Camera>(ent, "Camera");
|
||||||
|
camera->FOV = 45.f;
|
||||||
|
camera->FarClip = 1000.f;
|
||||||
|
camera->NearClip = 0.01f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWorld::RegisterSystems()
|
void GameWorld::RegisterSystems()
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ void Renderer::Initialize()
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
// Create Camera
|
// Create Camera
|
||||||
|
|
||||||
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
|
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
|
||||||
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
|
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
|||||||
{
|
{
|
||||||
m_Renderer->GetCamera()->Position(transformComponent->Position);
|
m_Renderer->GetCamera()->Position(transformComponent->Position);
|
||||||
m_Renderer->GetCamera()->Orientation(transformComponent->Orientation);
|
m_Renderer->GetCamera()->Orientation(transformComponent->Orientation);
|
||||||
|
|
||||||
|
m_Renderer->GetCamera()->FOV(cameraComponent->FOV);
|
||||||
|
m_Renderer->GetCamera()->NearClip(cameraComponent->NearClip);
|
||||||
|
m_Renderer->GetCamera()->FarClip(cameraComponent->FarClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user