Screen shake working

This commit is contained in:
2015-10-23 14:26:08 +02:00
parent aa0aff9002
commit 9158dd8ef7
7 changed files with 39 additions and 28 deletions
+20 -2
View File
@@ -37,6 +37,7 @@
#include "Rendering/CModel.h"
#include "Rendering/CSprite.h"
#include "Rendering/CPointLight.h"
#include "Rendering/CCamera.h"
#include "Transform/TransformSystem.h"
#include "Sound/SoundSystem.h"
#include "Sound/CCollisionSound.h"
@@ -67,6 +68,7 @@
#include "Game/BrickComponents.h"
#include "Game/ScreenShakeSystem.h"
#include "Game/EScreenShake.h"
#include "Physics/PhysicsSystem.h"
@@ -147,6 +149,7 @@ public:
m_World->ComponentFactory.Register<Components::Sprite>();
m_World->ComponentFactory.Register<Components::Camera>();
m_World->ComponentFactory.Register<Components::RectangleShape>();
m_World->ComponentFactory.Register<Components::Physics>();
m_World->ComponentFactory.Register<Components::Ball>();
@@ -209,6 +212,9 @@ public:
m_World->SystemFactory.Register<Systems::LifeSystem>(
[this]() { return new Systems::LifeSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::LifeSystem>();
m_World->SystemFactory.Register<Systems::ScreenShakeSystem>(
[this]() { return new Systems::ScreenShakeSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::ScreenShakeSystem>();
m_World->ComponentFactory.Register<Components::Model>();
m_World->ComponentFactory.Register<Components::Template>();
@@ -271,8 +277,6 @@ public:
TEMPAddToRenderQueue();
}
std::unique_ptr<dd::Camera> defaultCamera = nullptr;
// Render scene
//TODO send renderqueue to draw.
m_Renderer->Draw(m_RendererQueue);
@@ -292,6 +296,20 @@ public:
{
if (!m_TransformSystem)
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
// HACK: How do we handle multiple cameras? Maybe view and projection matrices in render queue...
auto cameras = m_World->GetComponentsOfType<Components::Camera>();
if (cameras != nullptr) {
for (auto& component : *cameras) {
auto camera = static_cast<Components::Camera*>(component.get());
auto transform = m_World->GetComponent<Components::Transform>(camera->Entity);
m_Renderer->Camera()->SetPosition(transform->Position);
m_Renderer->Camera()->SetOrientation(transform->Orientation);
m_Renderer->Camera()->SetFOV(camera->FOV);
m_Renderer->Camera()->SetNearClip(camera->NearClip);
m_Renderer->Camera()->SetFarClip(camera->FarClip);
}
}
for (auto &pair : *m_World->GetEntities())
{