Merge remote-tracking branch 'origin/master' into water
Conflicts: src/game/Game/ProjectileSystem.cpp
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
#ifndef BGFXRenderer_h__
|
||||
#define BGFXRenderer_h__
|
||||
|
||||
#include <bgfx.h>
|
||||
#include <bgfxplatform.h>
|
||||
|
||||
#include "Util/Rectangle.h"
|
||||
#include "Core/Camera.h"
|
||||
#include "Core/RenderQueue.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class BGFXRenderer
|
||||
{
|
||||
public:
|
||||
GLFWwindow* Window() const { return m_Window; }
|
||||
Rectangle Resolution() const { return m_Resolution; }
|
||||
void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; }
|
||||
bool Fullscreen() { return m_Fullscreen; }
|
||||
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
|
||||
bool VSYNC() const { return m_VSYNC; }
|
||||
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
|
||||
//void SetViewport(const Rectangle& viewport) { m_Viewport = viewport; }
|
||||
//void SetScissor(const Rectangle& scissor) { m_Scissor = scissor; }
|
||||
const dd::Camera* Camera() const { return m_Camera; }
|
||||
void SetCamera(const dd::Camera* camera)
|
||||
{
|
||||
if (camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera.get();
|
||||
} else {
|
||||
m_Camera = camera;
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
// Initialize GLFW
|
||||
if (!glfwInit()) {
|
||||
LOG_ERROR("GLFW: Initialization failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Create a window
|
||||
GLFWmonitor* monitor = nullptr;
|
||||
if (m_Fullscreen) {
|
||||
monitor = glfwGetPrimaryMonitor();
|
||||
}
|
||||
glfwWindowHint(GLFW_SAMPLES, 8);
|
||||
m_Window = glfwCreateWindow(m_Resolution.Width, m_Resolution.Height, "daydream", monitor, nullptr);
|
||||
if (!m_Window) {
|
||||
LOG_ERROR("GLFW: Failed to create window");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
//glfwMakeContextCurrent(m_Window);
|
||||
|
||||
// Initialize GLEW
|
||||
// if (glewInit() != GLEW_OK) {
|
||||
// LOG_ERROR("GLEW: Initialization failed");
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
//LOG_ERROR("STUFF");
|
||||
|
||||
// Initialize bgfx
|
||||
bgfx::glfwSetWindow(m_Window);
|
||||
bgfx::init(bgfx::RendererType::OpenGL, BGFX_PCI_ID_NONE, 0, nullptr, nullptr);
|
||||
bgfx::reset(m_Resolution.Width, m_Resolution.Height, BGFX_RESET_NONE);
|
||||
bgfx::setDebug(BGFX_DEBUG_TEXT);
|
||||
bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x303030ff, 1.0f, 0);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << bgfx::getRendererName(bgfx::getRendererType());
|
||||
#ifdef DEBUG
|
||||
ss << " DEBUG";
|
||||
#endif
|
||||
LOG_INFO(ss.str().c_str());
|
||||
glfwSetWindowTitle(m_Window, ss.str().c_str());
|
||||
}
|
||||
|
||||
void Draw(RenderQueueCollection& rq)
|
||||
{
|
||||
bgfx::touch(0);
|
||||
|
||||
bgfx::dbgTextClear();
|
||||
bgfx::dbgTextPrintf(0, 1, 0x4f, "daydream");
|
||||
|
||||
bgfx::frame();
|
||||
}
|
||||
|
||||
private:
|
||||
Rectangle m_Resolution = Rectangle(1280, 720);
|
||||
bool m_Fullscreen = false;
|
||||
bool m_VSYNC = false;
|
||||
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
|
||||
const dd::Camera* m_Camera = nullptr;
|
||||
|
||||
GLFWwindow* m_Window = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+26
-21
@@ -21,12 +21,12 @@
|
||||
#include <Sound/CCollisionSound.h>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "OBJ.h"
|
||||
#include "Model.h"
|
||||
#include "Texture.h"
|
||||
#include "Rendering/OBJ.h"
|
||||
#include "Rendering/Model.h"
|
||||
#include "Rendering/Texture.h"
|
||||
#include "EventBroker.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "Renderer.h"
|
||||
#include "Rendering/RenderQueue.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
#include "InputManager.h"
|
||||
//TODO: Remove includes that are only here for the temporary draw solution.
|
||||
#include "World.h"
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBrickPart.h"
|
||||
#include "Game/CWall.h"
|
||||
#include "Game/CKraken.h"
|
||||
#include "Game/CBackground.h"
|
||||
@@ -59,6 +60,7 @@
|
||||
#include "Game/LifebuoySystem.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
#include "Game/KrakenSystem.h"
|
||||
#include "Game/WaterSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Game/BrickComponents.h"
|
||||
@@ -143,6 +145,7 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::Physics>();
|
||||
m_World->ComponentFactory.Register<Components::Ball>();
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::BrickPart>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Wall>();
|
||||
m_World->ComponentFactory.Register<Components::Background>();
|
||||
@@ -164,7 +167,7 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::KrakenAttackBrick>();
|
||||
|
||||
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LevelSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PadSystem>(
|
||||
[this]() { return new Systems::PadSystem(m_World.get(), m_EventBroker); });
|
||||
@@ -193,6 +196,9 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::KrakenSystem>(
|
||||
[this]() { return new Systems::KrakenSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::KrakenSystem>();
|
||||
m_World->SystemFactory.Register<Systems::WaterSystem>(
|
||||
[this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::WaterSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
@@ -203,6 +209,9 @@ public:
|
||||
m_World->Initialize();
|
||||
|
||||
//auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
|
||||
|
||||
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EGameStart);
|
||||
@@ -348,23 +357,20 @@ public:
|
||||
{
|
||||
ModelJob job;
|
||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||
job.DiffuseTexture = (texGroup.Texture) ? *texGroup.Texture : 0;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.VAO = model->VAO;
|
||||
job.ElementBuffer = model->ElementBuffer;
|
||||
job.DiffuseTexture = texGroup.Texture.get();
|
||||
job.NormalTexture = texGroup.NormalMap.get();
|
||||
job.SpecularTexture = texGroup.SpecularMap.get();
|
||||
job.Model = model;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix * model->m_Matrix;
|
||||
job.Color = modelComponent->Color;
|
||||
|
||||
if (model->m_Skeleton != nullptr) {
|
||||
if (model->m_Skeleton != nullptr && animationComponent != nullptr) {
|
||||
job.Skeleton = model->m_Skeleton;
|
||||
if (animationComponent != nullptr) {
|
||||
job.AnimationName = animationComponent->Name;
|
||||
job.AnimationTime = animationComponent->Time;
|
||||
job.NoRootMotion = animationComponent->NoRootMotion;
|
||||
}
|
||||
job.AnimationName = animationComponent->Name;
|
||||
job.AnimationTime = animationComponent->Time;
|
||||
job.NoRootMotion = animationComponent->NoRootMotion;
|
||||
}
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
@@ -376,14 +382,13 @@ public:
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
job.DiffuseTexture = *texture;
|
||||
job.NormalTexture = *normalTexture;
|
||||
job.SpecularTexture = *specularTexture;
|
||||
job.DiffuseTexture = texture;
|
||||
job.NormalTexture = normalTexture;
|
||||
job.SpecularTexture = specularTexture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
job.Depth = depth;
|
||||
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,649 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <Sound/CCollisionSound.h>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "OBJ.h"
|
||||
#include "Model.h"
|
||||
#include "Texture.h"
|
||||
#include "EventBroker.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "Renderer.h"
|
||||
#include "InputManager.h"
|
||||
//TODO: Remove includes that are only here for the temporary draw solution.
|
||||
#include "World.h"
|
||||
#include "CTransform.h"
|
||||
#include "CTemplate.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CPointLight.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Sound/SoundSystem.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
|
||||
#include "Game/LevelSystem.h"
|
||||
#include "Game/PadSystem.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CWall.h"
|
||||
#include "Game/CKraken.h"
|
||||
#include "Game/CBackground.h"
|
||||
#include "Game/CTravels.h"
|
||||
#include "Game/CStickyAim.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/HitLagSystem.h"
|
||||
#include "Game/TravellingSystem.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
#include "Game/KrakenSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Game/BrickComponents.h"
|
||||
|
||||
#include "Game/EScreenShake.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Physics/CParticle.h"
|
||||
#include "Physics/CParticleEmitter.h"
|
||||
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
|
||||
#include "Game/EGameStart.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/Button.h"
|
||||
#include "Game/GUI/MainMenu.h"
|
||||
#include "Game/GUI/HUD.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Engine
|
||||
{
|
||||
|
||||
public:
|
||||
Engine(int argc, char* argv[]) {
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(config->GetValue<int>("Debug.LogLevel", 1));
|
||||
|
||||
m_EventBroker = std::make_shared<EventBroker>();
|
||||
|
||||
m_Renderer = std::make_shared<Renderer>();
|
||||
m_Renderer->SetFullscreen(config->GetValue<bool>("Video.Fullscreen", false));
|
||||
m_Renderer->SetResolution(Rectangle(
|
||||
0,
|
||||
0,
|
||||
config->GetValue<int>("Video.Width", 675),
|
||||
config->GetValue<int>("Video.Height", 1080)
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
|
||||
m_FrameStack = new GUI::Frame(m_EventBroker.get());
|
||||
m_FrameStack->Width = 675;
|
||||
m_FrameStack->Height = 1080;
|
||||
|
||||
if (config->GetValue<bool>("Debug.SkipStory", false)) {
|
||||
Events::GameStart e;
|
||||
m_EventBroker->Publish(e);
|
||||
auto hud = new GUI::HUD(m_FrameStack, "HUD");
|
||||
}
|
||||
else {
|
||||
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
||||
}
|
||||
|
||||
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
||||
|
||||
m_World = std::make_shared<World>(m_EventBroker);
|
||||
|
||||
//TODO: Move this out of engine.h
|
||||
m_World->ComponentFactory.Register<Components::Transform>();
|
||||
m_World->SystemFactory.Register<Systems::TransformSystem>(
|
||||
[this]() { return new Systems::TransformSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::TransformSystem>();
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::CollisionSound>();
|
||||
m_World->SystemFactory.Register<Systems::SoundSystem>(
|
||||
[this]() { return new Systems::SoundSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::SoundSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Sprite>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::RectangleShape>();
|
||||
m_World->ComponentFactory.Register<Components::Physics>();
|
||||
m_World->ComponentFactory.Register<Components::Ball>();
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Wall>();
|
||||
m_World->ComponentFactory.Register<Components::Background>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
||||
m_World->ComponentFactory.Register<Components::Projectile>();
|
||||
m_World->ComponentFactory.Register<Components::Kraken>();
|
||||
m_World->ComponentFactory.Register<Components::StickyAim>();
|
||||
m_World->ComponentFactory.Register<Components::Travels>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::StandardBrick>();
|
||||
m_World->ComponentFactory.Register<Components::MultiBallBrick>();
|
||||
m_World->ComponentFactory.Register<Components::LifebuoyBrick>();
|
||||
m_World->ComponentFactory.Register<Components::StickyBrick>();
|
||||
m_World->ComponentFactory.Register<Components::InkBlasterBrick>();
|
||||
m_World->ComponentFactory.Register<Components::KrakenAttackBrick>();
|
||||
|
||||
m_World->SystemFactory.Register<Systems::LevelSystem>(
|
||||
[this]() { return new Systems::LevelSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LevelSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PadSystem>(
|
||||
[this]() { return new Systems::PadSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PadSystem>();
|
||||
m_World->SystemFactory.Register<Systems::BallSystem>(
|
||||
[this]() { return new Systems::BallSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::BallSystem>();
|
||||
m_World->SystemFactory.Register<Systems::HitLagSystem>(
|
||||
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::HitLagSystem>();
|
||||
m_World->SystemFactory.Register<Systems::LifebuoySystem>(
|
||||
[this]() { return new Systems::LifebuoySystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LifebuoySystem>();
|
||||
m_World->SystemFactory.Register<Systems::ProjectileSystem>(
|
||||
[this]() { return new Systems::ProjectileSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::ProjectileSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
m_World->SystemFactory.Register<Systems::AnimationSystem>(
|
||||
[this]() { return new Systems::AnimationSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::AnimationSystem>();
|
||||
m_World->SystemFactory.Register<Systems::TravellingSystem>(
|
||||
[this]() { return new Systems::TravellingSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::TravellingSystem>();
|
||||
m_World->SystemFactory.Register<Systems::KrakenSystem>(
|
||||
[this]() { return new Systems::KrakenSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::KrakenSystem>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
m_World->ComponentFactory.Register<Components::PointLight>();
|
||||
m_World->ComponentFactory.Register<Components::WaterVolume>();
|
||||
m_World->ComponentFactory.Register<Components::Particle>();
|
||||
m_World->ComponentFactory.Register<Components::ParticleEmitter>();
|
||||
m_World->Initialize();
|
||||
|
||||
<<<<<<< HEAD
|
||||
//PointLightTest
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(-3.f, 6.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 20.f;
|
||||
pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_Light);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(3.f, -5.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 15.f;
|
||||
pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_Light);
|
||||
model->ModelFile = "Models/Core/UnitSphere.obj";
|
||||
m_World->CommitEntity(t_Light);
|
||||
}
|
||||
|
||||
//Halfpipe background test model.
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 34.6f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
|
||||
//Background
|
||||
|
||||
{
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -30.f);
|
||||
transform->Scale = glm::vec3(2681.f / 50.f, 1080.f / 50.f, 1.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(background);
|
||||
sprite->SpriteFile = "Textures/Background.png";
|
||||
m_World->CommitEntity(background);
|
||||
}
|
||||
|
||||
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
|
||||
transform->Sticky = true;
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//ParticleTest
|
||||
|
||||
|
||||
/*{
|
||||
auto Pe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
||||
auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(Pe);
|
||||
auto emitteSprite = m_World->AddComponent<Components::Sprite>(Pe);
|
||||
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
emitteSprite->SpriteFile = "Textures/Test/Brick_Normal.png";
|
||||
particleEmitter->GravityScale = 0.0f;
|
||||
particleEmitter->SpawnRate = 1.f;
|
||||
particleEmitter->NumberOfTicks = 2;
|
||||
particleEmitter->Speed = 1.f;
|
||||
particleEmitter->ParticlesPerTick = 5;
|
||||
particleEmitter->Spread = glm::pi<float>()*2;
|
||||
particleEmitter->EmittingAngle = glm::pi<float>();
|
||||
particleEmitter->LifeTime = 50;
|
||||
|
||||
{
|
||||
auto Pt = m_World->CreateEntity(Pe);
|
||||
auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
|
||||
auto PtParticle = m_World->AddComponent<Components::Particle>(Pt);
|
||||
auto PtTemplate = m_World->AddComponent<Components::Template>(Pt);
|
||||
|
||||
//PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
|
||||
PtTransform->Position = transform->Position;
|
||||
PtSprite->SpriteFile = "Textures/Background.png";
|
||||
PtParticle->LifeTime = 3.f;
|
||||
PtParticle->Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter);
|
||||
}
|
||||
m_World->CommitEntity(Pe);
|
||||
}*/
|
||||
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto BottomWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(BottomWall);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(BottomWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(BottomWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
||||
transform->Sticky = true;
|
||||
m_World->CommitEntity(BottomWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, 6.f, -10.f);
|
||||
transform->Scale = glm::vec3(20.f, 0.5f, 1.f);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(topWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto leftWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
leftWall);
|
||||
transform->Position = glm::vec3(-4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(leftWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto rightWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(
|
||||
rightWall);
|
||||
transform->Position = glm::vec3(4.f, 1.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 20.f, 1.f);
|
||||
|
||||
//std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(rightWall);
|
||||
//sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
|
||||
|
||||
std::shared_ptr<Components::RectangleShape> rectangleShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
|
||||
rectangleShape->Dimensions = glm::vec2(0.5f, 20.f);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
=======
|
||||
//auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
>>>>>>> origin/master
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EGameStart);
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
}
|
||||
|
||||
bool Running() const { return !glfwWindowShouldClose(m_Renderer->Window()); }
|
||||
|
||||
void Tick()
|
||||
{
|
||||
double currentTime = glfwGetTime();
|
||||
double dt = currentTime - m_LastTime;
|
||||
m_LastTime = currentTime;
|
||||
|
||||
// Update input
|
||||
m_InputManager->Update(dt);
|
||||
// Swap event queues to get fresh input data in the read queue
|
||||
//m_EventBroker->Swap();
|
||||
|
||||
//ResourceManager::Update();
|
||||
if (m_GameIsRunning) {
|
||||
m_World->Update(dt);
|
||||
} else {
|
||||
m_EventBroker->Process<Systems::SoundSystem>();
|
||||
}
|
||||
m_EventBroker->Process<GUI::Frame>();
|
||||
m_FrameStack->UpdateLayered(dt);
|
||||
|
||||
m_RendererQueue.Clear();
|
||||
m_FrameStack->DrawLayered(m_RendererQueue);
|
||||
//TODO Fill up the renderQueue with models (Temp fix)
|
||||
if (m_GameIsRunning) {
|
||||
TEMPAddToRenderQueue();
|
||||
}
|
||||
|
||||
std::unique_ptr<dd::Camera> defaultCamera = nullptr;
|
||||
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
m_Renderer->Draw(m_RendererQueue);
|
||||
|
||||
m_EventBroker->Process<Engine>();
|
||||
// Swap event queues
|
||||
m_EventBroker->Swap();
|
||||
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
std::shared_ptr<Systems::LevelSystem> m_LevelSystem;
|
||||
|
||||
//TODO: Get this out of engine.h
|
||||
void TEMPAddToRenderQueue()
|
||||
{
|
||||
if (!m_TransformSystem)
|
||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||
|
||||
for (auto &pair : *m_World->GetEntities())
|
||||
{
|
||||
EntityID entity = pair.first;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateComponent)
|
||||
continue;
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transform)
|
||||
continue;
|
||||
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(entity);
|
||||
if (modelComponent)
|
||||
{
|
||||
Model* modelAsset = nullptr;
|
||||
modelAsset = ResourceManager::Load<Model>(modelComponent->ModelFile);
|
||||
|
||||
if (modelAsset)
|
||||
{
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
|
||||
* glm::toMat4(absoluteTransform.Orientation)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
Components::Animation* animationComponent = m_World->GetComponent<Components::Animation>(entity);
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent, animationComponent);
|
||||
}
|
||||
}
|
||||
|
||||
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity);
|
||||
if (pointLightComponent)
|
||||
{
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
EnqueuePointLight(absoluteTransform.Position,
|
||||
pointLightComponent->Diffuse,
|
||||
pointLightComponent->Specular,
|
||||
pointLightComponent->Radius);
|
||||
}
|
||||
|
||||
auto parent = m_World->GetEntityParent(entity);
|
||||
if(parent != 0) {
|
||||
auto waterParticleComponent = m_World->GetComponent<Components::WaterVolume>(parent);
|
||||
if (waterParticleComponent) {
|
||||
//TODO: Remove hardcoded color.
|
||||
//TODO: Do i even need modelMatrix?
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueWaterParticles(absoluteTransform.Position, glm::vec4(1.f, 1.f, 1.f, 1.f), modelMatrix, absoluteTransform.Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto spriteComponent = m_World->GetComponent<Components::Sprite>(entity);
|
||||
if (spriteComponent)
|
||||
{
|
||||
std::string normal = spriteComponent->NormalTexture;
|
||||
std::string spec = spriteComponent->SpecularTexture;
|
||||
|
||||
if (normal.empty()) {
|
||||
normal = "Textures/Core/NeutralNormalMap.png";
|
||||
}
|
||||
if (spec.empty()) {
|
||||
spec = "Textures/Core/NeutralSpecularMap.png";
|
||||
}
|
||||
auto texturediff = ResourceManager::Load<Texture>(spriteComponent->SpriteFile);
|
||||
auto texturenorm = ResourceManager::Load<Texture>(normal);
|
||||
auto texturespec = ResourceManager::Load<Texture>(spec);
|
||||
|
||||
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::quat orientation2D = glm::angleAxis(glm::eulerAngles(absoluteTransform.Orientation).z, glm::vec3(0, 0, -1));
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color, absoluteTransform.Position.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Get this out of engine.h
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, const Components::Model* modelComponent, const Components::Animation* animationComponent)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
ModelJob job;
|
||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||
job.DiffuseTexture = (texGroup.Texture) ? *texGroup.Texture : 0;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.VAO = model->VAO;
|
||||
job.ElementBuffer = model->ElementBuffer;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix * model->m_Matrix;
|
||||
job.Color = modelComponent->Color;
|
||||
|
||||
if (model->m_Skeleton != nullptr) {
|
||||
job.Skeleton = model->m_Skeleton;
|
||||
if (animationComponent != nullptr) {
|
||||
job.AnimationName = animationComponent->Name;
|
||||
job.AnimationTime = animationComponent->Time;
|
||||
job.NoRootMotion = animationComponent->NoRootMotion;
|
||||
}
|
||||
}
|
||||
|
||||
m_RendererQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Get this out of engine.h
|
||||
void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color, float depth)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
job.DiffuseTexture = *texture;
|
||||
job.NormalTexture = *normalTexture;
|
||||
job.SpecularTexture = *specularTexture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
job.Depth = depth;
|
||||
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
void EnqueuePointLight(glm::vec3 position, glm::vec3 diffuseColor, glm::vec3 specularColor, float radius)
|
||||
{
|
||||
PointLightJob job;
|
||||
job.Position = position;
|
||||
job.DiffuseColor = diffuseColor;
|
||||
job.SpecularColor = specularColor;
|
||||
job.Radius = radius;
|
||||
|
||||
m_RendererQueue.Lights.Add(job);
|
||||
|
||||
}
|
||||
|
||||
void EnqueueWaterParticles(glm::vec3 position, glm::vec4 color, glm::mat4 modelMatrix, float depth)
|
||||
{
|
||||
WaterParticleJob job;
|
||||
job.Position = position;
|
||||
job.Color = color;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Depth = depth;
|
||||
|
||||
m_RendererQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<EventBroker> m_EventBroker;
|
||||
GUI::Frame* m_FrameStack = nullptr;
|
||||
std::shared_ptr<Renderer> m_Renderer;
|
||||
RenderQueueCollection m_RendererQueue;
|
||||
std::shared_ptr<InputManager> m_InputManager;
|
||||
std::shared_ptr<World> m_World;
|
||||
glm::vec3 m_CameraPosition = glm::vec3(0.f, 0.f, 0.f);
|
||||
|
||||
//TODO: Redo
|
||||
bool m_GameIsRunning = false;
|
||||
dd::EventRelay<Engine, dd::Events::GameStart> m_EGameStart;
|
||||
bool OnGameStart(const dd::Events::GameStart &event)
|
||||
{
|
||||
m_GameIsRunning = true;
|
||||
//Todo: Move this
|
||||
{
|
||||
// dd::Events::PlaySound e;
|
||||
// e.FilePath = "Sounds/BGM/under-the-sea-instrumental.wav";
|
||||
// e.IsAmbient = true;
|
||||
// m_EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
// dd::Events::PlaySound e;
|
||||
// e.FilePath = "Sounds/BGM/water-flowing.wav";
|
||||
// e.Gain = 0.3f;
|
||||
// e.IsAmbient = true;
|
||||
// m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
double m_LastTime;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <forward_list>
|
||||
|
||||
#include "Core/Util/Rectangle.h"
|
||||
#include "Core/Texture.h"
|
||||
#include "Core/Model.h"
|
||||
#include "Rendering/Texture.h"
|
||||
#include "Rendering/Model.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -78,20 +78,6 @@ struct ModelJob : RenderJob
|
||||
}
|
||||
};
|
||||
|
||||
struct BlendMapModelJob : ModelJob
|
||||
{
|
||||
GLuint BlendMapTextureRed;
|
||||
GLuint BlendMapTextureRedNormal;
|
||||
GLuint BlendMapTextureRedSpecular;
|
||||
GLuint BlendMapTextureGreen;
|
||||
GLuint BlendMapTextureGreenNormal;
|
||||
GLuint BlendMapTextureGreenSpecular;
|
||||
GLuint BlendMapTextureBlue;
|
||||
GLuint BlendMapTextureBlueNormal;
|
||||
GLuint BlendMapTextureBlueSpecular;
|
||||
float TextureRepeat;
|
||||
};
|
||||
|
||||
struct SpriteJob : RenderJob
|
||||
{
|
||||
unsigned int ShaderID;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef DD_STATICSYSTEM_H__
|
||||
#define DD_STATICSYSTEM_H__
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class StaticSystem
|
||||
{
|
||||
private:
|
||||
StaticSystem();
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
static T* Get()
|
||||
{
|
||||
return static_cast<T*>(Instances.at(typeid(T).hash_code()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void Set(T* ptr)
|
||||
{
|
||||
Instances[typeid(T).hash_code()] = static_cast<void*>(ptr);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static std::unordered_map<size_t, void*> Instances;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+3
-3
@@ -9,9 +9,9 @@
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/Renderer.h"
|
||||
#include "Core/RenderQueue.h"
|
||||
#include "Core/Texture.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
#include "Rendering/RenderQueue.h"
|
||||
#include "Rendering/Texture.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
|
||||
namespace dd
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define GUI_TextureFrame_h__
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "Core/Texture.h"
|
||||
#include "Rendering/Texture.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
|
||||
job.Viewport = Rectangle(Left(), Top(), Width, Height);
|
||||
job.TextureID = m_FadeTexture->ResourceID;
|
||||
job.DiffuseTexture = *m_FadeTexture;
|
||||
job.DiffuseTexture = m_FadeTexture;
|
||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a);
|
||||
job.Name = Name();
|
||||
rq.GUI.Add(job);
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
|
||||
job.Viewport = Rectangle(Left(), Top(), Width, Height);
|
||||
job.TextureID = m_Texture->ResourceID;
|
||||
job.DiffuseTexture = *m_Texture;
|
||||
job.DiffuseTexture = m_Texture;
|
||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade);
|
||||
job.Name = Name();
|
||||
rq.GUI.Add(job);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "Game/EStickyAttachedToPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EKrakenAttackEnd.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/EGameOver.h"
|
||||
@@ -40,6 +42,7 @@
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -109,6 +112,8 @@ private:
|
||||
bool m_InkBlaster = false;
|
||||
bool m_InkAttached = false;
|
||||
bool m_InkBlockedWaiting = false;
|
||||
bool m_KrakenAttack = false;
|
||||
double m_KrakenCharge = 0;
|
||||
bool m_Restarting = false;
|
||||
int m_StickyCounter = 3;
|
||||
bool m_GodMode = false;
|
||||
@@ -130,6 +135,8 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
|
||||
dd::EventRelay<BallSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<BallSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
|
||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<BallSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||
@@ -145,6 +152,8 @@ private:
|
||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
|
||||
@@ -19,7 +19,7 @@ struct Brick : Component
|
||||
//0 = empty, 1 = normal, 2 = multi-brick, 3 = lifebuoy, 4 = sticky, 5 = blaster, 6 = kraken
|
||||
int Type = 0;
|
||||
bool Removed = false;
|
||||
int Number = 0; // For the Kraken to keep track of which bricks needs replacing.
|
||||
int Number = 100; // For the Kraken to keep track of which bricks needs replacing.
|
||||
|
||||
//What number of types each is.
|
||||
const int EmptyBrickSpace = 0;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-21.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CBRICKPART_H
|
||||
#define DAYDREAM_CBRICKPART_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct BrickPart : Component
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CBRICKPART_H
|
||||
@@ -15,7 +15,8 @@ namespace Components
|
||||
|
||||
struct Kraken : Component {
|
||||
|
||||
int Health = 10;
|
||||
int MaxHealth = 30;
|
||||
int Health = MaxHealth;
|
||||
int CurrentAction = 1;
|
||||
|
||||
const int Idle = 1;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Components
|
||||
|
||||
struct Projectile : Component
|
||||
{
|
||||
|
||||
float Speed = 5;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace Events
|
||||
|
||||
struct BrickGenerating : Event
|
||||
{
|
||||
glm::vec3 Origin;
|
||||
glm::vec3 Origin1;
|
||||
glm::vec3 Origin2;
|
||||
int TargetLine;
|
||||
int Set;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Events
|
||||
|
||||
struct ClusterClear : Event
|
||||
{
|
||||
|
||||
int ClusterCleared;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ struct InkBlaster : Event
|
||||
{
|
||||
Components::Transform* Transform;
|
||||
int Shots;
|
||||
float Speed = 5;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-21.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EKRAKENATTACKEND_H
|
||||
#define DAYDREAM_EKRAKENATTACKEND_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct KrakenAttackEnd : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EKRAKENATTACKEND_H
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-19.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EKRAKENDEFEATED_H
|
||||
#define DAYDREAM_EKRAKENDEFEATED_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct KrakenDefeated : Event
|
||||
{
|
||||
EntityID Kraken;
|
||||
EntityID Hitter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EKRAKENDEFEATED_H
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-19.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EKRAKENHIT_H
|
||||
#define DAYDREAM_EKRAKENHIT_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct KrakenHit : Event
|
||||
{
|
||||
EntityID Kraken;
|
||||
EntityID Hitter;
|
||||
int MaxHealth;
|
||||
int CurrentHealth;
|
||||
int NewHealth;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EKRAKENHIT_H
|
||||
@@ -16,6 +16,7 @@ namespace Events
|
||||
struct RaiseWater : Event
|
||||
{
|
||||
float Amount;
|
||||
float Speed;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Administrator on 2015-10-20.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ERAISEWATERWALL_H
|
||||
#define DAYDREAM_ERAISEWATERWALL_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct RaiseWaterWall : Event
|
||||
{
|
||||
float Amount;
|
||||
float Speed;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ERAISEWATERWALL_H
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by Administrator on 2015-10-20.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ERELEVANTOBJECTCREATED_H
|
||||
#define DAYDREAM_ERELEVANTOBJECTCREATED_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct RelevantObjectCreated : Event
|
||||
{
|
||||
std::string ObjectName;
|
||||
EntityID ObjectID;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ERELEVANTOBJECTCREATED_H
|
||||
@@ -17,6 +17,7 @@ struct StageCleared : Event
|
||||
{
|
||||
int ClearedStage = 0;
|
||||
int StageCluster = 0;
|
||||
int StagesInCluster = 6;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by Administrator on 2015-10-19.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ESTARTEDNEWLEVEL_H
|
||||
#define DAYDREAM_ESTARTEDNEWLEVEL_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Events
|
||||
{
|
||||
struct StartedNewLevel : Event
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ESTARTEDNEWLEVEL_H
|
||||
+14
-5
@@ -51,6 +51,7 @@ public:
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttack, &HUD::OnKrakenAttack);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_KrakenAttackEnd, &HUD::OnKrakenAttackEnd);
|
||||
|
||||
updateScore();
|
||||
}
|
||||
@@ -71,22 +72,23 @@ private:
|
||||
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
|
||||
EventRelay<Frame, Events::KrakenAttack> m_KrakenAttack;
|
||||
EventRelay<Frame, Events::KrakenAttackEnd> m_KrakenAttackEnd;
|
||||
|
||||
void updateScore()
|
||||
{
|
||||
m_ScoreNumberFrame->SetLeft(Width / 2.f - m_ScoreNumberFrame->Width / 2.f);
|
||||
|
||||
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left());
|
||||
m_ScoreBackMid->Width = m_ScoreNumberFrame->Width;
|
||||
m_ScoreBackMid->Height = m_ScoreNumberFrame->Height + 35;
|
||||
m_ScoreBackMid->SetLeft(m_ScoreNumberFrame->Left() + 4);
|
||||
|
||||
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
|
||||
m_ScoreBackLeft->Width = 40;
|
||||
//m_ScoreBackLeft->Width = 40;
|
||||
m_ScoreBackLeft->Height = m_ScoreBackMid->Height;
|
||||
m_ScoreBackLeft->SetRight(m_ScoreBackMid->Left());
|
||||
|
||||
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
|
||||
m_ScoreBackRight->Width = 40;
|
||||
//m_ScoreBackRight->Width = 40;
|
||||
m_ScoreBackRight->Height = m_ScoreBackMid->Height;
|
||||
m_ScoreBackRight->SetLeft(m_ScoreBackMid->Right());
|
||||
}
|
||||
|
||||
bool OnScore(const Events::ScoreEvent& event)
|
||||
@@ -122,6 +124,13 @@ private:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnKrakenAttackEnd(const Events::KrakenAttackEnd& event)
|
||||
{
|
||||
m_KrakenAttackSlider->Hide();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "GUI/Slider.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Game/GUI/ELoadingFrameComplete.h"
|
||||
#include "Sound/EPlaySound.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -56,6 +57,9 @@ public:
|
||||
e.FrameName = Name();
|
||||
e.Frame = this;
|
||||
EventBroker->Publish(e);
|
||||
Events::PlaySound se;
|
||||
se.FilePath = "Sounds/jap-story.wav";
|
||||
EventBroker->Publish(se);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,21 @@
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EComboEvent.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Game/EKrakenAppear.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EKrakenHit.h"
|
||||
#include "Game/EKrakenDefeated.h"
|
||||
#include "Game/EBrickGenerating.h"
|
||||
#include "Game/CTravels.h"
|
||||
#include "Game/CKraken.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Sound/CCollisionSound.h"
|
||||
//#include "Core/Camera.h" Camera Component
|
||||
|
||||
@@ -57,24 +65,29 @@ private:
|
||||
bool m_ReturnToIdle = false;
|
||||
EntityID m_KrakenTemplate;
|
||||
std::string m_Action = "Idle";
|
||||
int m_NumberOfActions;
|
||||
float m_KrakenTimer = 0;
|
||||
float m_KrakenSecondsToAction = 1;
|
||||
float m_KrakenSecondsToAction = 10;
|
||||
const int Idle = 1;
|
||||
|
||||
std::array<int, 14> m_Bricks;
|
||||
std::array<int, 14> m_Colors;
|
||||
std::array<int, 42> m_Bricks;
|
||||
std::array<int, 42> m_Colors;
|
||||
|
||||
dd::EventRelay<KrakenSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::KrakenAppear> m_EKrakenAppear;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::KrakenHit> m_EKrakenHit;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::KrakenDefeated> m_EKrakenDefeated;
|
||||
dd::EventRelay<KrakenSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnKrakenAppear(const dd::Events::KrakenAppear &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnKrakenHit(const dd::Events::KrakenHit &event);
|
||||
bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event);
|
||||
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
void GetBrickSet();
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "Transform/EMove.h"
|
||||
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBrickPart.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CWall.h"
|
||||
@@ -33,7 +34,9 @@
|
||||
|
||||
#include "Game/BrickComponents.h"
|
||||
|
||||
#include "Game/ERelevantObjectCreated.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
@@ -52,7 +55,9 @@
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
|
||||
#include "Game/CKraken.h"
|
||||
#include "Game/EKrakenAppear.h"
|
||||
#include "Game/EKrakenDefeated.h"
|
||||
#include "Game/EBrickGenerating.h"
|
||||
|
||||
#include "Physics/CPhysics.h"
|
||||
@@ -147,6 +152,7 @@ private:
|
||||
int m_NumberOfBricks;
|
||||
int m_Rows = 6;
|
||||
int m_Lines = 7;
|
||||
int m_StagesInCluster = 6;
|
||||
float m_SpaceToEdge = 0.25f;
|
||||
glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4);
|
||||
float m_NotResettingTheStage = 5.f;
|
||||
@@ -167,8 +173,12 @@ private:
|
||||
std::array<int, 42> m_Bricks;
|
||||
std::array<glm::vec4, 42> m_Colors;
|
||||
|
||||
std::array<int, 14> m_BrickSet;
|
||||
std::array<glm::vec4, 14> m_ColorSet;
|
||||
std::array<int, 42> m_BrickSet;
|
||||
std::array<glm::vec4, 42> m_ColorSet;
|
||||
std::array<bool, 42> m_KrakenBricks;
|
||||
|
||||
bool m_BrickGenerating = false;
|
||||
dd::Events::BrickGenerating m_BrickGeneratingEvent;
|
||||
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
|
||||
@@ -177,10 +187,12 @@ private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
|
||||
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
|
||||
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<LevelSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
dd::EventRelay<LevelSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<LevelSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<LevelSystem, dd::Events::HitPad> m_EHitPad;
|
||||
dd::EventRelay<LevelSystem, dd::Events::BrickGenerating> m_EBrickGenerating;
|
||||
dd::EventRelay<LevelSystem, dd::Events::KrakenDefeated> m_EKrakenDefeated;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
|
||||
@@ -189,11 +201,14 @@ private:
|
||||
bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event);
|
||||
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnBrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
bool BrickGenerating(const dd::Events::BrickGenerating &event);
|
||||
void GetBrickSet(int Set);
|
||||
bool OnKrakenDefeated(const dd::Events::KrakenDefeated &event);
|
||||
|
||||
void GetNextLevel();
|
||||
void SetBrokenModel(EntityID entity);
|
||||
|
||||
@@ -36,12 +36,14 @@
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EResetAll.h"
|
||||
#include "Game/ERaiseWater.h"
|
||||
#include "Game/ERaiseWaterWall.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EStickyAttachedToPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EKrakenAttackEnd.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
@@ -49,6 +51,7 @@
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
|
||||
#include "Game/EBrickGenerating.h"
|
||||
|
||||
@@ -102,6 +105,7 @@ private:
|
||||
double m_KrakenStrength = 0;
|
||||
double m_PlayerStrength = 0;
|
||||
float m_Edge = 2.8f;
|
||||
EntityID m_KrakenArm;
|
||||
Components::Transform* m_Transform = nullptr;
|
||||
Components::Pad* m_Pad = nullptr;
|
||||
std::shared_ptr<Components::Transform> m_StickTransform;
|
||||
@@ -118,9 +122,11 @@ private:
|
||||
dd::EventRelay<PadSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<PadSystem, dd::Events::ResetAll> m_EResetAll;
|
||||
dd::EventRelay<PadSystem, dd::Events::RaiseWater> m_ERaiseWater;
|
||||
dd::EventRelay<PadSystem, dd::Events::RaiseWaterWall> m_ERaiseWaterWall;
|
||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<PadSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<PadSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
|
||||
dd::EventRelay<PadSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||
dd::EventRelay<PadSystem, dd::Events::StickyAttachedToPad> m_EStickyAttachedToPad;
|
||||
dd::EventRelay<PadSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
@@ -133,9 +139,12 @@ private:
|
||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnResetAll(const dd::Events::ResetAll &event);
|
||||
bool OnRaiseWater(const dd::Events::RaiseWater &event);
|
||||
bool OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event);
|
||||
bool RaisePad(float amount, float speed);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
|
||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||
bool OnStickyAttachedToPad(const dd::Events::StickyAttachedToPad &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EKrakenAttack.h"
|
||||
#include "Game/EKrakenAttackEnd.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/CProjectile.h"
|
||||
@@ -55,7 +57,9 @@ private:
|
||||
bool m_Pause = false;
|
||||
bool m_InkBlaster = false;
|
||||
bool m_SquidLoaded = false;
|
||||
bool m_KrakenAttack = false;
|
||||
int m_Shots = 0;
|
||||
float m_InkBlasterSpeed = 5;
|
||||
EntityID m_InkBlastTemplate;
|
||||
EntityID m_AttachedSquid;
|
||||
|
||||
@@ -63,6 +67,8 @@ private:
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::KrakenAttack> m_EKrakenAttack;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::KrakenAttackEnd> m_EKrakenAttackEnd;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
|
||||
@@ -70,6 +76,8 @@ private:
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnKrakenAttack(const dd::Events::KrakenAttack &event);
|
||||
bool OnKrakenAttackEnd(const dd::Events::KrakenAttackEnd &event);
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-20.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_WATERSYSTEM_H
|
||||
#define DAYDREAM_WATERSYSTEM_H
|
||||
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Transform/EMove.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
#include "Game/ERelevantObjectCreated.h"
|
||||
#include "Game/ERaiseWater.h"
|
||||
#include "Game/ERaiseWaterWall.h"
|
||||
#include "Game/EArrivedAtNewStage.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class WaterSystem : public System
|
||||
{
|
||||
public:
|
||||
WaterSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
bool m_Pause = false;
|
||||
EntityID m_BottomWall = 0;
|
||||
|
||||
dd::EventRelay<WaterSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<WaterSystem, dd::Events::Resume> m_EResume;
|
||||
dd::EventRelay<WaterSystem, dd::Events::RelevantObjectCreated> m_ERelevantObjectCreated;
|
||||
dd::EventRelay<WaterSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<WaterSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
|
||||
dd::EventRelay<WaterSystem, dd::Events::RaiseWater> m_ERaiseWater;
|
||||
dd::EventRelay<WaterSystem, dd::Events::RaiseWaterWall> m_ERaiseWaterWall;
|
||||
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnResume(const dd::Events::Resume &event);
|
||||
bool OnRelevantObjectCreated(const dd::Events::RelevantObjectCreated &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnArrivedAtNewStage(const dd::Events::ArrivedAtNewStage &event);
|
||||
bool OnRaiseWater(const dd::Events::RaiseWater &event);
|
||||
bool OnRaiseWaterWall(const dd::Events::RaiseWaterWall &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_WATERSYSTEM_H
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
|
||||
#include "Sound/EPlaySound.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
@@ -27,7 +27,13 @@
|
||||
// OpenGL
|
||||
#include <GL/glew.h>
|
||||
#define GLFW_INCLUDE_GLU
|
||||
#define NOMINMAX
|
||||
#include <GLFW/glfw3.h>
|
||||
#ifdef BUILD_RENDERER_DIRECTX
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#define GLFW_EXPOSE_NATIVE_WGL
|
||||
#include <GLFW/glfw3native.h>
|
||||
#endif
|
||||
#include <glext.h>
|
||||
#include "Core/Util/GLError.h"
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "Rendering/CAnimation.h"
|
||||
#include "Rendering/EAnimationComplete.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/Model.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EResume.h"
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DD_BASERENDERER_H__
|
||||
#define DD_BASERENDERER_H__
|
||||
|
||||
#include "Core/Util/Rectangle.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Rendering/Camera.h"
|
||||
#include "Rendering/RenderQueue.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class BaseRenderer
|
||||
{
|
||||
public:
|
||||
GLFWwindow* Window() const { return m_Window; }
|
||||
Rectangle Resolution() const { return m_Resolution; }
|
||||
void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; }
|
||||
bool Fullscreen() { return m_Fullscreen; }
|
||||
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
|
||||
bool VSYNC() const { return m_VSYNC; }
|
||||
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
|
||||
const dd::Camera* Camera() const { return m_Camera; }
|
||||
void SetCamera(const dd::Camera* camera)
|
||||
{
|
||||
if (camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera.get();
|
||||
} else {
|
||||
m_Camera = camera;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Initialize() = 0;
|
||||
virtual void Draw(RenderQueueCollection& rq) = 0;
|
||||
|
||||
protected:
|
||||
Rectangle m_Resolution = Rectangle(1280, 720);
|
||||
bool m_Fullscreen = false;
|
||||
bool m_VSYNC = false;
|
||||
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
|
||||
const dd::Camera* m_Camera = nullptr;
|
||||
GLFWwindow* m_Window = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Renderer_h__
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BaseTexture_h__
|
||||
#define BaseTexture_h__
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Rendering/PNG.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class BaseTexture : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
public:
|
||||
unsigned int Width = 0;
|
||||
unsigned int Height = 0;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,7 @@ struct Animation : Component
|
||||
std::string Name;
|
||||
double Time = 0.0;
|
||||
double Speed = 0.0;
|
||||
bool Loop = true;
|
||||
bool NoRootMotion = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#define Components_PointLight_h__
|
||||
|
||||
#include "Core/Component.h"
|
||||
#include "Core/Color.h"
|
||||
#include "Rendering/Color.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
@@ -65,15 +65,15 @@ public:
|
||||
float FarClip() const { return m_FarClip; }
|
||||
void SetFarClip(float val);
|
||||
|
||||
private:
|
||||
void UpdateViewMatrix();
|
||||
void UpdateProjectionMatrix();
|
||||
|
||||
float m_AspectRatio;
|
||||
float m_FOV;
|
||||
float m_NearClip;
|
||||
float m_FarClip;
|
||||
|
||||
private:
|
||||
void UpdateViewMatrix();
|
||||
void UpdateProjectionMatrix();
|
||||
|
||||
glm::vec3 m_Position;
|
||||
glm::quat m_Orientation;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef Model_h__
|
||||
#define Model_h__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#include "Rendering/RawModel.h"
|
||||
#include "Core/StaticSystem.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Model : public RawModel
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
private:
|
||||
Model(std::string fileName);
|
||||
|
||||
public:
|
||||
~Model();
|
||||
|
||||
ID3D11Buffer* VertexBuffer = nullptr;
|
||||
ID3D11Buffer* IndexBuffer = nullptr;
|
||||
unsigned int NumVertices;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Model_h__
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DD_RENDERER_H__
|
||||
#define DD_RENDERER_H__
|
||||
|
||||
#include <d3d11.h>
|
||||
#pragma comment (lib, "d3d11.lib")
|
||||
#include <DirectXTK/SimpleMath.h>
|
||||
using namespace DirectX::SimpleMath;
|
||||
//#pragma comment (lib, "DirectXTK.lib")
|
||||
|
||||
#include "Rendering/BaseRenderer.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Model;
|
||||
class ShaderProgram;
|
||||
|
||||
class Renderer : public BaseRenderer
|
||||
{
|
||||
public:
|
||||
~Renderer();
|
||||
|
||||
void Initialize() override;
|
||||
void Draw(RenderQueueCollection& rq) override;
|
||||
|
||||
D3D11_RASTERIZER_DESC m_RasterDesc;
|
||||
|
||||
IDXGISwapChain* m_SwapChain = nullptr;
|
||||
ID3D11Device* m_Device = nullptr;
|
||||
ID3D11RasterizerState* m_RasterState = nullptr;
|
||||
ID3D11DeviceContext* m_DeviceContext = nullptr;
|
||||
ID3D11RenderTargetView* m_BackBuffer = nullptr;
|
||||
ID3D11DepthStencilView* m_DepthBuffer = nullptr;
|
||||
ID3D11SamplerState* m_SamplerState = nullptr;
|
||||
|
||||
private:
|
||||
struct ConstantBufferStruct
|
||||
{
|
||||
Matrix MVP;
|
||||
Matrix ModelMatrix;
|
||||
Matrix ViewMatrix;
|
||||
Matrix ProjectionMatrix;
|
||||
Matrix InverseTransposeViewModel;
|
||||
Vector4 Color;
|
||||
Vector4 LightPositions[10];
|
||||
Vector4 LightColors[10];
|
||||
float LightRadii[10];
|
||||
unsigned int NumLights;
|
||||
float paddingBitch;
|
||||
} constantBufferStruct;
|
||||
|
||||
ShaderProgram* m_ForwardShaderProgram = nullptr;
|
||||
ShaderProgram* m_GUIShaderProgram = nullptr;
|
||||
ID3D11Buffer* constantBuffer = nullptr;
|
||||
|
||||
Model* m_UnitQuad = nullptr;
|
||||
Texture* m_WhiteSphereTexture = nullptr;
|
||||
|
||||
static DirectX::SimpleMath::Matrix GLMtoDXModelView(glm::mat4 m);
|
||||
static DirectX::SimpleMath::Matrix GLMtoDXProjection(glm::mat4 m);
|
||||
void setDefaultRasterState();
|
||||
void setGUIRasterState();
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Renderer_h__
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef ShaderProgram_h__
|
||||
#define ShaderProgram_h__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <d3dcompiler.h>
|
||||
#pragma comment (lib, "D3DCompiler.lib")
|
||||
|
||||
#include "Core/StaticSystem.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class ShaderProgram
|
||||
{
|
||||
public:
|
||||
ShaderProgram();
|
||||
~ShaderProgram();
|
||||
|
||||
void CompileVertexShader(std::wstring filename);
|
||||
void CompilePixelShader(std::wstring filename);
|
||||
|
||||
HRESULT CreateInputLayout(D3D11_INPUT_ELEMENT_DESC* ied, UINT numElements);
|
||||
ID3D11InputLayout* GetInputLayout() const { return m_InputLayout; }
|
||||
|
||||
void Bind();
|
||||
void Unbind();
|
||||
|
||||
private:
|
||||
ID3D10Blob* m_VertexShaderBlob;
|
||||
ID3D11VertexShader* m_VertexShader;
|
||||
ID3D10Blob* m_PixelShaderBlob;
|
||||
ID3D11PixelShader* m_PixelShader;
|
||||
|
||||
ID3D11InputLayout* m_InputLayout;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ShaderProgram_h__
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Texture_h__
|
||||
#define Texture_h__
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#include "Rendering/BaseTexture.h"
|
||||
#include "Core/StaticSystem.h"
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Texture : public BaseTexture
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
private:
|
||||
Texture(std::string path);
|
||||
|
||||
public:
|
||||
~Texture();
|
||||
|
||||
operator ID3D11Texture2D*() { return m_Texture; }
|
||||
|
||||
ID3D11Texture2D* m_Texture = nullptr;
|
||||
ID3D11ShaderResourceView* m_ShaderResourceView = nullptr;
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef RENDERING_EANIMATIONCOMPLETE_H__
|
||||
#define RENDERING_EANIMATIONCOMPLETE_H__
|
||||
|
||||
#include "Core/Entity.h"
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AnimationComplete
|
||||
{
|
||||
EntityID Entity;
|
||||
std::string Animation;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Executable → Regular
@@ -30,7 +30,7 @@
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Model_h__
|
||||
#define Model_h__
|
||||
|
||||
#include "Rendering/RawModel.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Model : public RawModel
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
private:
|
||||
Model(std::string fileName);
|
||||
|
||||
public:
|
||||
~Model();
|
||||
|
||||
GLuint VAO;
|
||||
GLuint ElementBuffer;
|
||||
|
||||
private:
|
||||
GLuint VertexBuffer;
|
||||
GLuint DiffuseVertexColorBuffer;
|
||||
GLuint SpecularVertexColorBuffer;
|
||||
GLuint NormalBuffer;
|
||||
GLuint TangentNormalsBuffer;
|
||||
GLuint BiTangentNormalsBuffer;
|
||||
GLuint TextureCoordBuffer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Model_h__
|
||||
@@ -19,7 +19,11 @@
|
||||
#ifndef DD_RENDERER_H__
|
||||
#define DD_RENDERER_H__
|
||||
|
||||
#include "Util/Rectangle.h"
|
||||
#include "Rendering/BaseRenderer.h"
|
||||
#include "Core/Util/Rectangle.h"
|
||||
#include "Rendering/Camera.h"
|
||||
#include "Rendering/RenderQueue.h"
|
||||
#include "Rendering/ShaderProgram.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
@@ -28,46 +32,22 @@
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Game/EScreenShake.h"
|
||||
#include "Camera.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "ShaderProgram.h"
|
||||
#include "Rendering/Model.h"
|
||||
#include "Rendering/Texture.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Renderer
|
||||
class Renderer : public BaseRenderer
|
||||
{
|
||||
public:
|
||||
GLFWwindow* Window() const { return m_Window; }
|
||||
Rectangle Resolution() const { return m_Resolution; }
|
||||
void SetResolution(const Rectangle& resolution) { m_Resolution = resolution; }
|
||||
bool Fullscreen() { return m_Fullscreen; }
|
||||
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
|
||||
bool VSYNC() const { return m_VSYNC; }
|
||||
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
|
||||
const dd::Camera* Camera() const { return m_Camera; }
|
||||
void SetCamera(const dd::Camera* camera)
|
||||
{
|
||||
if (camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera.get();
|
||||
} else {
|
||||
m_Camera = camera;
|
||||
}
|
||||
}
|
||||
void Initialize();
|
||||
void Draw(RenderQueueCollection& rq);
|
||||
void Initialize() override;
|
||||
void Draw(RenderQueueCollection& rq) override;
|
||||
void PlaceCamera(glm::vec3 position);
|
||||
|
||||
private:
|
||||
Rectangle m_Resolution = Rectangle(1280, 720);
|
||||
bool m_Fullscreen = false;
|
||||
bool m_VSYNC = false;
|
||||
std::unique_ptr<dd::Camera> m_DefaultCamera = nullptr;
|
||||
const dd::Camera* m_Camera = nullptr;
|
||||
|
||||
int m_GLVersion[2];
|
||||
std::string m_GLVendor;
|
||||
GLFWwindow* m_Window = nullptr;
|
||||
|
||||
ShaderProgram* m_SpDeferred1;
|
||||
ShaderProgram* m_SpDeferred2;
|
||||
@@ -80,6 +60,7 @@ private:
|
||||
GLuint m_ScreenQuad = 0;
|
||||
Model* m_UnitSphere = nullptr;
|
||||
Model* m_UnitQuad = nullptr;
|
||||
Texture* m_ErrorTexture;
|
||||
Texture* m_StandardNormal;
|
||||
Texture* m_StandardSpecular;
|
||||
Texture* m_WhiteSphereTexture;
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -19,17 +19,12 @@
|
||||
#ifndef Texture_h__
|
||||
#define Texture_h__
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <cstdio>
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "PNG.h"
|
||||
#include "Rendering/BaseTexture.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Texture : public Resource
|
||||
class Texture : public BaseTexture
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
@@ -41,16 +36,9 @@ public:
|
||||
|
||||
void Bind(GLenum textureUnit = GL_TEXTURE0);
|
||||
|
||||
operator GLuint() const { return m_Texture; }
|
||||
|
||||
unsigned int Width = 0;
|
||||
unsigned int Height = 0;
|
||||
|
||||
private:
|
||||
GLuint m_Texture = 0;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // Texture_h__
|
||||
@@ -16,8 +16,8 @@
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Model_h__
|
||||
#define Model_h__
|
||||
#ifndef RawModel_h__
|
||||
#define RawModel_h__
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
@@ -34,21 +34,21 @@
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/Texture.h"
|
||||
#include "Core/Skeleton.h"
|
||||
#include "Rendering/Texture.h"
|
||||
#include "Rendering/Skeleton.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Model : public Resource
|
||||
class RawModel : public Resource
|
||||
{
|
||||
friend class ResourceManager;
|
||||
|
||||
private:
|
||||
Model(std::string fileName);
|
||||
protected:
|
||||
RawModel(std::string fileName);
|
||||
|
||||
public:
|
||||
~Model();
|
||||
~RawModel();
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
@@ -75,17 +75,11 @@ public:
|
||||
unsigned int EndIndex;
|
||||
};
|
||||
|
||||
GLuint VAO;
|
||||
GLuint ElementBuffer;
|
||||
std::vector<MaterialGroup> TextureGroups;
|
||||
|
||||
std::vector<std::shared_ptr<Texture>> texture;
|
||||
glm::mat4 GetMatrix();
|
||||
std::vector<glm::vec3> Vertices;
|
||||
std::vector<Vertex> m_Vertices;
|
||||
std::vector<unsigned int> m_Indices;
|
||||
Skeleton* m_Skeleton = nullptr;
|
||||
|
||||
glm::mat4 m_Matrix;
|
||||
|
||||
private:
|
||||
@@ -98,17 +92,9 @@ private:
|
||||
std::vector<glm::vec3> BiTangentNormals;
|
||||
std::vector<glm::vec2> TextureCoords;
|
||||
|
||||
GLuint VertexBuffer;
|
||||
GLuint DiffuseVertexColorBuffer;
|
||||
GLuint SpecularVertexColorBuffer;
|
||||
GLuint NormalBuffer;
|
||||
GLuint TangentNormalsBuffer;
|
||||
GLuint BiTangentNormalsBuffer;
|
||||
GLuint TextureCoordBuffer;
|
||||
|
||||
void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Model_h__
|
||||
#endif
|
||||
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RenderQueue_h__
|
||||
#define RenderQueue_h__
|
||||
|
||||
#include <cstdint>
|
||||
#include <forward_list>
|
||||
|
||||
#include "Core/Util/Rectangle.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Model;
|
||||
class Skeleton;
|
||||
class Texture;
|
||||
class RenderQueue;
|
||||
|
||||
struct RenderJob
|
||||
{
|
||||
friend class RenderQueue;
|
||||
|
||||
float Depth;
|
||||
|
||||
protected:
|
||||
uint64_t Hash;
|
||||
|
||||
virtual void CalculateHash() = 0;
|
||||
|
||||
bool operator<(const RenderJob& rhs)
|
||||
{
|
||||
return this->Hash < rhs.Hash;
|
||||
}
|
||||
};
|
||||
|
||||
struct ModelJob : RenderJob
|
||||
{
|
||||
unsigned int ShaderID = 0;
|
||||
unsigned int TextureID = 0;
|
||||
|
||||
glm::mat4 ModelMatrix;
|
||||
const Texture* DiffuseTexture;
|
||||
const Texture* NormalTexture;
|
||||
const Texture* SpecularTexture;
|
||||
float Shininess = 0.f;
|
||||
glm::vec4 Color;
|
||||
const dd::Model* Model = nullptr;
|
||||
unsigned int StartIndex = 0;
|
||||
unsigned int EndIndex = 0;
|
||||
|
||||
// Animation
|
||||
dd::Skeleton* Skeleton = nullptr;
|
||||
bool NoRootMotion = true;
|
||||
std::string AnimationName;
|
||||
double AnimationTime = 0;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = TextureID;
|
||||
}
|
||||
};
|
||||
|
||||
struct SpriteJob : RenderJob
|
||||
{
|
||||
unsigned int ShaderID = 0;
|
||||
unsigned int TextureID = 0;
|
||||
|
||||
glm::mat4 ModelMatrix;
|
||||
const Texture* DiffuseTexture = nullptr;
|
||||
const Texture* NormalTexture = nullptr;
|
||||
const Texture* SpecularTexture = nullptr;
|
||||
glm::vec4 Color;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = TextureID;
|
||||
}
|
||||
};
|
||||
|
||||
struct PointLightJob : RenderJob
|
||||
{
|
||||
glm::vec3 Position;
|
||||
glm::vec3 SpecularColor = glm::vec3(1, 1, 1);
|
||||
glm::vec3 DiffuseColor = glm::vec3(1, 1, 1);
|
||||
float Radius = 1.f;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct FrameJob : SpriteJob
|
||||
{
|
||||
Rectangle Scissor;
|
||||
Rectangle Viewport;
|
||||
std::string Name;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct WaterParticleJob : RenderJob
|
||||
{
|
||||
glm::vec3 Position;
|
||||
glm::vec4 Color;
|
||||
glm::mat4 ModelMatrix;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
Hash = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class RenderQueue
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
void Add(T &job)
|
||||
{
|
||||
job.CalculateHash();
|
||||
Jobs.push_back(std::shared_ptr<T>(new T(job)));
|
||||
m_Size++;
|
||||
}
|
||||
|
||||
void Sort()
|
||||
{
|
||||
Jobs.sort();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Jobs.clear();
|
||||
m_Size = 0;
|
||||
}
|
||||
|
||||
int Size() const { return m_Size; }
|
||||
std::list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
||||
{
|
||||
return Jobs.begin();
|
||||
}
|
||||
|
||||
std::list<std::shared_ptr<RenderJob>>::const_iterator end()
|
||||
{
|
||||
return Jobs.end();
|
||||
}
|
||||
|
||||
std::list<std::shared_ptr<RenderJob>> Jobs;
|
||||
|
||||
private:
|
||||
int m_Size = 0;
|
||||
};
|
||||
|
||||
struct RenderQueueCollection
|
||||
{
|
||||
RenderQueue Deferred;
|
||||
RenderQueue Forward;
|
||||
RenderQueue Lights;
|
||||
RenderQueue GUI;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Deferred.Clear();
|
||||
Forward.Clear();
|
||||
Lights.Clear();
|
||||
GUI.Clear();
|
||||
}
|
||||
|
||||
void Sort()
|
||||
{
|
||||
Deferred.Sort();
|
||||
Forward.Sort();
|
||||
Lights.Sort();
|
||||
GUI.Sort();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RenderQueue_h__
|
||||
@@ -41,6 +41,7 @@ private:
|
||||
const std::string MENU_BGM = "Sounds/BGM/eastern-music.wav";
|
||||
const std::string GAME_BGM = "Sounds/BGM/under-the-sea-n.wav";
|
||||
const std::string WATER_BGM = "Sounds/BGM/water-flowing.wav";
|
||||
const std::string STORY_VOICE = "Sounds/jap-story.wav";
|
||||
|
||||
float m_BGMMasterVolume = 1.f;
|
||||
float m_SFXMasterVolume = 1.f;
|
||||
|
||||
Reference in New Issue
Block a user