Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
Conflicts: Escape-the-Dawn/Systems/SoundsSystem.cpp
This commit is contained in:
@@ -21,8 +21,9 @@ void Systems::InputSystem::Update(double dt)
|
||||
glfwGetCursorPos(m_Renderer->GetWindow(), &xpos, &ypos);
|
||||
m_CurrentMouseDeltaX = xpos - m_LastMouseX;
|
||||
m_CurrentMouseDeltaY = ypos - m_LastMouseY;
|
||||
m_LastMouseX = xpos;
|
||||
m_LastMouseY = ypos;
|
||||
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
|
||||
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
|
||||
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
|
||||
}
|
||||
|
||||
void Systems::InputSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "PlayerSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
|
||||
|
||||
void Systems::PlayerSystem::Update(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
||||
if (transform == nullptr)
|
||||
return;
|
||||
auto input = m_World->GetComponent<Components::Input>(entity, "Input");
|
||||
if (input == nullptr)
|
||||
return;
|
||||
|
||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||
if (name == "Camera") {
|
||||
|
||||
glm::vec3 Camera_Right = glm::rotate(transform->Orientation, glm::vec3(1, 0, 0));
|
||||
glm::vec3 Camera_Forward = glm::rotate(transform->Orientation, glm::vec3(0, 0, 1));
|
||||
|
||||
|
||||
float speed = 4.0f;
|
||||
if(input->KeyState[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
|
||||
{
|
||||
speed = 1.0f;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_A] == GLFW_PRESS)
|
||||
{
|
||||
transform->Position -= Camera_Right * (float)dt*2.f * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_D] == GLFW_PRESS)
|
||||
{
|
||||
transform->Position += Camera_Right * (float)dt*2.f * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_W] == GLFW_PRESS)
|
||||
{
|
||||
transform->Position -= Camera_Forward * (float)dt*2.f * speed;
|
||||
}
|
||||
if(input->KeyState[GLFW_KEY_S] == GLFW_PRESS)
|
||||
{
|
||||
transform->Position += Camera_Forward * (float)dt*2.f * speed;
|
||||
}
|
||||
|
||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>(-(input->dX/300.f),glm::vec3(0,1,0));
|
||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>(-(input->dY/300.f),glm::vec3(1,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef PlayerSystem_h__
|
||||
#define PlayerSystem_h__
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "System.h"
|
||||
#include "Renderer.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Input.h"
|
||||
#include "logging.h"
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class PlayerSystem : public System
|
||||
{
|
||||
public:
|
||||
PlayerSystem(World* world)
|
||||
: System(world) { }
|
||||
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // InputSystem_h__
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "RenderSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::RenderSystem::OnComponentCreated( std::string type, std:: shared_ptr<Component> component )
|
||||
{
|
||||
if(type == "Model")
|
||||
{
|
||||
auto modelComponent = std::static_pointer_cast<Components::Model>(component);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (m_CachedModels.find(modelComponent->ModelFile) != m_CachedModels.end()) {
|
||||
m_CachedModels[modelComponent->ModelFile] = new Model(modelComponent->ModelFile);
|
||||
}
|
||||
=======
|
||||
>>>>>>> ce6b570520794087eb98447a571578585a705ded
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user