Some pretty darn cool explosions
This commit is contained in:
+1
-1
Submodule assets updated: 4724dbbd28...bd746269ff
@@ -11,7 +11,6 @@ namespace Components
|
||||
|
||||
struct Particle : Component
|
||||
{
|
||||
std::vector<Color> ColorSpectrum;
|
||||
std::vector<glm::vec3> ScaleSpectrum;
|
||||
double LifeTime;
|
||||
double SpawnTime;
|
||||
|
||||
@@ -19,13 +19,14 @@ struct ParticleEmitter : Component
|
||||
, SpawnCount(0)
|
||||
, SpreadAngle(0)
|
||||
, LifeTime(0)
|
||||
, TimeSinceLastSpawn(100) { } // TEMP fulhack så att partiklarna spawnar direkt
|
||||
, TimeSinceLastSpawn(100)
|
||||
, Color(glm::vec4(0)) { }
|
||||
|
||||
EntityID ParticleTemplate;
|
||||
float SpawnFrequency;
|
||||
float Speed;
|
||||
int SpawnCount;
|
||||
std::vector<Color> ColorSpectrum;
|
||||
glm::vec4 Color;
|
||||
std::vector<glm::vec3> ScaleSpectrum;
|
||||
float SpreadAngle;
|
||||
double LifeTime;
|
||||
|
||||
@@ -9,14 +9,17 @@ namespace Events
|
||||
{
|
||||
struct CreateExplosion : Event
|
||||
{
|
||||
CreateExplosion()
|
||||
: Color(glm::vec4(0)) {}
|
||||
glm::vec3 Position;
|
||||
glm::vec4 Color;
|
||||
double LifeTime;
|
||||
int ParticlesToSpawn;
|
||||
std::string spritePath;
|
||||
glm::quat RelativeUpOrientation;
|
||||
float Speed;
|
||||
float SpreadAngle;
|
||||
float ParticleScale;
|
||||
std::vector<float> ParticleScale;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ void Renderer::LoadContent()
|
||||
FrameBufferTextures();
|
||||
|
||||
m_sphereModel = ResourceManager->Load<Model>("Model", "Models/Placeholders/PhysicsTest/Sphere.obj");
|
||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/sky36", "jpg");
|
||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/sunset", "jpg");
|
||||
}
|
||||
|
||||
void Renderer::Draw(double dt)
|
||||
|
||||
+1
-1
@@ -201,7 +201,7 @@ private:
|
||||
void CreateNormalMapTangent();
|
||||
void ForwardRendering(RenderQueue &rq);
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth > j->Depth); }
|
||||
|
||||
GLuint CreateQuad();
|
||||
void DrawDebugShadowMap();
|
||||
|
||||
@@ -95,6 +95,9 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
ScalarInterpolation(timeProgress, spectrum, alpha);
|
||||
sprite->Color.w = alpha;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*// Angular velocity interpolation
|
||||
if (particleComponent->AngularVelocitySpectrum.size() != 0)
|
||||
{
|
||||
@@ -161,6 +164,10 @@ void Systems::ParticleSystem::SpawnParticles(EntityID emitterID)
|
||||
particle->VelocitySpectrum.push_back(particleTransform->Velocity);
|
||||
particle->Fade = eComponent->Fade;
|
||||
|
||||
auto sprite = m_World->GetComponent<Components::Sprite>(ent);
|
||||
if(eComponent->Color != glm::vec4(0))
|
||||
sprite->Color = eComponent->Color;
|
||||
|
||||
if (eComponent->ScaleSpectrum.size() > 0)
|
||||
{
|
||||
if (eComponent->ScaleSpectrum.size() > 1)
|
||||
@@ -235,9 +242,15 @@ bool Systems::ParticleSystem::CreateExplosion(const Events::CreateExplosion &e)
|
||||
emitter->SpawnCount = e.ParticlesToSpawn;
|
||||
emitter->Speed = e.Speed;
|
||||
emitter->SpreadAngle = e.SpreadAngle;
|
||||
emitter->ScaleSpectrum.push_back(glm::vec3(e.ParticleScale));
|
||||
//emitter->ScaleSpectrum.push_back(glm::vec3(e.ParticleScale));
|
||||
emitter->SpawnFrequency = e.LifeTime + 20; //temp
|
||||
emitter->Fade = true;
|
||||
emitter->Color = e.Color;
|
||||
std::vector<glm::vec3> scale;
|
||||
scale.push_back(glm::vec3(e.ParticleScale[0]));
|
||||
if(e.ParticleScale.size() >= 2)
|
||||
scale.push_back(glm::vec3(e.ParticleScale[1]));
|
||||
emitter->ScaleSpectrum = scale;
|
||||
// emitter->GoalVelocity = glm::vec3(0,-_speed, 0);
|
||||
m_World->CommitEntity(explosion);
|
||||
|
||||
|
||||
@@ -130,23 +130,35 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
||||
|
||||
{
|
||||
Events::CreateExplosion e;
|
||||
e.LifeTime = 2;
|
||||
e.ParticleScale = 8;
|
||||
e.ParticlesToSpawn = 10;
|
||||
e.LifeTime = 3;
|
||||
e.ParticleScale.push_back(8);
|
||||
e.ParticlesToSpawn = 20;
|
||||
e.Position = shellTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 3;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||
EventBroker->Publish(e);
|
||||
e.LifeTime = 1;
|
||||
e.ParticleScale = 12;
|
||||
e.LifeTime = 0.7;
|
||||
e.ParticleScale.push_back(12);
|
||||
e.ParticlesToSpawn = 10;
|
||||
e.Position = shellTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 17;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/Fire.png";
|
||||
EventBroker->Publish(e);
|
||||
e.LifeTime = 0.2;
|
||||
e.ParticleScale.push_back(1);
|
||||
e.ParticleScale.push_back(15);
|
||||
e.ParticlesToSpawn = 5;
|
||||
e.Position = shellTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 6;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/Fire.png";
|
||||
e.spritePath = "Textures/Sprites/Blast1.png";
|
||||
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user