2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-05 08:34:14 +00:00
|
|
|
|
2017-06-04 01:01:09 +00:00
|
|
|
#include <array>
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CColor.hpp>
|
|
|
|
#include <zeus/CMatrix4f.hpp>
|
|
|
|
#include <zeus/CVector3f.hpp>
|
|
|
|
#include <zeus/CVector4f.hpp>
|
2016-02-06 07:31:53 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-03-19 02:04:12 +00:00
|
|
|
class CElementGen;
|
2018-12-08 05:30:43 +00:00
|
|
|
class CParticleGlobals {
|
2020-04-12 00:23:38 +00:00
|
|
|
CParticleGlobals() = default;
|
2019-12-03 08:47:05 +00:00
|
|
|
static std::unique_ptr<CParticleGlobals> g_ParticleGlobals;
|
2020-04-12 00:23:38 +00:00
|
|
|
|
2016-02-05 08:34:14 +00:00
|
|
|
public:
|
2019-12-03 08:47:05 +00:00
|
|
|
int m_EmitterTime = 0;
|
|
|
|
float m_EmitterTimeReal = 0.f;
|
|
|
|
void SetEmitterTime(int frame) {
|
|
|
|
m_EmitterTime = frame;
|
2020-04-13 22:44:47 +00:00
|
|
|
m_EmitterTimeReal = float(frame);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-02-05 08:34:14 +00:00
|
|
|
|
2019-12-03 08:47:05 +00:00
|
|
|
int m_ParticleLifetime = 0;
|
|
|
|
float m_ParticleLifetimeReal = 0.f;
|
|
|
|
void SetParticleLifetime(int frame) {
|
|
|
|
m_ParticleLifetime = frame;
|
2020-04-13 22:44:47 +00:00
|
|
|
m_ParticleLifetimeReal = float(frame);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-02-05 08:34:14 +00:00
|
|
|
|
2019-12-03 08:47:05 +00:00
|
|
|
int m_ParticleLifetimePercentage = 0;
|
|
|
|
float m_ParticleLifetimePercentageReal = 0.f;
|
|
|
|
float m_ParticleLifetimePercentageRemainder = 0.f;
|
|
|
|
void UpdateParticleLifetimeTweenValues(int frame) {
|
2020-04-13 22:44:47 +00:00
|
|
|
const float lt = m_ParticleLifetime != 0 ? float(m_ParticleLifetime) : 1.0f;
|
|
|
|
m_ParticleLifetimePercentageReal = 100.0f * float(frame) / lt;
|
2019-12-03 08:47:05 +00:00
|
|
|
m_ParticleLifetimePercentage = int(m_ParticleLifetimePercentageReal);
|
2020-04-13 22:44:47 +00:00
|
|
|
m_ParticleLifetimePercentageRemainder = m_ParticleLifetimePercentageReal - float(m_ParticleLifetimePercentage);
|
2019-12-03 08:47:05 +00:00
|
|
|
m_ParticleLifetimePercentage = zeus::clamp(0, m_ParticleLifetimePercentage, 100);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-02-06 07:31:53 +00:00
|
|
|
|
2019-12-03 08:47:05 +00:00
|
|
|
const std::array<float, 8>* m_particleAccessParameters = nullptr;
|
2016-02-06 07:31:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SParticleSystem {
|
|
|
|
FourCC x0_type;
|
|
|
|
CElementGen* x4_system;
|
|
|
|
};
|
2016-02-14 07:38:01 +00:00
|
|
|
|
2020-04-12 00:23:38 +00:00
|
|
|
SParticleSystem* m_currentParticleSystem = nullptr;
|
2019-12-03 08:47:05 +00:00
|
|
|
|
|
|
|
static CParticleGlobals* instance() {
|
|
|
|
if (!g_ParticleGlobals)
|
|
|
|
g_ParticleGlobals.reset(new CParticleGlobals());
|
|
|
|
|
|
|
|
return g_ParticleGlobals.get();
|
|
|
|
}
|
2016-02-05 08:34:14 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SParticleInstanceTex {
|
2020-04-12 00:29:36 +00:00
|
|
|
std::array<zeus::CVector4f, 4> pos;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor color;
|
2020-04-12 00:29:36 +00:00
|
|
|
std::array<zeus::CVector2f, 4> uvs;
|
2018-03-17 03:41:01 +00:00
|
|
|
};
|
|
|
|
extern std::vector<SParticleInstanceTex> g_instTexData;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SParticleInstanceIndTex {
|
2020-04-12 00:29:36 +00:00
|
|
|
std::array<zeus::CVector4f, 4> pos;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor color;
|
2020-04-12 00:29:36 +00:00
|
|
|
std::array<zeus::CVector4f, 4> texrTindUVs;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector4f sceneUVs;
|
2018-03-17 03:41:01 +00:00
|
|
|
};
|
|
|
|
extern std::vector<SParticleInstanceIndTex> g_instIndTexData;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SParticleInstanceNoTex {
|
2020-04-12 00:29:36 +00:00
|
|
|
std::array<zeus::CVector4f, 4> pos;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor color;
|
2018-03-17 03:41:01 +00:00
|
|
|
};
|
|
|
|
extern std::vector<SParticleInstanceNoTex> g_instNoTexData;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SParticleUniforms {
|
|
|
|
zeus::CMatrix4f mvp;
|
|
|
|
zeus::CColor moduColor;
|
2018-03-17 03:41:01 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|