Merge and some small fixes
This commit is contained in:
Regular → Executable
+833
-835
File diff suppressed because it is too large
Load Diff
+40
-39
@@ -133,10 +133,10 @@ public:
|
||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
ball->Speed = 5.f;
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
ball->Speed = 10.f;
|
||||
auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
plight->Radius = 2.f;
|
||||
|
||||
@@ -169,8 +169,8 @@ public:
|
||||
{
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -20.f);
|
||||
transform->Scale = glm::vec3(2681.f / 100.f, 1080.f / 100.f, 1.f);
|
||||
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);
|
||||
@@ -180,18 +180,19 @@ public:
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -1.f, -10.f);
|
||||
transform->Scale = glm::vec3(2.f, 3.f, 1.f);
|
||||
transform->Position = glm::vec3(0.f, -4.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.f, 1.5f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, -3.f, -9.9f);
|
||||
transform->Scale = glm::vec3(3.f, 0.5f, 1.f);
|
||||
transform->Position = glm::vec3(0.f, -6.f, -9.9f);
|
||||
transform->Scale = glm::vec3(10.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> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
@@ -201,33 +202,33 @@ public:
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
//SideBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(1.5f, -1.5f, -9.9f);
|
||||
transform->Scale = glm::vec3(0.5f, 3.f, 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> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
//OtherSideBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(-1.5f, -1.5f, -9.9f);
|
||||
transform->Scale = glm::vec3(0.5f, 3.0f, 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> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
// {
|
||||
// auto topWall = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
// transform->Position = glm::vec3(3.f, -3.0f, -9.9f);
|
||||
// transform->Scale = glm::vec3(0.5f, 3.f, 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> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
// topWall);
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
// physics->Static = true;
|
||||
// m_World->CommitEntity(topWall);
|
||||
// }
|
||||
// //OtherSideBox
|
||||
// {
|
||||
// auto topWall = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
// transform->Position = glm::vec3(-4.f, -3.0f, -9.9f);
|
||||
// transform->Scale = glm::vec3(0.5f, 3.0f, 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> boxShape = m_World->AddComponent<Components::RectangleShape>(
|
||||
// topWall);
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
// physics->Static = true;
|
||||
// m_World->CommitEntity(topWall);
|
||||
// }
|
||||
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
@@ -291,13 +292,13 @@ public:
|
||||
m_World->SetProperty(ent, "Name", "Pad");
|
||||
auto ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(0.f, -5.f, -10.f);
|
||||
ctransform->Scale = glm::vec3(1.6, 0.4, 0.);
|
||||
ctransform->Scale = glm::vec3(1.0f, 1.0f, 1.f);
|
||||
auto rectangle = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
auto csprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Submarine.obj";
|
||||
auto pad = m_World->AddComponent<Components::Pad>(ent);
|
||||
csprite->SpriteFile = "Textures/Pad.png";
|
||||
m_World->CommitEntity(ent);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,543 +0,0 @@
|
||||
/*
|
||||
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 "Core/EventBroker.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "CTemplate.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/CBrick.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
class Engine
|
||||
{
|
||||
public:
|
||||
Engine(int argc, char* argv[]) {
|
||||
m_EventBroker = std::make_shared<EventBroker>();
|
||||
|
||||
m_Renderer = std::make_shared<Renderer>();
|
||||
m_Renderer->SetFullscreen(false);
|
||||
//m_Renderer->SetResolution(Rectangle(0, 0, 1920, 1080));
|
||||
m_Renderer->SetResolution(Rectangle(0, 0, 675, 1080));
|
||||
m_Renderer->Initialize();
|
||||
|
||||
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::Life>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
|
||||
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::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->ComponentFactory.Register<Components::Model>();
|
||||
m_World->ComponentFactory.Register<Components::Template>();
|
||||
m_World->ComponentFactory.Register<Components::PointLight>();
|
||||
m_World->ComponentFactory.Register<Components::WaterVolume>();
|
||||
m_World->Initialize();
|
||||
|
||||
|
||||
//OctoBall
|
||||
<<<<<<< HEAD
|
||||
// {
|
||||
// auto ent = m_World->CreateEntity();
|
||||
// std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
// transform->Position = glm::vec3(0.5f, 0.f, -9.9f);
|
||||
// transform->Scale = glm::vec3(1.f, 1.f, 1.f);
|
||||
// transform->Velocity = glm::vec3(1.0f, -5.f, 0.f);
|
||||
//
|
||||
// auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
// model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||
//
|
||||
// std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
// std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
//
|
||||
// std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
// physics->Static = false;
|
||||
//
|
||||
// auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
// plight->Radius = 2.f;
|
||||
//
|
||||
// m_World->CommitEntity(ent);
|
||||
// }
|
||||
=======
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
transform->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
||||
|
||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||
|
||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
ball->Speed = 10.f;
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
|
||||
auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
plight->Radius = 2.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
|
||||
}
|
||||
>>>>>>> 72413dc0a93bd3a2f6ab9fa7e19bbc3b846232db
|
||||
|
||||
//PointLightTest
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(2.f, 1.5f, -9.f);
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 8.f;
|
||||
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(15.f);
|
||||
// auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
// model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
// model->Color = glm::vec4(1.f, 1.f, 1.f, 0.3f);
|
||||
// m_World->CommitEntity(t_halfPipe);
|
||||
// }
|
||||
|
||||
//Background
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -15.f);
|
||||
transform->Scale = glm::vec3(2681.f/100.f, 1080.f/100.f, 1.f);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(background);
|
||||
sprite->SpriteFile = "Textures/Background.png";
|
||||
m_World->CommitEntity(background);
|
||||
}
|
||||
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -1.f, -10.f);
|
||||
transform->Scale = glm::vec3(2.f, 3.f, 1.f);
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
//BottomBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(0.f, -3.f, -9.9f);
|
||||
transform->Scale = glm::vec3(3.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> boxShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
//SideBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(1.5f, -1.5f, -9.9f);
|
||||
transform->Scale = glm::vec3(0.5f, 3.f, 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> boxShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
//OtherSideBox
|
||||
{
|
||||
auto topWall = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(topWall);
|
||||
transform->Position = glm::vec3(-1.5f, -1.5f, -9.9f);
|
||||
transform->Scale = glm::vec3(0.5f, 3.0f, 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> boxShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = true;
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
|
||||
=======
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -13.f);
|
||||
transform->Scale = glm::vec3(5.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
}
|
||||
|
||||
>>>>>>> 72413dc0a93bd3a2f6ab9fa7e19bbc3b846232db
|
||||
{
|
||||
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> boxShape = m_World->AddComponent<Components::RectangleShape>(topWall);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(topWall);
|
||||
physics->Static = 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> boxShape = m_World->AddComponent<Components::RectangleShape>(leftWall);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(leftWall);
|
||||
physics->Static = 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> boxShape = m_World->AddComponent<Components::RectangleShape>(rightWall);
|
||||
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(rightWall);
|
||||
physics->Static = true;
|
||||
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Pad");
|
||||
auto ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(0.f, -5.f, -10.f);
|
||||
ctransform->Scale = glm::vec3(1.6, 0.4, 0.);
|
||||
auto rectangle = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
auto csprite = m_World->AddComponent<Components::Sprite>(ent);
|
||||
auto pad = m_World->AddComponent<Components::Pad>(ent);
|
||||
csprite->SpriteFile = "Textures/Pad.png";
|
||||
m_World->CommitEntity(ent);
|
||||
}
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
}
|
||||
|
||||
bool Running() const { return !glfwWindowShouldClose(m_Renderer->Window()); }
|
||||
|
||||
void Tick()
|
||||
{
|
||||
double currentTime = glfwGetTime();
|
||||
double dt = currentTime - m_LastTime;
|
||||
m_LastTime = currentTime;
|
||||
|
||||
ResourceManager::Update();
|
||||
|
||||
// Update input
|
||||
m_InputManager->Update(dt);
|
||||
|
||||
m_World->Update(dt);
|
||||
|
||||
|
||||
//
|
||||
// if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) {
|
||||
// ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl");
|
||||
// }
|
||||
//
|
||||
//TODO Fill up the renderQueue with models (Temp fix)
|
||||
// TEMPAddToRenderQueue();
|
||||
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
// m_Renderer->Draw(m_RendererQueue);
|
||||
|
||||
if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) {
|
||||
ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl");
|
||||
}
|
||||
|
||||
//TODO Fill up the renderQueue with models (Temp fix)
|
||||
TEMPAddToRenderQueue();
|
||||
|
||||
// Render scene
|
||||
//TODO send renderqueue to draw.
|
||||
m_Renderer->Draw(m_RendererQueue);
|
||||
|
||||
// Swap event queues
|
||||
m_EventBroker->Clear();
|
||||
|
||||
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>();
|
||||
|
||||
m_RendererQueue.Clear();
|
||||
|
||||
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);
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color, modelComponent->ModelFile);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
m_RendererQueue.Sort();
|
||||
}
|
||||
|
||||
//TODO: Get this out of engine.h
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color, std::string fileName)
|
||||
{
|
||||
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;
|
||||
job.Color = color;
|
||||
job.fileName = fileName;
|
||||
|
||||
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<ResourceManager> m_ResourceManager;
|
||||
std::shared_ptr<EventBroker> m_EventBroker;
|
||||
std::shared_ptr<Renderer> m_Renderer;
|
||||
RenderQueueCollection m_RendererQueue;
|
||||
std::shared_ptr<InputManager> m_InputManager;
|
||||
std::shared_ptr<World> m_World;
|
||||
|
||||
|
||||
double m_LastTime;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -226,8 +226,8 @@ void dd::Renderer::CreateBuffers()
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Resolution.Width, m_Resolution.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
//Fill waterBlur pass
|
||||
glGenFramebuffers(1, &t_m_fbWaterBlur);
|
||||
@@ -247,8 +247,8 @@ void dd::Renderer::CreateBuffers()
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Resolution.Width, m_Resolution.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
//Fill waterBlur pass2
|
||||
glGenFramebuffers(1, &t_m_fbWaterBlur2);
|
||||
@@ -267,8 +267,8 @@ void dd::Renderer::CreateBuffers()
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Resolution.Width, m_Resolution.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// Create third pass framebuffer
|
||||
glGenFramebuffers(1, &m_fbDeferred3);
|
||||
@@ -537,10 +537,11 @@ void dd::Renderer::DrawWater(RenderQueue &rq)
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
t_m_spWater2->Bind();
|
||||
float radius = 3.f;
|
||||
|
||||
glUniform2fv(glGetUniformLocation(shaderProgramHandle, "dir"), 1, glm::value_ptr(glm::vec2(1.0f, 0.0f)));
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "res"), m_Resolution.Width);
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "radius"), 3.0f);
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "radius"), radius);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, t_m_Gwater);
|
||||
@@ -560,7 +561,7 @@ void dd::Renderer::DrawWater(RenderQueue &rq)
|
||||
|
||||
glUniform2fv(glGetUniformLocation(shaderProgramHandle, "dir"), 1, glm::value_ptr(glm::vec2(0.0f, 1.0f)));
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "res"), m_Resolution.Height);
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "radius"), 3.0f);
|
||||
glUniform1f(glGetUniformLocation(shaderProgramHandle, "radius"), radius);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, t_m_BWater);
|
||||
@@ -665,6 +666,9 @@ void dd::Renderer::DebugKeys()
|
||||
m_CurrentScreenBuffer = m_tLighting;
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_F7)) {
|
||||
m_CurrentScreenBuffer = t_m_BWater;
|
||||
m_CurrentScreenBuffer = t_m_Gwater;
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_F8)) {
|
||||
m_CurrentScreenBuffer = t_m_BWater;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ EntityID dd::Systems::PadSystem::CreateBall()
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
|
||||
cball->Speed = 10;
|
||||
cball->Speed = 5.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ void dd::Systems::PhysicsSystem::Initialize()
|
||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||
{
|
||||
b2ParticleSystemDef m_ParticleSystemDef;
|
||||
m_ParticleSystemDef.radius = 0.1f;
|
||||
m_ParticleSystemDef.radius = 0.13f;
|
||||
|
||||
m_ParticleSystem = m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef);
|
||||
}
|
||||
@@ -265,7 +265,6 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
shape.SetAsBox(transform->Scale.x/2.f, transform->Scale.y/2.f);
|
||||
pd.shape = &shape;
|
||||
pd.flags = b2_tensileParticle;
|
||||
pd.linearVelocity = b2Vec2(0, 5.f);
|
||||
pd.position.Set(transform->Position.x, transform->Position.y);
|
||||
//TODO: PUT IN LIST
|
||||
t_watergroup = m_ParticleSystem->CreateParticleGroup(pd);
|
||||
@@ -276,8 +275,6 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
auto transformChild = m_World->AddComponent<Components::Transform>(t_waterparticle);
|
||||
//auto sprite = m_World->AddComponent<Components::Sprite>(t_waterparticle);
|
||||
|
||||
|
||||
|
||||
transformChild->Position = glm::vec3(t_ParticlePositions[i].x - transform->Position.x, t_ParticlePositions[i].y - transform->Position.y, -9.5f);
|
||||
transformChild->Scale = glm::vec3(m_ParticleSystem->GetRadius())/transform->Scale;
|
||||
//sprite->SpriteFile = "Textures/Ball.png";
|
||||
|
||||
Reference in New Issue
Block a user