Merge remote-tracking branch 'origin/master' into Sound

Conflicts:
	include/Core/Engine.h
This commit is contained in:
Stiffly
2015-09-17 13:18:56 +02:00
44 changed files with 18806 additions and 228 deletions
+30 -42
View File
@@ -79,7 +79,6 @@ public:
m_World->SystemFactory.Register<Systems::Sound>([this]() { return new Systems::Sound(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::Sound>();
m_World->ComponentFactory.Register<Components::Sprite>();
m_World->ComponentFactory.Register<Components::RectangleShape>();
@@ -107,14 +106,15 @@ public:
/*{
}*/
//OctoBall
{
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);
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
sprite->SpriteFile = "Textures/Ball.png";
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);
@@ -134,26 +134,34 @@ public:
m_EventBroker->Publish(e);
}
//PointLightTest
{
auto t_BrickWall = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
transform->Position = glm::vec3(0.f, 0.f, -10.f);
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
//TODO: Rename SpriteFile to DiffuseTexture or similar.
sprite->SpriteFile = "Textures/Ball.png";
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
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;
}
//Halfpipe background test model.
{
auto t_BrickWall = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_BrickWall);
transform->Position = glm::vec3(0.4f, 0.f, -9.5f);
auto sprite = m_World->AddComponent<Components::Sprite>(t_BrickWall);
//TODO: Rename SpriteFile to DiffuseTexture or similar.
sprite->SpriteFile = "Textures/Ball.png";
sprite->NormalTexture = "Textures/Test/Brick_Normal.png";
sprite->SpecularTexture = "Textures/Test/Brick_Specular.png";
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";
}
//Brick test model
{
auto t_Brick = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_Brick);
transform->Position = glm::vec3(0.f, 0.f, -12.f);
transform->Orientation = glm::rotate(glm::quat(), 0.5f, glm::vec3(0,-1,-1));
auto model = m_World->AddComponent<Components::Model>(t_Brick);
model->ModelFile = "Models/Test/Brick/Brick.obj";
}
{
@@ -205,25 +213,6 @@ public:
m_World->CommitEntity(rightWall);
}
/*{
auto ent = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(0.f, -3.f, -10.f);
transform->Scale = glm::vec3(8.f, 0.5f, 1.f);
transform->Orientation = glm::rotate(transform->Orientation, glm::radians(25.f), glm::vec3(0, 0, -1));
std::shared_ptr<Components::Sprite> sprite = m_World->AddComponent<Components::Sprite>(ent);
sprite->SpriteFile = "Textures/Core/ErrorTexture.png";
std::shared_ptr<Components::RectangleShape> boxShape = m_World->AddComponent<Components::RectangleShape>(ent);
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
physics->Static = true;
m_World->CommitEntity(ent);
}*/
{
auto ent = m_World->CreateEntity();
m_World->SetProperty(ent, "Name", "Pad");
@@ -322,7 +311,7 @@ public:
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
* glm::toMat4(absoluteTransform.Orientation)
* glm::scale(absoluteTransform.Scale);
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color);
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color, modelComponent->ModelFile);
}
}
@@ -370,7 +359,7 @@ public:
}
//TODO: Get this out of engine.h
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color)
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color, std::string fileName)
{
for (auto texGroup : model->TextureGroups)
{
@@ -385,8 +374,7 @@ public:
job.EndIndex = texGroup.EndIndex;
job.ModelMatrix = modelMatrix;
job.Color = color;
//TODO: This Depth is probably wrong.
job.Depth = (glm::vec4(1,1,1,0) * modelMatrix).z;
job.fileName = fileName;
m_RendererQueue.Deferred.Add(job);
}
-9
View File
@@ -121,8 +121,6 @@ public:
int Process(std::string contextTypeName);
void Clear();
void Unsubscribe(BaseEventRelay &relay);
template <typename ContextType>
void UnsubscribeAll();
private:
typedef std::string ContextTypeName_t; // typeid(ContextType).name()
@@ -156,13 +154,6 @@ int EventBroker::Process()
return Process(contextTypeName);
}
template <typename ContextType>
void EventBroker::UnsubscribeAll()
{
const std::string contextTypeName = typeid(ContextType).name();
m_ContextRelays.erase(contextTypeName);
}
}
#endif // MessageRelay_h__
+2
View File
@@ -52,6 +52,8 @@ struct ModelJob : RenderJob
unsigned int ShaderID;
unsigned int TextureID;
std::string fileName;
glm::mat4 ModelMatrix;
GLuint DiffuseTexture;
GLuint NormalTexture;
+2
View File
@@ -76,6 +76,8 @@ private:
GLuint m_ScreenQuad = 0;
Model* m_UnitSphere = nullptr;
Model* m_UnitQuad = nullptr;
Texture* m_StandardNormal;
Texture* m_StandardSpecular;
GLuint m_rbDepthBuffer = 0;
GLuint m_fbDeferred1 = 0;
+1 -1
View File
@@ -195,7 +195,7 @@ public:
// Triggers commit events in systems
// TODO: Replace completely by EComponentCreated?
void CommitEntity(EntityID entity);
int CommitEntity(EntityID entity);
/** Get all components of a specific type.
+1 -1
View File
@@ -15,7 +15,7 @@ namespace Components
struct Ball : Component
{
int number = 0;
int Number = 0;
};
}
+1
View File
@@ -17,6 +17,7 @@ struct Brick : Component
{
int Points = 10;
int Hits = 1;
int Score = 50;
};
}
+2 -2
View File
@@ -1,5 +1,5 @@
//
// Created by Administrator on 2015-09-15.
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_CLIFE_H
@@ -15,7 +15,7 @@ namespace Components
struct Life : Component {
int number = 0;
int Number = 0;
};
+4
View File
@@ -19,6 +19,10 @@ struct Pad : Component
{
int Lives;
int Points;
float SlowdownModifier = 5.f;
float AccelerationSpeed = 80.f;
float MaxSpeed = 40.f;
};
}
+2 -2
View File
@@ -1,5 +1,5 @@
//
// Created by Administrator on 2015-09-15.
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_ELIFELOST_H
@@ -16,7 +16,7 @@ namespace Events
struct LifeLost : Event
{
EntityID entity;
EntityID Entity;
};
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_ERESETBALL_H
#define DAYDREAM_ERESETBALL_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct ResetBall : Event
{
};
}
}
#endif //DAYDREAM_ERESETBALL_H
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-09-15.
//
#ifndef DAYDREAM_ESCOREEVENT_H
#define DAYDREAM_ESCOREEVENT_H
#include "Core/EventBroker.h"
namespace dd
{
namespace Events
{
struct ScoreEvent : Event
{
int Score = 0;
};
}
}
#endif //DAYDREAM_ESCOREEVENT_H
Regular → Executable
+35 -12
View File
@@ -8,6 +8,7 @@
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Game/CBrick.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
@@ -15,6 +16,8 @@
#include "Game/CLife.h"
#include "Game/EStageCleared.h"
#include "Game/ELifeLost.h"
#include "Game/EResetBall.h"
#include "Game/EScoreEvent.h"
#include "Physics/CBoxShape.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
@@ -63,25 +66,45 @@ public:
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
int lives = 3;
int pastLives = 3;
bool Initialized() const { return m_Initialized; }
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
int& Lives() { return m_Lives; }
void SetLives(const int& lives) { m_Lives = lives; }
int& PastLives() { return m_PastLives; }
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
int& Score() { return m_Score; }
void SetScore(const int& score) { m_Score = score; }
int& NumberOfBricks() { return m_NumberOfBricks; }
void SetNumberOfBricks(const int& numberOfBricks) { m_NumberOfBricks = numberOfBricks; }
int& Rows() { return m_Rows; }
void SetRows(const int& rows) { m_Rows = rows; }
int& Lines() { return m_Lines; }
void SetLines(const int& lines) { m_Lines = lines; }
int& SpaceToEdge() { return m_SpaceToEdge; }
void SetSpaceToEdge(const int& spaceToEdge) { m_SpaceToEdge = spaceToEdge; }
glm::vec2& SpaceBetweenBricks() { return m_SpaceBetweenBricks; }
void SetSpaceBetweenBricks(const glm::vec2& spaceBetweenBricks) { m_SpaceBetweenBricks = spaceBetweenBricks; }
private:
bool m_Initialized = false;
int m_Lives = 3;
int m_PastLives = 3;
int m_Score = 0;
int m_NumberOfBricks;
int m_Rows = 7;
int m_Lines = 8;
int m_SpaceToEdge = 0;
glm::vec2 m_SpaceBetweenBricks = glm::vec2(2, 0.5);
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<LevelSystem, dd::Events::LifeLost> m_ELifeLost;
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
bool OnContact(const dd::Events::Contact &event);
bool LifeLost(const dd::Events::LifeLost &event);
bool m_Initialized = false;
int numberOfBricks;
int tRows = 7;
int tLines = 8;
glm::vec2 tSpaceBetweenBricks = glm::vec2(2, 0.5);
int tSpaceToEdge = 0;
EntityID entityToRemove = NULL;
bool ScoreEvent(const dd::Events::ScoreEvent &event);
};
}
Regular → Executable
+29 -21
View File
@@ -19,10 +19,10 @@
#include "Physics/CCircleShape.h"
#include "Physics/ESetImpulse.h"
#include "Rendering/CSprite.h"
#include "Rendering/CModel.h"
#include "Game/CBall.h"
#include "Game/ELifeLost.h"
#include "Game/EResetBall.h"
#include "CPad.h"
namespace dd
@@ -35,41 +35,49 @@ class PadSystem : public System
{
public:
PadSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
: System(world, eventBroker) { }
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
EntityID& Entity() { return m_Entity; }
void SetEntity(const EntityID& ent) { m_Entity = ent; }
glm::vec3 Acceleration() const { return m_Acceleration; }
void SetAcceleration(const glm::vec3& acceleration) { m_Acceleration = acceleration; }
bool Left() const { return m_Left; }
void SetLeft(const bool& left) { m_Left = left; }
bool Right() const { return m_Right; }
void SetRight(const bool& right) { m_Right = right; }
bool ReplaceBall() const { return m_ReplaceBall; }
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
Components::Transform* Transform() const { return m_Transform; }
void SetTransform(const Components::Transform* transform) { m_Transform = transform; }
Components::Pad* Pad() const { return m_Pad; }
void SetPad(const Components::Pad* pad) { m_Pad = pad; }
private:
EntityID m_Entity = 0;
glm::vec3 m_Acceleration = glm::vec3(0.f, 0.f, 0.f);
bool m_Left = false, m_Right = false, m_ReplaceBall = false;
Components::Transform* m_Transform;
Components::Pad* m_Pad;
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
dd::EventRelay<PadSystem, dd::Events::LifeLost> m_ELifeLost;
dd::EventRelay<PadSystem, dd::Events::ResetBall> m_EResetBall;
bool OnKeyDown(const dd::Events::KeyDown &event);
bool OnKeyUp(const dd::Events::KeyUp &event);
bool OnContact(const dd::Events::Contact &event);
bool LifeLost(const dd::Events::LifeLost &event);
EntityID removeThisObject = NULL;
float slowdownModifier = 5.f;
float accelerationSpeed = 80.f;
float maxSpeed = 40.f;
bool ResetBall(const dd::Events::ResetBall &event);
class PadSteeringInputController;
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
EntityID ent = 0;
Components::Transform* transform;
glm::vec3 acceleration = glm::vec3(0.f, 0.f, 0.f);
bool left = false, right = false, replaceBall = false;
};
class PadSystem::PadSteeringInputController : InputController<PadSystem>