Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn

This commit is contained in:
Tobias Dahl
2014-03-10 00:50:04 +01:00
7 changed files with 53 additions and 13 deletions
+10
View File
@@ -37,6 +37,15 @@ public:
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
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:
void UpdateProjectionMatrix();
@@ -46,6 +55,7 @@ private:
float m_AspectRatio;
float m_NearClip;
float m_FarClip;
glm::vec3 m_Position;
glm::quat m_Orientation;
+3 -3
View File
@@ -8,9 +8,9 @@ namespace Components
struct Camera : Component
{
int FOV;
int NearClip;
int FarClip;
float FOV;
float NearClip;
float FarClip;
};
}
+18 -3
View File
@@ -60,11 +60,26 @@ void GameWorld::Initialize()
//AddSystem("SoundSystem");
AddSystem("RenderSystem");
EntityID ent = CreateEntity();
auto transform = AddComponent<Components::Transform>(ent, "Transform");
std::shared_ptr<Components::Transform> 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);
auto model = AddComponent<Components::Model>(ent, "Model");
model = AddComponent<Components::Model>(ent, "Model");
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()
+1
View File
@@ -42,6 +42,7 @@ void Renderer::Initialize()
glEnable(GL_DEPTH_TEST);
// Create Camera
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));
+20 -7
View File
@@ -12,18 +12,31 @@ void Systems::RenderSystem::OnComponentCreated( std::string type, std:: shared_p
void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
{
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
if (modelComponent == nullptr)
return;
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
if (transformComponent == nullptr)
return;
auto modelComponent = m_World->GetComponent<Components::Model>(entity, "Model");
if (modelComponent != nullptr)
{
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()){
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
}
if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()) {
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
Model* model = m_CachedModels[modelComponent->ModelFile];
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
}
Model* model = m_CachedModels[modelComponent->ModelFile];
m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
auto cameraComponent = m_World->GetComponent<Components::Camera>(entity, "Camera");
if (cameraComponent != nullptr)
{
m_Renderer->GetCamera()->Position(transformComponent->Position);
m_Renderer->GetCamera()->Orientation(transformComponent->Orientation);
m_Renderer->GetCamera()->FOV(cameraComponent->FOV);
m_Renderer->GetCamera()->NearClip(cameraComponent->NearClip);
m_Renderer->GetCamera()->FarClip(cameraComponent->FarClip);
}
}
+1
View File
@@ -6,6 +6,7 @@
#include "Texture.h"
#include "Components/Model.h"
#include "Components/Transform.h"
#include "Components/Camera.h"
#include "Renderer.h"
#include <unordered_map>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 879 KiB

After

Width:  |  Height:  |  Size: 69 KiB