diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters.orig b/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters.orig
deleted file mode 100644
index df95cf2..0000000
--- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj.filters.orig
+++ /dev/null
@@ -1,186 +0,0 @@
-
-
-
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
-
-
-
- GUI
-
-
-
-
- GUI
-
-
- GUI
-
-
- GUI
-
-
- GUI
-
-
-
-
-
-
-
-
-
-
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
- Systems
-
-
-
- Components
-
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Components
-
-
- Util
-
-
- Util
-
-
-
-
- GUI
-
-
- GUI
-
-
- GUI
-
-
- GUI
-
-
- GUI
-
-
-
-
-
-
-
-
- Shaders
-
-
- Shaders
-
-<<<<<<< HEAD
-
-=======
-
- Shaders
-
-
->>>>>>> origin/master
- Shaders
-
-
-
-
- {657e11f4-52e7-4336-b77f-80f00b85c33f}
-
-
- {59929465-a139-43b9-9c75-48121d156e78}
-
-
- {54f1eb6f-dc00-4e97-a3ef-ac255d755e2e}
-
-
- {d985d7a7-c041-46fe-ae03-aa40295a7aad}
-
-
- {7bdb0f69-049e-4f16-b271-2495e02e4b28}
-
-
-
\ No newline at end of file
diff --git a/Escape-the-Dawn/GameWorld.cpp b/Escape-the-Dawn/GameWorld.cpp
index 708c2b8..3844113 100644
--- a/Escape-the-Dawn/GameWorld.cpp
+++ b/Escape-the-Dawn/GameWorld.cpp
@@ -1,5 +1,6 @@
#include "GameWorld.h"
+
void GameWorld::Initialize()
{
World::Initialize();
@@ -18,24 +19,14 @@ void GameWorld::Initialize()
std::shared_ptr camera;
EntityID ent;
- // Camera
- ent = CreateEntity();
- SetProperty(ent, "Name", std::string("Camera"));
- transform = AddComponent(ent, "Transform");
- AddComponent(ent, "Input");
- transform->Position = glm::vec3(0.f, 2.f, 10.f);
- camera = AddComponent(ent, "Camera");
- camera->FOV = 45.f;
- camera->FarClip = 1000.f;
- camera->NearClip = 0.01f;
- transform->Orientation = glm::angleAxis(glm::radians(25.0f),glm::vec3(1,0,0));
-
// Fucking lights
ent = CreateEntity();
transform = AddComponent(ent, "Transform");
+ transform->Position = glm::vec3(0.f, 4.f, 0.f);
transform->Position = glm::vec3(10.f, 2.f, 5.f);
pointLight = AddComponent(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
+ pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(1.0, 1.0, 5.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
@@ -45,8 +36,11 @@ void GameWorld::Initialize()
model->ModelFile = "sphere.obj";
ent = CreateEntity();
transform = AddComponent(ent, "Transform");
+ transform->Position = glm::vec3(10.f, 4.f, 0.f);
transform->Position = glm::vec3(0.f, 2.f, 5.f);
pointLight = AddComponent(ent, "PointLight");
+ pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
+ pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->Specular = glm::vec3(3.0, 3.0, 3.0);
pointLight->Diffuse = glm::vec3(3.0, 0.0, 0.0);
pointLight->constantAttenuation = 0.f;
@@ -57,9 +51,11 @@ void GameWorld::Initialize()
model->ModelFile = "sphere.obj";
ent = CreateEntity();
transform = AddComponent(ent, "Transform");
+ transform->Position = glm::vec3(0.f, -4.f, 0.f);
transform->Position = glm::vec3(-10.f, 2.f, 5.f);
pointLight = AddComponent(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
+ pointLight->Diffuse = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(0.0, 3.0, 0.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
@@ -87,14 +83,6 @@ void GameWorld::Initialize()
transform->Position = glm::vec3(10.f, 0.f, 0.f);
model = AddComponent(ent, "Model");
model->ModelFile = "ship.obj";
- auto soundEmitter = AddComponent(ent, "SoundEmitter");
- soundEmitter->Gain = 0.1f;
- soundEmitter->MaxDistance = FLT_MAX;
- soundEmitter->ReferenceDistance = 10;
- soundEmitter->Loop = true;
- soundEmitter->Pitch = 0;
- //GetSystem("SoundSystem")->PlaySound(soundEmitter, "Sounds/hallelujah.wav");
-
}
void GameWorld::Update(double dt)
@@ -129,5 +117,4 @@ void GameWorld::RegisterSystems()
m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_Renderer); });
-}
-
+}
\ No newline at end of file
diff --git a/Escape-the-Dawn/GameWorld.h b/Escape-the-Dawn/GameWorld.h
index 5a9e3bc..49ff95a 100644
--- a/Escape-the-Dawn/GameWorld.h
+++ b/Escape-the-Dawn/GameWorld.h
@@ -32,12 +32,13 @@ class GameWorld : public World
public:
GameWorld(std::shared_ptr renderer)
: m_Renderer(renderer), World() { }
- void Initialize() override;
+
+ void Initialize();
void RegisterSystems() override;
void RegisterComponents() override;
- void Update(double dt) override;
+ void Update(double dt) ;
private:
std::shared_ptr m_Renderer;
diff --git a/Escape-the-Dawn/Renderer.cpp b/Escape-the-Dawn/Renderer.cpp
index 13b93bd..84f1273 100644
--- a/Escape-the-Dawn/Renderer.cpp
+++ b/Escape-the-Dawn/Renderer.cpp
@@ -72,6 +72,17 @@ void Renderer::Draw(double dt)
glPolygonMode(GL_FRONT_AND_BACK, m_DrawWireframe ? GL_LINE : GL_FILL);
DrawModels();
+#ifdef DEBUG
+ // Debug draw normals
+ if (m_DrawNormals) {
+ m_ShaderProgramNormals.Bind();
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ DrawModels();
+ }
+#endif
+
+ ModelsToRender.clear();
+
#ifdef DEBUG
// Debug draw normals
if (m_DrawNormals) {
@@ -113,7 +124,7 @@ void Renderer::DrawModels()
for (auto texGroup : model->TextureGroups) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texGroup.Texture->texture);
- glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
+ glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, (texGroup.EndIndex - texGroup.StartIndex + 1) * abs(sin(glfwGetTime())));
}
}
}
diff --git a/Escape-the-Dawn/Renderer.cpp.orig b/Escape-the-Dawn/Renderer.cpp.orig
deleted file mode 100644
index 0177d0f..0000000
--- a/Escape-the-Dawn/Renderer.cpp.orig
+++ /dev/null
@@ -1,193 +0,0 @@
-#include "Renderer.h"
-
-Renderer::Renderer()
-{
- m_VSync = false;
- m_DrawNormals = false;
- m_DrawWireframe = false;
-}
-
-void Renderer::Initialize()
-{
- // Initialize GLFW
- if (!glfwInit()) {
- LOG_ERROR("GLFW: Initialization failed");
- exit(EXIT_FAILURE);
- }
-
- // Create a window
- WIDTH = 1280;
- HEIGHT = 720;
- m_Window = glfwCreateWindow(WIDTH, HEIGHT, "OpenGL", nullptr, nullptr);
- if (!m_Window) {
- LOG_ERROR("GLFW: Failed to create window");
- exit(EXIT_FAILURE);
- }
- glfwMakeContextCurrent(m_Window);
-
- // GL version info
- glGetIntegerv(GL_MAJOR_VERSION, &m_glVersion[0]);
- glGetIntegerv(GL_MINOR_VERSION, &m_glVersion[1]);
- m_glVendor = (GLchar*)glGetString(GL_VENDOR);
- std::stringstream ss;
- ss << m_glVendor << " OpenGL " << m_glVersion[0] << "." << m_glVersion[1];
-#ifdef DEBUG
- ss << " DEBUG";
-#endif
- LOG_INFO(ss.str().c_str());
- glfwSetWindowTitle(m_Window, ss.str().c_str());
-
- // Initialize GLEW
- if (glewInit() != GLEW_OK) {
- LOG_ERROR("GLEW: Initialization failed");
- exit(EXIT_FAILURE);
- }
-
- // Create Camera
- m_Camera = std::make_shared(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
- m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
-
- glfwSwapInterval(m_VSync);
- glEnable(GL_CULL_FACE);
- glCullFace(GL_BACK);
- glEnable(GL_DEPTH_TEST);
-
- LoadContent();
-}
-
-void Renderer::Draw(double dt)
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
-#ifdef DEBUG
- glDisable(GL_CULL_FACE);
- glPolygonMode(GL_BACK, GL_LINE);
-#endif
-
- // Draw models
- m_ShaderProgram.Bind();
- glPolygonMode(GL_FRONT_AND_BACK, m_DrawWireframe ? GL_LINE : GL_FILL);
- DrawModels();
-
-#ifdef DEBUG
- // Debug draw normals
- if (m_DrawNormals) {
- m_ShaderProgramNormals.Bind();
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- DrawModels();
- }
-#endif
-
- ModelsToRender.clear();
-
- glfwSwapBuffers(m_Window);
-}
-
-void Renderer::DrawModels()
-{
- glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
-
- glm::mat4 MVP;
- for (int i = 0; i < ModelsToRender.size(); i++)
- {
- ModelData* modelData = ModelsToRender.at(i);
- auto model = modelData->model;
-
- MVP = cameraMatrix * modelData->ModelMatrix;
- glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
- glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "model"), 1, GL_FALSE, glm::value_ptr(modelData->ModelMatrix));
- glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "view"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
-<<<<<<< HEAD
- glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "position"), 3, Light_position.data());
- glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "specular"), 3, Light_specular.data());
- glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "diffuse"), 3, Light_diffuse.data());
- glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "constantAttenuation"), 3, Light_constantAttenuation.data());
- glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 3, Light_linearAttenuation.data());
- glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 3, Light_quadraticAttenuation.data());
- glUniform1fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "spotExponent"), 3, Light_spotExponent.data());
- glBindVertexArray(ModelsToRender[i]->model->VAO);
- glDrawArrays(GL_TRIANGLES, 0, ModelsToRender[i]->model->Vertices.size());
-=======
- glUniform3fv(glGetUniformLocation(m_ShaderProgram.GetHandle(), "lightPosition"), 1, glm::value_ptr(glm::vec3(2.0f, 4.0f, 1.0f)));
- glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "constantAttenuation"), 1.5f);
- glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "linearAttenuation"), 0.0f);
- glUniform1f(glGetUniformLocation(m_ShaderProgram.GetHandle(), "quadraticAttenuation"), 0.0f);
->>>>>>> origin/master
-
-
- glBindVertexArray(model->VAO);
- for (auto texGroup : model->TextureGroups) {
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texGroup.Texture->texture);
- glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, (texGroup.EndIndex - texGroup.StartIndex + 1) * abs(sin(glfwGetTime())));
- }
- }
-}
-
-void Renderer::DrawText()
-{
- //DrawShitInTextForm
-}
-
-void Renderer::AddTextToDraw()
-{
- //Add to draw shit vector
-}
-
-void Renderer::AddModelToDraw(std::shared_ptr _model, glm::vec3 _position, glm::quat _orientation)
-{
- glm::mat4 RotationMatrix = glm::toMat4(_orientation);
- glm::mat4 ModelMatrix = glm::translate(glm::mat4(), _position) * RotationMatrix ;
- // You can now use ModelMatrix to build the MVP matrix
- ModelsToRender.push_back(new ModelData(_model, ModelMatrix));
-}
-
-void Renderer::AddPointLightToDraw(
- glm::vec3 _position,
- glm::vec3 _specular,
- glm::vec3 _diffuse,
- float _constantAttenuation,
- float _linearAttenuation,
- float _quadraticAttenuation,
- float _spotExponent
- )
-{
- Light_position.push_back(_position.x);
- Light_position.push_back(_position.y);
- Light_position.push_back(_position.z);
- Light_specular.push_back(_specular.x);
- Light_specular.push_back(_specular.y);
- Light_specular.push_back(_specular.z);
- Light_diffuse.push_back(_diffuse.x);
- Light_diffuse.push_back(_diffuse.y);
- Light_diffuse.push_back(_diffuse.z);
- Light_constantAttenuation.push_back(_constantAttenuation);
- Light_linearAttenuation.push_back(_linearAttenuation);
- Light_quadraticAttenuation.push_back(_quadraticAttenuation);
- Light_spotExponent.push_back(_spotExponent);
-
-}
-
-
-void Renderer::LoadContent()
-{
- auto standardVS = std::shared_ptr(new VertexShader("Shaders/Vertex.glsl"));
- auto standardFS = std::shared_ptr(new FragmentShader("Shaders/Fragment.glsl"));
-
- auto normalsGS = std::shared_ptr(new GeometryShader("Shaders/Normals.geo.glsl"));
- auto normalsFS = std::shared_ptr(new FragmentShader("Shaders/Normals.frag.glsl"));
-
- m_ShaderProgram.AddShader(standardVS);
- m_ShaderProgram.AddShader(standardFS);
- m_ShaderProgram.Compile();
- m_ShaderProgram.Link();
-
- m_ShaderProgramNormals.AddShader(normalsGS);
- m_ShaderProgramNormals.AddShader(standardVS);
- m_ShaderProgramNormals.AddShader(normalsFS);
- m_ShaderProgramNormals.Compile();
- m_ShaderProgramNormals.Link();
-}
diff --git a/Escape-the-Dawn/Systems/RenderSystem.cpp.orig b/Escape-the-Dawn/Systems/RenderSystem.cpp.orig
deleted file mode 100644
index b51a198..0000000
--- a/Escape-the-Dawn/Systems/RenderSystem.cpp.orig
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "RenderSystem.h"
-#include "World.h"
-
-void Systems::RenderSystem::OnComponentCreated( std::string type, std:: shared_ptr component )
-{
- if(type == "Model")
- {
- auto modelComponent = std::static_pointer_cast(component);
-
- }
-}
-
-void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
-{
- auto transformComponent = m_World->GetComponent(entity, "Transform");
- if (transformComponent == nullptr)
- return;
-
- // Draw models
- auto modelComponent = m_World->GetComponent(entity, "Model");
- if (modelComponent != nullptr)
- {
- if (m_CachedModels.find(modelComponent->ModelFile) == m_CachedModels.end()){
- m_CachedModels[modelComponent->ModelFile] = std::make_shared(OBJ(modelComponent->ModelFile));
- }
-
- auto model = m_CachedModels[modelComponent->ModelFile];
- m_Renderer->AddModelToDraw(model, transformComponent->Position, transformComponent->Orientation);
- }
-<<<<<<< HEAD
- auto pointLightComponent = m_World->GetComponent(entity, "PointLight");
- if (pointLightComponent != nullptr)
- {
-
- m_Renderer->AddPointLightToDraw(
- transformComponent->Position,
- pointLightComponent->Specular,
- pointLightComponent->Diffuse,
- pointLightComponent->constantAttenuation,
- pointLightComponent->linearAttenuation,
- pointLightComponent->quadraticAttenuation,
- pointLightComponent->spotExponent);
- }
-=======
-
- // Update camera
->>>>>>> origin/master
- auto cameraComponent = m_World->GetComponent(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);
- }
-}
-
-
-
-
diff --git a/Escape-the-Dawn/Systems/RenderSystem.h b/Escape-the-Dawn/Systems/RenderSystem.h
index 086a54a..dc3f15b 100644
--- a/Escape-the-Dawn/Systems/RenderSystem.h
+++ b/Escape-the-Dawn/Systems/RenderSystem.h
@@ -1,5 +1,5 @@
#ifndef RenderSystem_h__
-#define RenderSystem_h__
+#define RenderSystem_h__
#include