2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CELEMENTGEN_HPP__
|
|
|
|
#define __URDE_CELEMENTGEN_HPP__
|
2015-08-17 23:46:41 +00:00
|
|
|
|
2016-02-11 22:38:25 +00:00
|
|
|
#include "RetroTypes.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "zeus/CTransform.hpp"
|
|
|
|
#include "zeus/CVector3f.hpp"
|
|
|
|
#include "zeus/CColor.hpp"
|
|
|
|
#include "zeus/CAABox.hpp"
|
2016-02-08 05:10:17 +00:00
|
|
|
#include "CToken.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "Graphics/CLight.hpp"
|
|
|
|
#include "Graphics/CGraphics.hpp"
|
2016-02-09 22:52:33 +00:00
|
|
|
#include "CRandom16.hpp"
|
2016-02-13 05:49:59 +00:00
|
|
|
#include "CParticleGen.hpp"
|
2017-06-10 05:34:39 +00:00
|
|
|
#include "Graphics/Shaders/CElementGenShaders.hpp"
|
2016-02-18 02:42:32 +00:00
|
|
|
#include "Graphics/CLineRenderer.hpp"
|
2017-05-08 19:10:09 +00:00
|
|
|
#include "Particle/CGenDescription.hpp"
|
2015-08-21 00:06:39 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 23:46:41 +00:00
|
|
|
{
|
2016-02-08 03:31:05 +00:00
|
|
|
class CWarp;
|
|
|
|
class CLight;
|
2016-02-11 23:05:42 +00:00
|
|
|
class IGenDescription;
|
2016-02-08 05:10:17 +00:00
|
|
|
class CGenDescription;
|
2016-02-11 22:38:25 +00:00
|
|
|
class CParticleSwoosh;
|
|
|
|
class CParticleElectric;
|
2015-08-17 23:46:41 +00:00
|
|
|
|
2016-02-13 05:49:59 +00:00
|
|
|
class CElementGen : public CParticleGen
|
2015-08-17 23:46:41 +00:00
|
|
|
{
|
2017-06-11 02:57:35 +00:00
|
|
|
static u16 g_GlobalSeed;
|
2016-02-08 05:10:17 +00:00
|
|
|
public:
|
2017-06-11 02:57:35 +00:00
|
|
|
static void SetGlobalSeed(u16 seed) { g_GlobalSeed = seed; }
|
2016-02-08 05:10:17 +00:00
|
|
|
enum class EModelOrientationType
|
|
|
|
{
|
2016-02-09 22:52:33 +00:00
|
|
|
Normal,
|
|
|
|
One
|
2016-02-08 05:10:17 +00:00
|
|
|
};
|
|
|
|
enum class EOptionalSystemFlags
|
2016-02-09 22:52:33 +00:00
|
|
|
{
|
|
|
|
None,
|
|
|
|
One,
|
|
|
|
Two
|
|
|
|
};
|
2016-02-13 05:16:39 +00:00
|
|
|
enum class LightType
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Custom = 1,
|
|
|
|
Directional = 2,
|
|
|
|
Spot = 3
|
|
|
|
};
|
2016-02-09 22:52:33 +00:00
|
|
|
class CParticleListItem
|
2016-02-08 05:10:17 +00:00
|
|
|
{
|
2016-02-11 02:36:21 +00:00
|
|
|
friend class CElementGen;
|
|
|
|
s16 x0_partIdx;
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::CVector3f x4_viewPoint;
|
2016-02-10 02:00:28 +00:00
|
|
|
public:
|
2016-02-11 02:36:21 +00:00
|
|
|
CParticleListItem(s16 idx)
|
2017-06-04 01:01:09 +00:00
|
|
|
: x0_partIdx(idx) {}
|
2016-02-10 02:00:28 +00:00
|
|
|
};
|
2016-02-25 06:23:35 +00:00
|
|
|
struct CParticle
|
2016-02-10 02:00:28 +00:00
|
|
|
{
|
2016-02-11 02:36:21 +00:00
|
|
|
int x0_endFrame = 0;
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::CVector3f x4_pos;
|
|
|
|
zeus::CVector3f x10_prevPos;
|
|
|
|
zeus::CVector3f x1c_vel;
|
2016-02-11 02:36:21 +00:00
|
|
|
int x28_startFrame = 0;
|
|
|
|
float x2c_lineLengthOrSize = 0.f;
|
|
|
|
float x30_lineWidthOrRota = 0.f;
|
2016-03-04 23:04:53 +00:00
|
|
|
zeus::CColor x34_color = {0.f, 0.f, 0.f, 1.f};
|
2016-02-08 05:10:17 +00:00
|
|
|
};
|
2016-02-25 06:23:35 +00:00
|
|
|
static CParticle* g_currentParticle;
|
2016-02-15 04:00:26 +00:00
|
|
|
private:
|
|
|
|
friend class CElementGenShaders;
|
2016-02-13 05:49:59 +00:00
|
|
|
TLockedToken<CGenDescription> x1c_genDesc;
|
2017-06-04 01:01:09 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
u32 x70_internalStartFrame = 0;
|
|
|
|
u32 x74_curFrame = 0;
|
|
|
|
double x78_curSeconds = 0.f;
|
|
|
|
float x80_timeDeltaScale;
|
|
|
|
u32 x84_prevFrame = -1;
|
|
|
|
bool x88_particleEmission = true;
|
|
|
|
float x8c_generatorRemainder = 0.f;
|
2017-05-06 05:21:42 +00:00
|
|
|
int x90_MAXP = 0;
|
|
|
|
u16 x94_randomSeed = 99;
|
2017-06-04 01:01:09 +00:00
|
|
|
float x98_generatorRate = 1.f;
|
2017-06-03 06:03:07 +00:00
|
|
|
float x9c_cextValues[16] = {};
|
2017-06-04 01:01:09 +00:00
|
|
|
|
|
|
|
zeus::CVector3f xdc_translation;
|
|
|
|
zeus::CVector3f xe8_globalTranslation;
|
2017-05-06 05:21:42 +00:00
|
|
|
zeus::CVector3f xf4_POFS;
|
2017-06-04 01:01:09 +00:00
|
|
|
zeus::CVector3f x100_globalScale = {1.f, 1.f, 1.f};
|
|
|
|
zeus::CTransform x10c_globalScaleTransform = zeus::CTransform::Identity();
|
|
|
|
zeus::CTransform x13c_globalScaleTransformInverse = zeus::CTransform::Identity();
|
|
|
|
zeus::CVector3f x16c_localScale = {1.f, 1.f, 1.f};
|
|
|
|
zeus::CTransform x178_localScaleTransform = zeus::CTransform::Identity();
|
|
|
|
zeus::CTransform x1a8_localScaleTransformInverse = zeus::CTransform::Identity();
|
|
|
|
zeus::CTransform x1d8_orientation = zeus::CTransform::Identity();
|
|
|
|
zeus::CTransform x208_orientationInverse = zeus::CTransform::Identity();
|
|
|
|
zeus::CTransform x22c_globalOrientation = zeus::CTransform::Identity();
|
|
|
|
|
|
|
|
u32 x25c_activeParticleCount = 0;
|
|
|
|
u32 x260_cumulativeParticles = 0;
|
|
|
|
u32 x264_recursiveParticleCount = 0;
|
|
|
|
int x268_PSLT;
|
2017-05-06 05:21:42 +00:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2017-06-04 01:01:09 +00:00
|
|
|
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;
|
2017-05-06 05:21:42 +00:00
|
|
|
bool x26c_31_LINE : 1;
|
|
|
|
bool x26d_24_FXLL : 1;
|
2017-06-04 01:01:09 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
u32 _dummy = 0;
|
|
|
|
};
|
|
|
|
|
2017-06-04 01:01:09 +00:00
|
|
|
int x270_MBSP = 0;
|
|
|
|
int m_maxMBSP = 0;
|
|
|
|
ERglLightBits x274_backupLightActive = ERglLightBits::None;
|
|
|
|
bool x278_hasVMD[4] = {};
|
2017-05-06 05:21:42 +00:00
|
|
|
CRandom16 x27c_randState;
|
2017-06-04 01:01:09 +00:00
|
|
|
CModVectorElement* x280_VELSources[4] = {};
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<CParticleGen>> x290_activePartChildren;
|
2017-05-06 05:21:42 +00:00
|
|
|
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;
|
2017-06-04 01:01:09 +00:00
|
|
|
float x2cc = 0.f;
|
|
|
|
float x2d0 = 0.f;
|
|
|
|
zeus::CVector3f x2d4_aabbMin;
|
|
|
|
zeus::CVector3f x2e0_aabbMax;
|
|
|
|
float x2ec_maxSize = 0.f;
|
|
|
|
zeus::CAABox x2f0_systemBounds = zeus::CAABox::skInvertedBox;
|
2017-05-06 05:21:42 +00:00
|
|
|
LightType x308_lightType;
|
2017-06-04 01:01:09 +00:00
|
|
|
zeus::CColor x30c_LCLR = zeus::CColor::skWhite;
|
|
|
|
float x310_LINT = 1.f;
|
|
|
|
zeus::CVector3f x314_LOFF;
|
|
|
|
zeus::CVector3f x320_LDIR = {1.f, 0.f, 0.f};
|
2017-05-06 05:21:42 +00:00
|
|
|
EFalloffType x32c_falloffType = EFalloffType::Linear;
|
2017-06-04 01:01:09 +00:00
|
|
|
float x330_LFOR = 1.f;
|
|
|
|
float x334_LSLA = 45.f;
|
|
|
|
zeus::CColor x338_moduColor = {1.f, 1.f, 1.f, 1.f};
|
2016-02-09 22:52:33 +00:00
|
|
|
|
2016-02-18 02:42:32 +00:00
|
|
|
std::unique_ptr<CLineRenderer> m_lineRenderer;
|
2016-02-15 04:00:26 +00:00
|
|
|
CElementGenShaders::EShaderClass m_shaderClass;
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void AccumulateBounds(zeus::CVector3f& pos, float size);
|
2016-02-11 02:36:21 +00:00
|
|
|
|
2015-08-18 05:54:43 +00:00
|
|
|
public:
|
2016-02-08 05:10:17 +00:00
|
|
|
CElementGen(const TToken<CGenDescription>& gen, EModelOrientationType orientType, EOptionalSystemFlags flags);
|
2016-02-13 05:49:59 +00:00
|
|
|
~CElementGen();
|
2016-02-08 05:10:17 +00:00
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
boo::GraphicsDataToken m_gfxToken;
|
2017-06-12 18:20:07 +00:00
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
boo::IShaderDataBinding* m_normalDataBind = nullptr;
|
|
|
|
boo::IShaderDataBinding* m_redToAlphaDataBind = nullptr;
|
|
|
|
boo::IGraphicsBufferD* m_instBuf = nullptr;
|
|
|
|
boo::IGraphicsBufferD* m_uniformBuf = nullptr;
|
|
|
|
|
2017-06-12 18:20:07 +00:00
|
|
|
boo::IShaderDataBinding* m_normalDataBindPmus = nullptr;
|
|
|
|
boo::IShaderDataBinding* m_redToAlphaDataBindPmus = nullptr;
|
|
|
|
boo::IGraphicsBufferD* m_instBufPmus = nullptr;
|
|
|
|
boo::IGraphicsBufferD* m_uniformBufPmus = nullptr;
|
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
CGenDescription* GetDesc() {return x1c_genDesc.GetObj();}
|
|
|
|
|
2017-06-04 01:01:09 +00:00
|
|
|
static bool g_ParticleSystemInitialized;
|
2016-02-13 05:49:59 +00:00
|
|
|
static int g_ParticleAliveCount;
|
|
|
|
static int g_ParticleSystemAliveCount;
|
2017-01-22 17:36:25 +00:00
|
|
|
static bool sMoveRedToAlphaBuffer;
|
2016-02-13 05:49:59 +00:00
|
|
|
static void Initialize();
|
2016-02-16 19:42:24 +00:00
|
|
|
static void Shutdown();
|
2015-11-02 18:45:39 +00:00
|
|
|
|
2017-06-04 01:01:09 +00:00
|
|
|
void UpdateAdvanceAccessParameters(u32 activeParticleCount, u32 particleFrame);
|
|
|
|
bool UpdateVelocitySource(u32 idx, u32 particleFrame, CParticle& particle);
|
2016-02-10 02:00:28 +00:00
|
|
|
void UpdateExistingParticles();
|
|
|
|
void CreateNewParticles(int);
|
|
|
|
void UpdatePSTranslationAndOrientation();
|
|
|
|
void UpdateChildParticleSystems(double);
|
2017-06-04 01:01:09 +00:00
|
|
|
std::unique_ptr<CParticleGen> ConstructChildParticleSystem(const TToken<CGenDescription>&);
|
2016-02-10 02:00:28 +00:00
|
|
|
void UpdateLightParameters();
|
2015-11-02 18:45:39 +00:00
|
|
|
void BuildParticleSystemBounds();
|
2017-06-04 01:01:09 +00:00
|
|
|
u32 GetEmitterTime() const { return x74_curFrame; }
|
2016-02-11 19:18:14 +00:00
|
|
|
u32 GetSystemCount();
|
2016-03-19 02:04:12 +00:00
|
|
|
u32 GetCumulativeParticleCount() const { return x260_cumulativeParticles; }
|
2016-02-11 22:38:25 +00:00
|
|
|
u32 GetParticleCountAllInternal() const;
|
2017-06-04 01:01:09 +00:00
|
|
|
u32 GetParticleCountAll() const { return x264_recursiveParticleCount; }
|
2016-02-26 03:31:00 +00:00
|
|
|
void EndLifetime();
|
2016-03-19 02:04:12 +00:00
|
|
|
void ForceParticleCreation(int amount);
|
2017-06-03 06:03:07 +00:00
|
|
|
float GetCEXTValue(int i) const { return x9c_cextValues[i]; }
|
|
|
|
void SetCEXTValue(int i, float v) { x9c_cextValues[i] = v; }
|
2016-02-08 03:31:05 +00:00
|
|
|
|
2016-02-13 05:49:59 +00:00
|
|
|
bool InternalUpdate(double);
|
2016-02-12 02:36:34 +00:00
|
|
|
void RenderModels();
|
|
|
|
void RenderLines();
|
|
|
|
void RenderParticles();
|
2016-02-13 00:57:09 +00:00
|
|
|
void RenderParticlesIndirectTexture();
|
2016-02-12 02:36:34 +00:00
|
|
|
|
2017-06-04 04:54:47 +00:00
|
|
|
bool Update(double);
|
2016-02-13 05:49:59 +00:00
|
|
|
void Render();
|
2016-03-04 23:04:53 +00:00
|
|
|
void SetOrientation(const zeus::CTransform&);
|
|
|
|
void SetTranslation(const zeus::CVector3f&);
|
|
|
|
void SetGlobalOrientation(const zeus::CTransform&);
|
|
|
|
void SetGlobalTranslation(const zeus::CVector3f&);
|
|
|
|
void SetGlobalScale(const zeus::CVector3f&);
|
|
|
|
void SetLocalScale(const zeus::CVector3f&);
|
2017-06-04 01:01:09 +00:00
|
|
|
void SetGlobalOrientAndTrans(const zeus::CTransform& xf);
|
2016-02-13 05:49:59 +00:00
|
|
|
void SetParticleEmission(bool);
|
2016-03-04 23:04:53 +00:00
|
|
|
void SetModulationColor(const zeus::CColor&);
|
2017-06-04 01:01:09 +00:00
|
|
|
void SetGeneratorRate(float rate);
|
2016-03-04 23:04:53 +00:00
|
|
|
const zeus::CTransform& GetOrientation() const;
|
|
|
|
const zeus::CVector3f& GetTranslation() const;
|
|
|
|
const zeus::CTransform& GetGlobalOrientation() const;
|
|
|
|
const zeus::CVector3f& GetGlobalTranslation() const;
|
|
|
|
const zeus::CVector3f& GetGlobalScale() const;
|
|
|
|
const zeus::CColor& GetModulationColor() const;
|
2017-06-04 01:01:09 +00:00
|
|
|
float GetGeneratorRate() const { return x98_generatorRate; }
|
2016-02-13 05:49:59 +00:00
|
|
|
bool IsSystemDeletable() const;
|
2017-01-21 06:03:37 +00:00
|
|
|
rstl::optional_object<zeus::CAABox> GetBounds() const;
|
2016-02-13 05:49:59 +00:00
|
|
|
u32 GetParticleCount() const;
|
|
|
|
bool SystemHasLight() const;
|
|
|
|
CLight GetLight() const;
|
|
|
|
bool GetParticleEmission() const;
|
|
|
|
void DestroyParticles();
|
2016-02-18 04:44:06 +00:00
|
|
|
void Reset();
|
2017-06-04 01:01:09 +00:00
|
|
|
FourCC Get4CharId() const { return FOURCC('PART'); }
|
2017-05-06 05:21:42 +00:00
|
|
|
size_t GetNumActiveChildParticles() const { return x290_activePartChildren.size(); }
|
2017-06-04 01:01:09 +00:00
|
|
|
CParticleGen& GetActiveChildParticle(size_t idx) const { return *x290_activePartChildren[idx]; }
|
2017-01-22 17:36:25 +00:00
|
|
|
|
|
|
|
static void SetMoveRedToAlphaBuffer(bool);
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CELEMENTGEN_HPP__
|