CElementGen constructor

This commit is contained in:
Jack Andersen 2016-02-09 12:52:33 -10:00
parent 69f32a4706
commit 33eb00b366
14 changed files with 409 additions and 62 deletions

0
Runtime/CLight.cpp Normal file
View File

31
Runtime/CLight.hpp Normal file
View File

@ -0,0 +1,31 @@
#ifndef __RETRO_CLIGHT_HPP__
#define __RETRO_CLIGHT_HPP__
namespace Retro
{
enum class ELightType
{
LocalAmbient,
Directional,
Custom,
Spot,
Spot2,
LocalAmbient2
};
enum class EFalloffType
{
Constant,
Linear,
Quadratic
};
class CLight
{
public:
};
}
#endif // __RETRO_CLIGHT_HPP__

View File

@ -59,6 +59,7 @@ add_library(RuntimeCommon
CStringExtras.hpp
CCallStack.hpp
CTexture.hpp CTexture.cpp
CLight.hpp CLight.cpp
IOStreams.hpp IOStreams.cpp
CMainFlowBase.hpp CMainFlowBase.cpp
CMFGameBase.hpp

View File

@ -241,6 +241,7 @@ class TLockedToken : public TToken<T>
{
T* m_obj;
public:
TLockedToken() {m_obj = nullptr;}
TLockedToken(const CToken& other) : TToken<T>(other) {m_obj = TToken<T>::GetObj();}
TLockedToken(CToken&& other) : TToken<T>(std::move(other)) {m_obj = TToken<T>::GetObj();}
T* GetObj() {return m_obj;}

View File

@ -11,6 +11,7 @@ add_executable(mp1
target_link_libraries(mp1
RuntimeCommonCharacter
RuntimeCommonInput
RuntimeCommonParticle
RuntimeCommon
DNAMP1
DNACommon

View File

@ -25,7 +25,7 @@ bool CCEKeyframeEmitter::GetValue(int frame, Zeus::CColor& valOut) const
{
if (!x4_percent)
{
int emitterTime = CParticleGlobals::g_emitterTimeInt;
int emitterTime = CParticleGlobals::g_EmitterTime;
int calcKey = emitterTime;
if (xc_loop)
{
@ -47,8 +47,8 @@ bool CCEKeyframeEmitter::GetValue(int frame, Zeus::CColor& valOut) const
}
else
{
int ltPerc = CParticleGlobals::g_particleLifetimePercentTweenInt;
float ltPercRem = CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem;
int ltPerc = CParticleGlobals::g_ParticleLifetimePercentage;
float ltPercRem = CParticleGlobals::g_ParticleLifetimePercentageRemainder;
if (ltPerc == 100)
valOut = x18_keys[100];
else

View File

@ -1,15 +1,255 @@
#include "CElementGen.hpp"
#include "CGenDescription.hpp"
#include "CLight.hpp"
namespace Retro
{
int CElementGen::g_ParticleAliveCount;
int CElementGen::g_ParticleSystemAliveCount;
void CElementGen::Initialize()
{
g_ParticleAliveCount = 0;
g_ParticleSystemAliveCount = 0;
}
CElementGen::CElementGen(const TToken<CGenDescription>& gen,
EModelOrientationType orientType,
EOptionalSystemFlags flags)
: x1c_genDesc(gen), x28_orientType(orientType)
: x1c_genDesc(gen), x28_orientType(orientType),
x226((flags & EOptionalSystemFlags::Two) != EOptionalSystemFlags::None), x230(x74)
{
CIntElement* pmedElem = x1c_genDesc.GetObj()->x1c_PMED.get();
if (pmedElem)
{
int pmedVal;
pmedElem->GetValue(x50, pmedVal);
x74 = pmedVal;
}
x230.SetSeed(x74);
++g_ParticleSystemAliveCount;
x224_25_LIT_ = x1c_genDesc.GetObj()->x44_29_LIT_;
x224_26_AAPH = x1c_genDesc.GetObj()->x44_26_AAPH;
x224_27_ZBUF = x1c_genDesc.GetObj()->x44_27_ZBUF;
x224_29_MBLR = x1c_genDesc.GetObj()->x44_30_MBLR;
CIntElement* mbspElem = x1c_genDesc.GetObj()->x48_MBSP.get();
if (mbspElem)
mbspElem->GetValue(x50, x228_MBSP);
x224_30_VMD1 = x1c_genDesc.GetObj()->x45_26_VMD1;
x224_31_VMD2 = x1c_genDesc.GetObj()->x45_27_VMD2;
x225_24_VMD2 = x1c_genDesc.GetObj()->x45_28_VMD3;
x225_25_VMD2 = x1c_genDesc.GetObj()->x45_29_VMD4;
CIntElement* cssdElem = x1c_genDesc.GetObj()->xa0_CSSD.get();
if (cssdElem)
cssdElem->GetValue(0, x244_CSSD);
SChildGeneratorDesc& idts = x1c_genDesc.GetObj()->xa4_IDTS;
if (idts.m_found)
{
int ndsyVal = 1;
CIntElement* ndsyElem = x1c_genDesc.GetObj()->xb4_NDSY.get();
if (ndsyElem)
ndsyElem->GetValue(0, ndsyVal);
x248_children.reserve(ndsyVal + x248_children.size());
for (int i=0 ; i<ndsyVal ; ++i)
{
CGenDescription* chDesc = x1c_genDesc.GetObj()->xa4_IDTS.m_gen.GetObj();
if (x226 && chDesc->x45_31_OPTS)
break;
x248_children.emplace_back(new CElementGen(x1c_genDesc.GetObj()->xa4_IDTS.m_gen,
EModelOrientationType::Normal,
x226 ? EOptionalSystemFlags::Two : EOptionalSystemFlags::One));
}
}
CIntElement* pisyElem = x1c_genDesc.GetObj()->xc8_PISY.get();
if (pisyElem)
{
pisyElem->GetValue(0, x25c_PISY);
if (x25c_PISY <= 0)
x25c_PISY = 1;
}
CIntElement* sisyElem = x1c_genDesc.GetObj()->xcc_SISY.get();
if (sisyElem)
pisyElem->GetValue(0, x258_SISY);
CIntElement* sssdElem = x1c_genDesc.GetObj()->xe4_SSSD.get();
if (sssdElem)
sssdElem->GetValue(0, x270_SSSD);
CVectorElement* sspoElem = x1c_genDesc.GetObj()->xe8_SSPO.get();
if (sspoElem)
sspoElem->GetValue(0, x274_SSPO);
CIntElement* sesdElem = x1c_genDesc.GetObj()->xf8_SESD.get();
if (sesdElem)
sesdElem->GetValue(0, x290_SESD);
CVectorElement* sepoElem = x1c_genDesc.GetObj()->xfc_SEPO.get();
if (sepoElem)
sepoElem->GetValue(0, x294_SEPO);
CIntElement* psltElem = x1c_genDesc.GetObj()->xc_PSLT.get();
if (psltElem)
psltElem->GetValue(0, x214_PSLT);
CVectorElement* psivElem = x1c_genDesc.GetObj()->x0_PSIV.get();
if (psivElem)
psivElem->GetValue(0, x218_PSIV);
CIntElement* maxpElem = x1c_genDesc.GetObj()->x28_MAXP.get();
if (maxpElem)
maxpElem->GetValue(x50, x70_MAXP);
x2c_particleLists.reserve(std::min(256, x70_MAXP));
if (x28_orientType == EModelOrientationType::One)
{
x3c_parentMatrices.insert(x3c_parentMatrices.end(), x70_MAXP,
Zeus::CMatrix3f::skIdentityMatrix3f);
}
x225_26_LINE = x1c_genDesc.GetObj()->x44_24_LINE;
x225_27_FXLL = x1c_genDesc.GetObj()->x44_25_FXLL;
CRealElement* widtElem = x1c_genDesc.GetObj()->x24_WIDT.get();
if (widtElem)
widtElem->GetValue(x50, x94_WIDT);
CIntElement* ltypElem = x1c_genDesc.GetObj()->x100_LTYP.get();
if (ltypElem)
{
int ltyp;
ltypElem->GetValue(x50, ltyp);
switch (ELightType(ltyp))
{
case ELightType::LocalAmbient:
default:
x2dc_lightType = ELightType::LocalAmbient;
break;
case ELightType::Directional:
x2dc_lightType = ELightType::Directional;
break;
case ELightType::Custom:
x2dc_lightType = ELightType::Custom;
break;
case ELightType::Spot:
x2dc_lightType = ELightType::Spot;
break;
}
}
CIntElement* lfotElem = x1c_genDesc.GetObj()->x114_LFOT.get();
if (lfotElem)
{
int lfot;
lfotElem->GetValue(x50, lfot);
switch (EFalloffType(lfot))
{
case EFalloffType::Constant:
x300_falloffType = EFalloffType::Constant;
break;
case EFalloffType::Linear:
default:
x300_falloffType = EFalloffType::Linear;
break;
case EFalloffType::Quadratic:
x300_falloffType = EFalloffType::Quadratic;
break;
}
}
}
CElementGen::~CElementGen()
{
--g_ParticleSystemAliveCount;
}
void CElementGen::Update(double)
{
}
void CElementGen::Render()
{
}
void CElementGen::SetOrientation(const Zeus::CTransform&)
{
}
void CElementGen::SetTranslation(const Zeus::CVector3f&)
{
}
void CElementGen::SetGlobalOrientation(const Zeus::CTransform&)
{
}
void CElementGen::SetGlobalTranslation(const Zeus::CVector3f&)
{
}
void CElementGen::SetGlobalScale(const Zeus::CVector3f&)
{
}
void CElementGen::SetLocalScale(const Zeus::CVector3f&)
{
}
void CElementGen::SetParticleEmission(bool)
{
}
void CElementGen::SetModulationColor(const Zeus::CColor&)
{
}
const Zeus::CTransform& CElementGen::GetOrientation() const
{
}
const Zeus::CVector3f& CElementGen::GetTranslation() const
{
}
const Zeus::CVector3f& CElementGen::GetGlobalScale() const
{
}
const Zeus::CColor& CElementGen::GetModulationColor() const
{
}
bool CElementGen::IsSystemDeletable() const
{
}
Zeus::CAABox CElementGen::GetBounds() const
{
}
u32 CElementGen::GetParticleCount() const
{
}
bool CElementGen::SystemHasLight() const
{
}
CLight CElementGen::GetLight() const
{
}
void CElementGen::DestroyParticles()
{
}
void CElementGen::AddModifier(CWarp*)
{
}
}

View File

@ -3,9 +3,12 @@
#include "../RetroTypes.hpp"
#include "CTransform.hpp"
#include "CVector3f.hpp"
#include "CColor.hpp"
#include "CAABox.hpp"
#include "CToken.hpp"
#include "CLight.hpp"
#include "CRandom16.hpp"
namespace Retro
{
@ -18,16 +21,23 @@ class CElementGen
public:
enum class EModelOrientationType
{
Normal,
One
};
enum class EOptionalSystemFlags
{
None,
One,
Two
};
class CParticleListItem
{
};
private:
TLockedToken<CGenDescription> x1c_genDesc;
EModelOrientationType x28_orientType;
u32 x30 = 0;
u32 x34 = 0;
u32 x38 = 0;
std::vector<CParticleListItem> x2c_particleLists;
std::vector<Zeus::CMatrix3f> x3c_parentMatrices;
u32 x40 = 0;
u32 x44 = 0;
u32 x48 = 0;
@ -37,29 +47,90 @@ private:
u32 x64 = -1;
bool x68_particleEmission = true;
float x6c = 0.f;
u32 x70 = 0;
int x70_MAXP = 0;
u16 x74 = 99;
float x78_generatorRate = 1.f;
float x7c = 0.f;
float x80 = 0.f;
float x84 = 0.f;
float x88 = 0.f;
float x8c = 0.f;
float x90 = 0.f;
float x94 = 0.f;
Zeus::CVector3f x88_globalTranslation;
float x94_WIDT = 0.f;
float x98 = 0.f;
float x9c = 0.f;
float xa0 = 1.f;
float xa4 = 1.f;
float xa8 = 1.f;
Zeus::CTransform xac = Zeus::CTransform::Identity();
Zeus::CVector3f x88_globalTranslation;
Zeus::CTransform x1d8_globalOrientation;
std::vector<CElementGen> x240_children;
std::vector<CElementGen> x254_children;
Zeus::CTransform xdc = Zeus::CTransform::Identity();
float x10c = 1.f;
float x110 = 1.f;
float x114 = 1.f;
Zeus::CTransform x118 = Zeus::CTransform::Identity();
Zeus::CTransform x148 = Zeus::CTransform::Identity();
Zeus::CTransform x178 = Zeus::CTransform::Identity();
Zeus::CTransform x1a8 = Zeus::CTransform::Identity();
Zeus::CTransform x1d8_globalOrientation = Zeus::CTransform::Identity();
u32 x208 = 0;
u32 x20c = 0;
u32 x210 = 0;
int x214_PSLT = 0x7fffff;
Zeus::CVector3f x218_PSIV;
bool x224_24 = false;
bool x224_25_LIT_;
bool x224_26_AAPH;
bool x224_27_ZBUF;
bool x224_28 = true;
bool x224_29_MBLR;
bool x224_30_VMD1;
bool x224_31_VMD2;
bool x225_24_VMD2;
bool x225_25_VMD2;
bool x225_26_LINE;
bool x225_27_FXLL;
bool x225_28 = false;
bool x225_29 = false;
bool x226;
int x228_MBSP;
bool x22c = false;
CRandom16 x230;
std::vector<std::unique_ptr<CElementGen>> x234_children;
int x244_CSSD = 0;
std::vector<std::unique_ptr<CElementGen>> x248_children;
int x258_SISY = 16;
int x25c_PISY = 16;
u32 x264 = 0;
u32 x268 = 0;
u32 x26c = 0;
int x270_SSSD = 0;
Zeus::CVector3f x274_SSPO;
u32 x284 = 0;
u32 x288 = 0;
u32 x28c = 0;
int x290_SESD = 0;
Zeus::CVector3f x294_SEPO;
float x2a0 = 0.f;
float x2a4 = 0.f;
Zeus::CVector3f x2a8;
Zeus::CVector3f x2b4;
float x2c0 = 0.f;
Zeus::CAABox x2c4 = Zeus::CAABox::skInvertedBox;
ELightType x2dc_lightType;
Zeus::CColor x2e0 = Zeus::CColor::skWhite;
float x2e4 = 1.f;
float x2e8 = 0.f;
float x2ec = 0.f;
float x2f0 = 0.f;
float x2f4 = 1.f;
float x2f8 = 0.f;
float x2fc = 0.f;
EFalloffType x300_falloffType = EFalloffType::Linear;
float x304 = 1.f;
float x308 = 45.f;
u32 x30c = -1;
public:
CElementGen(const TToken<CGenDescription>& gen, EModelOrientationType orientType, EOptionalSystemFlags flags);
virtual ~CElementGen() = default;
virtual ~CElementGen();
virtual const Zeus::CVector3f& GetGlobalTranslation() const
{ return x88_globalTranslation; }
@ -75,16 +146,17 @@ public:
else
x78_generatorRate = 0.0f;
for (CElementGen& child : x240_children)
child.SetGeneratorRateScalar(x78_generatorRate);
for (std::unique_ptr<CElementGen>& child : x234_children)
child->SetGeneratorRateScalar(x78_generatorRate);
for (CElementGen& child : x254_children)
child.SetGeneratorRateScalar(x78_generatorRate);
for (std::unique_ptr<CElementGen>& child : x248_children)
child->SetGeneratorRateScalar(x78_generatorRate);
}
static void Initialize()
{
}
static int g_ParticleAliveCount;
static int g_ParticleSystemAliveCount;
static void Initialize();
void BuildParticleSystemBounds();
virtual void Update(double);
@ -109,6 +181,7 @@ public:
virtual void DestroyParticles();
virtual void AddModifier(CWarp*);
};
ENABLE_BITWISE_ENUM(CElementGen::EOptionalSystemFlags)
}

View File

@ -24,7 +24,7 @@ bool CIEKeyframeEmitter::GetValue(int frame, int& valOut) const
{
if (!x4_percent)
{
int emitterTime = CParticleGlobals::g_emitterTimeInt;
int emitterTime = CParticleGlobals::g_EmitterTime;
int calcKey = emitterTime;
if (xc_loop)
{
@ -46,8 +46,8 @@ bool CIEKeyframeEmitter::GetValue(int frame, int& valOut) const
}
else
{
int ltPerc = CParticleGlobals::g_particleLifetimePercentTweenInt;
float ltPercRem = CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem;
int ltPerc = CParticleGlobals::g_ParticleLifetimePercentage;
float ltPercRem = CParticleGlobals::g_ParticleLifetimePercentageRemainder;
if (ltPerc == 100)
valOut = x18_keys[100];
else
@ -117,7 +117,7 @@ bool CIELifetimePercent::GetValue(int frame, int& valOut) const
int a;
x4_percentVal->GetValue(frame, a);
a = std::max(0, a);
valOut = (a / 100.0f) * CParticleGlobals::g_particleLifetimeFloat;
valOut = (a / 100.0f) * CParticleGlobals::g_ParticleLifetimeReal;
return false;
}

View File

@ -24,25 +24,25 @@ class CIntElement;
struct SParticleModel
{
TToken<CModel> m_model;
TLockedToken<CModel> m_model;
bool m_found = false;
};
struct SChildGeneratorDesc
{
TToken<CGenDescription> m_gen;
TLockedToken<CGenDescription> m_gen;
bool m_found = false;
};
struct SSwooshGeneratorDesc
{
TToken<CSwooshDescription> m_swoosh;
TLockedToken<CSwooshDescription> m_swoosh;
bool m_found = false;
};
struct SElectricGeneratorDesc
{
TToken<CElectricDescription> m_electric;
TLockedToken<CElectricDescription> m_electric;
bool m_found = false;
};

View File

@ -3,15 +3,15 @@
namespace Retro
{
int CParticleGlobals::g_emitterTimeInt = 0;
float CParticleGlobals::g_emitterTimeFloat = 0.0;
int CParticleGlobals::g_EmitterTime = 0;
float CParticleGlobals::g_EmitterTimeReal = 0.0;
int CParticleGlobals::g_particleLifetimeInt = 0;
float CParticleGlobals::g_particleLifetimeFloat = 0.0;
int CParticleGlobals::g_ParticleLifetime = 0;
float CParticleGlobals::g_ParticleLifetimeReal = 0.0;
int CParticleGlobals::g_particleLifetimePercentTweenInt = 0;
float CParticleGlobals::g_particleLifetimePercentTweenFloat = 0.0;
float CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem = 0.0;
int CParticleGlobals::g_ParticleLifetimePercentage = 0;
float CParticleGlobals::g_ParticleLifetimePercentageReal = 0.0;
float CParticleGlobals::g_ParticleLifetimePercentageRemainder = 0.0;
float* CParticleGlobals::g_papValues = nullptr;
CParticleGlobals::SParticleMetrics* CParticleGlobals::g_particleMetrics = nullptr;

View File

@ -9,31 +9,31 @@ namespace Retro
class CParticleGlobals
{
public:
static int g_emitterTimeInt;
static float g_emitterTimeFloat;
static int g_EmitterTime;
static float g_EmitterTimeReal;
static void SetEmitterTime(int frame)
{
g_emitterTimeInt = frame;
g_emitterTimeFloat = frame;
g_EmitterTime = frame;
g_EmitterTimeReal = frame;
}
static int g_particleLifetimeInt;
static float g_particleLifetimeFloat;
static int g_ParticleLifetime;
static float g_ParticleLifetimeReal;
static void SetParticleLifetime(int frame)
{
g_particleLifetimeInt = frame;
g_particleLifetimeFloat = frame;
g_ParticleLifetime = frame;
g_ParticleLifetimeReal = frame;
}
static int g_particleLifetimePercentTweenInt;
static float g_particleLifetimePercentTweenFloat;
static float g_particleLifetimePercentTweenIntFloatRem;
static int g_ParticleLifetimePercentage;
static float g_ParticleLifetimePercentageReal;
static float g_ParticleLifetimePercentageRemainder;
static void UpdateParticleLifetimeTweenValues(int frame)
{
float lt = g_particleLifetimeInt != 0.0f ? g_particleLifetimeInt : 1.0f;
g_particleLifetimePercentTweenFloat = 100.0f * frame / lt;
g_particleLifetimePercentTweenInt = g_particleLifetimePercentTweenFloat;
g_particleLifetimePercentTweenIntFloatRem = g_particleLifetimePercentTweenFloat - g_particleLifetimePercentTweenInt;
float lt = g_ParticleLifetime != 0.0f ? g_ParticleLifetime : 1.0f;
g_ParticleLifetimePercentageReal = 100.0f * frame / lt;
g_ParticleLifetimePercentage = g_ParticleLifetimePercentageReal;
g_ParticleLifetimePercentageRemainder = g_ParticleLifetimePercentageReal - g_ParticleLifetimePercentage;
}
static float* g_papValues;

View File

@ -25,7 +25,7 @@ bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const
{
if (!x4_percent)
{
int emitterTime = CParticleGlobals::g_emitterTimeInt;
int emitterTime = CParticleGlobals::g_EmitterTime;
int calcKey = emitterTime;
if (xc_loop)
{
@ -47,8 +47,8 @@ bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const
}
else
{
int ltPerc = CParticleGlobals::g_particleLifetimePercentTweenInt;
float ltPercRem = CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem;
int ltPerc = CParticleGlobals::g_ParticleLifetimePercentage;
float ltPercRem = CParticleGlobals::g_ParticleLifetimePercentageRemainder;
if (ltPerc == 100)
valOut = x18_keys[100];
else
@ -59,7 +59,7 @@ bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const
bool CRELifetimeTween::GetValue(int frame, float& valOut) const
{
float ltFac = frame / CParticleGlobals::g_particleLifetimeFloat;
float ltFac = frame / CParticleGlobals::g_ParticleLifetimeReal;
float a, b;
x4_a->GetValue(frame, a);
x8_b->GetValue(frame, b);
@ -149,7 +149,7 @@ bool CRELifetimePercent::GetValue(int frame, float& valOut) const
float a;
x4_percentVal->GetValue(frame, a);
a = std::max(0.0f, a);
valOut = (a / 100.0f) * CParticleGlobals::g_particleLifetimeFloat;
valOut = (a / 100.0f) * CParticleGlobals::g_ParticleLifetimeReal;
return false;
}

View File

@ -25,7 +25,7 @@ bool CVEKeyframeEmitter::GetValue(int frame, Zeus::CVector3f& valOut) const
{
if (!x4_percent)
{
int emitterTime = CParticleGlobals::g_emitterTimeInt;
int emitterTime = CParticleGlobals::g_EmitterTime;
int calcKey = emitterTime;
if (xc_loop)
{
@ -47,8 +47,8 @@ bool CVEKeyframeEmitter::GetValue(int frame, Zeus::CVector3f& valOut) const
}
else
{
int ltPerc = CParticleGlobals::g_particleLifetimePercentTweenInt;
float ltPercRem = CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem;
int ltPerc = CParticleGlobals::g_ParticleLifetimePercentage;
float ltPercRem = CParticleGlobals::g_ParticleLifetimePercentageRemainder;
if (ltPerc == 100)
valOut = x18_keys[100];
else