Eventbaserade partiklar. Fick nån krasch i physicssystem efter ett tags spelande, men det hoppas jag löser sig när jag mergar in Viktors senaste fysikfixar :3
This commit is contained in:
+29
-11
@@ -137,7 +137,6 @@ public:
|
||||
|
||||
|
||||
//OctoBall
|
||||
/*
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
@@ -159,7 +158,7 @@ public:
|
||||
plight->Radius = 2.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
}*/
|
||||
}
|
||||
|
||||
//PointLightTest
|
||||
{
|
||||
@@ -212,8 +211,8 @@ public:
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -5.5f, -10.f);
|
||||
transform->Scale = glm::vec3(0.2f, 0.2f, 1.f);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 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);
|
||||
@@ -221,18 +220,37 @@ public:
|
||||
|
||||
//ParticleTest
|
||||
{
|
||||
Events::CreateParticleSequence e;
|
||||
e.Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
e.SpriteFile = "Textures/Background.png";
|
||||
e.GravityScale = 0.0f;
|
||||
e.SpawnRate = 1.f;
|
||||
e.NumberOfTicks = 2;
|
||||
e.Speed = 1.f;
|
||||
e.ParticlesPerTick = 5;
|
||||
e.Spread = glm::pi<float>() * 2;
|
||||
e.EmittingAngle = glm::pi<float>();
|
||||
e.EmitterLifeTime = 50;
|
||||
e.ParticleLifeTime = 3.f;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
/*{
|
||||
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.1f;
|
||||
particleEmitter->NumberOfTicks = 1000;
|
||||
particleEmitter->Speed = 2.f;
|
||||
particleEmitter->SpawnRate = 1.f;
|
||||
particleEmitter->NumberOfTicks = 2;
|
||||
particleEmitter->Speed = 1.f;
|
||||
particleEmitter->ParticlesPerTick = 5;
|
||||
particleEmitter->Spread = glm::pi<float>()/2;
|
||||
particleEmitter->Spread = glm::pi<float>()*2;
|
||||
particleEmitter->EmittingAngle = glm::pi<float>();
|
||||
particleEmitter->LifeTime = 50;
|
||||
|
||||
{
|
||||
auto Pt = m_World->CreateEntity(Pe);
|
||||
@@ -244,11 +262,11 @@ public:
|
||||
//PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
|
||||
PtTransform->Position = transform->Position;
|
||||
PtSprite->SpriteFile = "Textures/Background.png";
|
||||
PtParticle->LifeTime = 1.f;
|
||||
PtParticle->LifeTime = 3.f;
|
||||
PtParticle->Flags = ParticleFlags::Type::powderParticle | ParticleFlags::Type::particleContactFilterParticle | ParticleFlags::Type::fixtureContactFilterParticle;
|
||||
}
|
||||
m_World->CommitEntity(Pe);
|
||||
}
|
||||
}*/
|
||||
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
@@ -361,7 +379,7 @@ public:
|
||||
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, -13.5f, -10.f);
|
||||
ctransform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
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);
|
||||
|
||||
@@ -18,6 +18,7 @@ struct ParticleEmitter : public Component
|
||||
float EmittingAngle = 0.f;
|
||||
float Spread = 0.f;
|
||||
float Speed = 2.f;
|
||||
double LifeTime = 100;
|
||||
|
||||
//ParticleSystem variables
|
||||
float GravityScale = 1.0f;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef EVENTS_ECREATEPARTICLESEQUENCE_H__
|
||||
#define EVENTS_ECREATEPARTICLESEQUENCE_H__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Physics/CParticle.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct CreateParticleSequence : public Event
|
||||
{
|
||||
//Emitter
|
||||
double EmitterLifeTime = 100;
|
||||
glm::vec3 Position = glm::vec3(0);
|
||||
float GravityScale = 0.f;
|
||||
float SpawnRate = 1.f;
|
||||
int NumberOfTicks = 100;
|
||||
float Speed = 1.f;
|
||||
int ParticlesPerTick = 1.f;
|
||||
float Spread = glm::pi<float>();
|
||||
float EmittingAngle = glm::two_pi<float>();
|
||||
float MaxCount = 0;
|
||||
|
||||
//Particle
|
||||
std::string SpriteFile = "Texures/Core/ErrorTexture.png";
|
||||
double ParticleLifeTime = 3.f;
|
||||
ParticleFlags::Type Flags = ParticleFlags::Type::powderParticle | ParticleFlags::Type::particleContactFilterParticle | ParticleFlags::Type::fixtureContactFilterParticle;
|
||||
float Radius = 1.f;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/CPad.h"
|
||||
@@ -47,6 +48,9 @@ public:
|
||||
EventRelay<PhysicsSystem, Events::SetImpulse> m_SetImpulse;
|
||||
bool SetImpulse(const Events::SetImpulse &event);
|
||||
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
bool CreateParticleSequence(const Events::CreateParticleSequence &event);
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "Sound/CCollisionSound.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user