2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-08-17 23:46:41 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <array>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CRandom16.hpp"
|
|
|
|
#include "Runtime/CToken.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
#include "Runtime/Graphics/CLight.hpp"
|
|
|
|
#include "Runtime/Graphics/CLineRenderer.hpp"
|
|
|
|
#include "Runtime/Graphics/Shaders/CElementGenShaders.hpp"
|
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/Particle/CParticleGen.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CAABox.hpp>
|
|
|
|
#include <zeus/CColor.hpp>
|
|
|
|
#include <zeus/CTransform.hpp>
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2015-08-21 00:06:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2020-03-09 16:33:22 +00:00
|
|
|
class CActorLights;
|
2016-02-08 05:10:17 +00:00
|
|
|
class CGenDescription;
|
2020-03-09 16:33:22 +00:00
|
|
|
class CLight;
|
2016-02-11 22:38:25 +00:00
|
|
|
class CParticleElectric;
|
2020-03-09 16:33:22 +00:00
|
|
|
class CParticleSwoosh;
|
|
|
|
class CWarp;
|
|
|
|
class IGenDescription;
|
2015-08-17 23:46:41 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CElementGen : public CParticleGen {
|
|
|
|
static u16 g_GlobalSeed;
|
|
|
|
static bool g_subtractBlend;
|
|
|
|
|
2016-02-08 05:10:17 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
static void SetGlobalSeed(u16 seed) { g_GlobalSeed = seed; }
|
|
|
|
static void SetSubtractBlend(bool s) { g_subtractBlend = s; }
|
|
|
|
enum class EModelOrientationType { Normal, One };
|
|
|
|
enum class EOptionalSystemFlags { None, One, Two };
|
|
|
|
enum class LightType { None = 0, Custom = 1, Directional = 2, Spot = 3 };
|
|
|
|
class CParticleListItem {
|
|
|
|
friend class CElementGen;
|
|
|
|
s16 x0_partIdx;
|
|
|
|
zeus::CVector3f x4_viewPoint;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CParticleListItem(s16 idx) : x0_partIdx(idx) {}
|
|
|
|
};
|
|
|
|
static CParticle* g_currentParticle;
|
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
friend class CElementGenShaders;
|
|
|
|
TLockedToken<CGenDescription> x1c_genDesc;
|
|
|
|
CGenDescription* x28_loadedGenDesc;
|
|
|
|
EModelOrientationType x2c_orientType;
|
|
|
|
std::vector<CParticle> x30_particles;
|
|
|
|
std::vector<u32> x40;
|
|
|
|
std::vector<zeus::CMatrix3f> x50_parentMatrices;
|
|
|
|
std::vector<std::array<float, 8>> x60_advValues;
|
|
|
|
|
|
|
|
int x70_internalStartFrame = 0;
|
|
|
|
int x74_curFrame = 0;
|
|
|
|
double x78_curSeconds = 0.f;
|
|
|
|
float x80_timeDeltaScale;
|
|
|
|
int x84_prevFrame = -1;
|
|
|
|
bool x88_particleEmission = true;
|
|
|
|
float x8c_generatorRemainder = 0.f;
|
|
|
|
int x90_MAXP = 0;
|
|
|
|
int m_maxMAXP = 256;
|
2019-01-05 03:28:02 +00:00
|
|
|
u16 x94_randomSeed = g_GlobalSeed;
|
2018-12-08 05:30:43 +00:00
|
|
|
float x98_generatorRate = 1.f;
|
2020-03-09 16:37:15 +00:00
|
|
|
std::array<float, 16> x9c_externalVars{};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
zeus::CVector3f xdc_translation;
|
|
|
|
zeus::CVector3f xe8_globalTranslation;
|
|
|
|
zeus::CVector3f xf4_POFS;
|
|
|
|
zeus::CVector3f x100_globalScale = {1.f, 1.f, 1.f};
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CTransform x10c_globalScaleTransform = zeus::CTransform();
|
|
|
|
zeus::CTransform x13c_globalScaleTransformInverse = zeus::CTransform();
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f x16c_localScale = {1.f, 1.f, 1.f};
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CTransform x178_localScaleTransform = zeus::CTransform();
|
|
|
|
zeus::CTransform x1a8_localScaleTransformInverse = zeus::CTransform();
|
|
|
|
zeus::CTransform x1d8_orientation = zeus::CTransform();
|
|
|
|
zeus::CTransform x208_orientationInverse = zeus::CTransform();
|
|
|
|
zeus::CTransform x22c_globalOrientation = zeus::CTransform();
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
u32 x25c_activeParticleCount = 0;
|
|
|
|
u32 x260_cumulativeParticles = 0;
|
|
|
|
u32 x264_recursiveParticleCount = 0;
|
|
|
|
int x268_PSLT;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
bool x26c_24_translationDirty : 1;
|
|
|
|
bool x26c_25_LIT_ : 1;
|
|
|
|
bool x26c_26_AAPH : 1;
|
|
|
|
bool x26c_27_ZBUF : 1;
|
|
|
|
bool x26c_28_zTest : 1;
|
|
|
|
bool x26c_29_ORNT : 1;
|
|
|
|
bool x26c_30_MBLR : 1;
|
|
|
|
bool x26c_31_LINE : 1;
|
|
|
|
bool x26d_24_FXLL : 1;
|
|
|
|
bool x26d_25_warmedUp : 1;
|
|
|
|
bool x26d_26_modelsUseLights : 1;
|
|
|
|
bool x26d_27_enableOPTS : 1;
|
|
|
|
bool x26d_28_enableADV : 1;
|
2017-05-06 05:21:42 +00:00
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 _dummy = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
int x270_MBSP = 0;
|
|
|
|
int m_maxMBSP = 0;
|
|
|
|
ERglLightBits x274_backupLightActive = ERglLightBits::None;
|
2020-03-09 16:37:15 +00:00
|
|
|
std::array<bool, 4> x278_hasVMD{};
|
2018-12-08 05:30:43 +00:00
|
|
|
CRandom16 x27c_randState;
|
2020-03-09 16:37:15 +00:00
|
|
|
std::array<CModVectorElement*, 4> x280_VELSources{};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
std::vector<std::unique_ptr<CParticleGen>> x290_activePartChildren;
|
|
|
|
int x2a0_CSSD = 0;
|
|
|
|
int x2a4_SISY = 16;
|
|
|
|
int x2a8_PISY = 16;
|
|
|
|
int x2ac_SSSD = 0;
|
|
|
|
zeus::CVector3f x2b0_SSPO;
|
|
|
|
int x2bc_SESD = 0;
|
|
|
|
zeus::CVector3f x2c0_SEPO;
|
|
|
|
float x2cc = 0.f;
|
|
|
|
float x2d0 = 0.f;
|
|
|
|
zeus::CVector3f x2d4_aabbMin;
|
|
|
|
zeus::CVector3f x2e0_aabbMax;
|
|
|
|
float x2ec_maxSize = 0.f;
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CAABox x2f0_systemBounds = zeus::CAABox();
|
2018-12-08 05:30:43 +00:00
|
|
|
LightType x308_lightType;
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CColor x30c_LCLR = zeus::skWhite;
|
2018-12-08 05:30:43 +00:00
|
|
|
float x310_LINT = 1.f;
|
|
|
|
zeus::CVector3f x314_LOFF;
|
|
|
|
zeus::CVector3f x320_LDIR = {1.f, 0.f, 0.f};
|
|
|
|
EFalloffType x32c_falloffType = EFalloffType::Linear;
|
|
|
|
float x330_LFOR = 1.f;
|
|
|
|
float x334_LSLA = 45.f;
|
|
|
|
zeus::CColor x338_moduColor = {1.f, 1.f, 1.f, 1.f};
|
|
|
|
|
|
|
|
std::unique_ptr<CLineRenderer> m_lineRenderer;
|
|
|
|
CElementGenShaders::EShaderClass m_shaderClass;
|
|
|
|
|
|
|
|
void AccumulateBounds(const zeus::CVector3f& pos, float size);
|
2016-02-11 02:36:21 +00:00
|
|
|
|
2015-08-18 05:54:43 +00:00
|
|
|
public:
|
2020-03-09 17:07:51 +00:00
|
|
|
explicit CElementGen(TToken<CGenDescription> gen, EModelOrientationType orientType = EModelOrientationType::Normal,
|
|
|
|
EOptionalSystemFlags flags = EOptionalSystemFlags::One);
|
2019-08-09 12:45:18 +00:00
|
|
|
~CElementGen() override;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-03-09 16:37:15 +00:00
|
|
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_normalDataBind;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_normalSubDataBind;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_redToAlphaDataBind;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_redToAlphaSubDataBind;
|
2018-12-08 05:30:43 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBufferD> m_instBuf;
|
|
|
|
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuf;
|
|
|
|
|
2020-03-09 16:37:15 +00:00
|
|
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_normalDataBindPmus;
|
|
|
|
std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_redToAlphaDataBindPmus;
|
2018-12-08 05:30:43 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBufferD> m_instBufPmus;
|
|
|
|
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBufPmus;
|
|
|
|
|
|
|
|
CGenDescription* GetDesc() { return x1c_genDesc.GetObj(); }
|
|
|
|
const SObjectTag* GetDescTag() const { return x1c_genDesc.GetObjectTag(); }
|
|
|
|
|
|
|
|
static bool g_ParticleSystemInitialized;
|
|
|
|
static int g_ParticleAliveCount;
|
|
|
|
static int g_ParticleSystemAliveCount;
|
|
|
|
static bool sMoveRedToAlphaBuffer;
|
|
|
|
static void Initialize();
|
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
void UpdateAdvanceAccessParameters(u32 activeParticleCount, u32 particleFrame);
|
2020-03-09 16:37:15 +00:00
|
|
|
bool UpdateVelocitySource(size_t idx, u32 particleFrame, CParticle& particle);
|
2018-12-08 05:30:43 +00:00
|
|
|
void UpdateExistingParticles();
|
|
|
|
void CreateNewParticles(int);
|
|
|
|
void UpdatePSTranslationAndOrientation();
|
|
|
|
void UpdateChildParticleSystems(double);
|
2019-08-14 10:04:11 +00:00
|
|
|
std::unique_ptr<CParticleGen> ConstructChildParticleSystem(const TToken<CGenDescription>&) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
void UpdateLightParameters();
|
|
|
|
void BuildParticleSystemBounds();
|
|
|
|
u32 GetEmitterTime() const { return x74_curFrame; }
|
2020-03-09 17:03:40 +00:00
|
|
|
u32 GetSystemCount() const;
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 GetCumulativeParticleCount() const { return x260_cumulativeParticles; }
|
|
|
|
u32 GetParticleCountAllInternal() const;
|
|
|
|
u32 GetParticleCountAll() const { return x264_recursiveParticleCount; }
|
|
|
|
void EndLifetime();
|
|
|
|
void ForceParticleCreation(int amount);
|
2019-11-19 23:06:25 +00:00
|
|
|
float GetExternalVar(int i) const { return x9c_externalVars[i]; }
|
2019-12-03 08:47:05 +00:00
|
|
|
void SetExternalVar(int i, float v) { x9c_externalVars[i] = v; }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
bool InternalUpdate(double);
|
|
|
|
void RenderModels(const CActorLights* actLights);
|
|
|
|
void RenderLines();
|
|
|
|
void RenderParticles();
|
|
|
|
void RenderParticlesIndirectTexture();
|
|
|
|
|
2019-08-09 12:45:18 +00:00
|
|
|
bool Update(double) override;
|
|
|
|
void Render(const CActorLights* = nullptr) override;
|
|
|
|
void SetOrientation(const zeus::CTransform&) override;
|
|
|
|
void SetTranslation(const zeus::CVector3f&) override;
|
|
|
|
void SetGlobalOrientation(const zeus::CTransform&) override;
|
|
|
|
void SetGlobalTranslation(const zeus::CVector3f&) override;
|
|
|
|
void SetGlobalScale(const zeus::CVector3f&) override;
|
|
|
|
void SetLocalScale(const zeus::CVector3f&) override;
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetGlobalOrientAndTrans(const zeus::CTransform& xf);
|
2019-08-09 12:45:18 +00:00
|
|
|
void SetParticleEmission(bool) override;
|
|
|
|
void SetModulationColor(const zeus::CColor&) override;
|
|
|
|
void SetGeneratorRate(float rate) override;
|
|
|
|
const zeus::CTransform& GetOrientation() const override;
|
|
|
|
const zeus::CVector3f& GetTranslation() const override;
|
|
|
|
const zeus::CTransform& GetGlobalOrientation() const override;
|
|
|
|
const zeus::CVector3f& GetGlobalTranslation() const override;
|
|
|
|
const zeus::CVector3f& GetGlobalScale() const override;
|
|
|
|
const zeus::CColor& GetModulationColor() const override;
|
|
|
|
float GetGeneratorRate() const override { return x98_generatorRate; }
|
|
|
|
bool IsSystemDeletable() const override;
|
|
|
|
std::optional<zeus::CAABox> GetBounds() const override;
|
|
|
|
u32 GetParticleCount() const override;
|
|
|
|
bool SystemHasLight() const override;
|
|
|
|
CLight GetLight() const override;
|
|
|
|
bool GetParticleEmission() const override;
|
|
|
|
void DestroyParticles() override;
|
|
|
|
void Reset() override;
|
|
|
|
FourCC Get4CharId() const override { return FOURCC('PART'); }
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t GetNumActiveChildParticles() const { return x290_activePartChildren.size(); }
|
|
|
|
CParticleGen& GetActiveChildParticle(size_t idx) const { return *x290_activePartChildren[idx]; }
|
|
|
|
bool IsIndirectTextured() const { return x28_loadedGenDesc->x54_x40_TEXR && x28_loadedGenDesc->x58_x44_TIND; }
|
|
|
|
void SetModelsUseLights(bool v) { x26d_26_modelsUseLights = v; }
|
2019-04-16 08:00:46 +00:00
|
|
|
void SetZTest(bool z) { x26c_28_zTest = z; }
|
2018-12-08 05:30:43 +00:00
|
|
|
static void SetMoveRedToAlphaBuffer(bool);
|
|
|
|
|
|
|
|
s32 GetMaxParticles() const { return x90_MAXP; }
|
2015-08-17 23:46:41 +00:00
|
|
|
};
|
2016-02-09 22:52:33 +00:00
|
|
|
ENABLE_BITWISE_ENUM(CElementGen::EOptionalSystemFlags)
|
2015-08-17 23:46:41 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|