2016-02-05 08:34:14 +00:00
|
|
|
#include "CRealElement.hpp"
|
|
|
|
#include "CParticleGlobals.hpp"
|
|
|
|
|
|
|
|
namespace Retro
|
|
|
|
{
|
|
|
|
|
|
|
|
CREKeyframeEmitter::CREKeyframeEmitter(CInputStream& in)
|
|
|
|
{
|
|
|
|
x4_percent = in.readUint32Big();
|
2016-02-05 09:56:21 +00:00
|
|
|
x8_unk1 = in.readUint32Big();
|
2016-02-05 09:52:20 +00:00
|
|
|
xc_loop = in.readBool();
|
2016-02-05 09:56:21 +00:00
|
|
|
xd_unk2 = in.readBool();
|
2016-02-05 09:52:20 +00:00
|
|
|
x10_loopEnd = in.readUint32Big();
|
|
|
|
x14_loopStart = in.readUint32Big();
|
2016-02-05 08:34:14 +00:00
|
|
|
|
|
|
|
u32 count = in.readUint32Big();
|
|
|
|
x18_keys.reserve(count);
|
|
|
|
for (u32 i=0 ; i<count ; ++i)
|
|
|
|
x18_keys.push_back(in.readFloatBig());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const
|
|
|
|
{
|
|
|
|
if (!x4_percent)
|
|
|
|
{
|
|
|
|
int emitterTime = CParticleGlobals::g_emitterTimeInt;
|
|
|
|
int calcKey = emitterTime;
|
2016-02-05 09:52:20 +00:00
|
|
|
if (xc_loop)
|
2016-02-05 08:34:14 +00:00
|
|
|
{
|
2016-02-05 09:52:20 +00:00
|
|
|
if (emitterTime >= x10_loopEnd)
|
2016-02-05 08:34:14 +00:00
|
|
|
{
|
2016-02-05 09:52:20 +00:00
|
|
|
int v1 = emitterTime - x14_loopStart;
|
|
|
|
int v2 = x10_loopEnd - x14_loopStart;
|
|
|
|
calcKey = v1 % v2;
|
|
|
|
calcKey += x14_loopStart;
|
2016-02-05 08:34:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-05 09:52:20 +00:00
|
|
|
int v1 = x10_loopEnd - 1;
|
|
|
|
if (v1 < emitterTime)
|
|
|
|
calcKey = v1;
|
2016-02-05 08:34:14 +00:00
|
|
|
}
|
2016-02-06 00:34:40 +00:00
|
|
|
valOut = x18_keys[calcKey];
|
2016-02-05 08:34:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int ltPerc = CParticleGlobals::g_particleLifetimePercentTweenInt;
|
|
|
|
float ltPercRem = CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem;
|
|
|
|
if (ltPerc == 100)
|
|
|
|
valOut = x18_keys[100];
|
|
|
|
else
|
|
|
|
valOut = x18_keys[ltPerc+1] * ltPercRem + (1.0f - ltPercRem) * x18_keys[ltPerc];
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRELifetimeTween::GetValue(int frame, float& valOut) const
|
|
|
|
{
|
|
|
|
float ltFac = frame / CParticleGlobals::g_particleLifetimeFloat;
|
|
|
|
float a, b;
|
|
|
|
x4_a->GetValue(frame, a);
|
|
|
|
x8_b->GetValue(frame, b);
|
|
|
|
valOut = b * ltFac + (1.0f - ltFac) * a;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CREConstant::GetValue(int frame, float& valOut) const
|
|
|
|
{
|
|
|
|
valOut = x4_val;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CRETimeChain::GetValue(int frame, float& valOut) const
|
|
|
|
{
|
|
|
|
int v;
|
2016-02-06 00:34:40 +00:00
|
|
|
xc_swFrame->GetValue(frame, v);
|
2016-02-05 08:34:14 +00:00
|
|
|
if (frame >= v)
|
|
|
|
return x8_b->GetValue(frame, valOut);
|
|
|
|
else
|
|
|
|
return x4_a->GetValue(frame, valOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CREAdd::GetValue(int frame, float& valOut) const
|
|
|
|
{
|
|
|
|
float a, b;
|
|
|
|
x4_a->GetValue(frame, a);
|
|
|
|
x8_b->GetValue(frame, b);
|
|
|
|
valOut = a + b;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CREClamp::GetValue(int frame, float &valOut) const
|
|
|
|
{
|
|
|
|
float a, b;
|
2016-02-06 00:34:40 +00:00
|
|
|
x4_min->GetValue(frame, a);
|
|
|
|
x8_max->GetValue(frame, b);
|
|
|
|
xc_val->GetValue(frame, valOut);
|
2016-02-05 08:34:14 +00:00
|
|
|
if (valOut > b)
|
|
|
|
valOut = b;
|
|
|
|
if (valOut < a)
|
|
|
|
valOut = a;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|