All real elements implemented

This commit is contained in:
Jack Andersen 2016-02-05 21:31:53 -10:00
parent c8abcad283
commit 8fbe6a953c
9 changed files with 259 additions and 50 deletions

View File

@ -100,9 +100,6 @@ void RealElementFactory::read(Athena::io::YAMLDocReader& r)
case SBIG('PRLW'): case SBIG('PRLW'):
m_elem.reset(new struct REPRLW); m_elem.reset(new struct REPRLW);
break; break;
case SBIG('PSOF'):
m_elem.reset(new struct REPSOF);
break;
case SBIG('SUB_'): case SBIG('SUB_'):
m_elem.reset(new struct RESubtract); m_elem.reset(new struct RESubtract);
break; break;
@ -236,9 +233,6 @@ void RealElementFactory::read(Athena::io::IStreamReader& r)
case SBIG('PRLW'): case SBIG('PRLW'):
m_elem.reset(new struct REPRLW); m_elem.reset(new struct REPRLW);
break; break;
case SBIG('PSOF'):
m_elem.reset(new struct REPSOF);
break;
case SBIG('SUB_'): case SBIG('SUB_'):
m_elem.reset(new struct RESubtract); m_elem.reset(new struct RESubtract);
break; break;

View File

@ -329,12 +329,6 @@ struct REPRLW : IRealElement
const char* ClassID() const {return "PRLW";} const char* ClassID() const {return "PRLW";}
}; };
struct REPSOF : IRealElement
{
DECL_YAML
const char* ClassID() const {return "PSOF";}
};
struct RESubtract : IRealElement struct RESubtract : IRealElement
{ {
DECL_YAML DECL_YAML

View File

@ -608,10 +608,6 @@ CRealElement* CParticleDataFactory::GetRealElement(CInputStream& in)
{ {
return new CREPRLW; return new CREPRLW;
} }
case SBIG('PSOF'):
{
return new CREPSOF;
}
case SBIG('SUB_'): case SBIG('SUB_'):
{ {
CRealElement* a = GetRealElement(in); CRealElement* a = GetRealElement(in);

View File

@ -13,4 +13,7 @@ int CParticleGlobals::g_particleLifetimePercentTweenInt = 0;
float CParticleGlobals::g_particleLifetimePercentTweenFloat = 0.0; float CParticleGlobals::g_particleLifetimePercentTweenFloat = 0.0;
float CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem = 0.0; float CParticleGlobals::g_particleLifetimePercentTweenIntFloatRem = 0.0;
float* CParticleGlobals::g_papValues = nullptr;
CParticleGlobals::SParticleMetrics* CParticleGlobals::g_particleMetrics = nullptr;
} }

View File

@ -1,6 +1,8 @@
#ifndef __RETRO_CPARTICLEGLOBALS_HPP__ #ifndef __RETRO_CPARTICLEGLOBALS_HPP__
#define __RETRO_CPARTICLEGLOBALS_HPP__ #define __RETRO_CPARTICLEGLOBALS_HPP__
#include "CVector3f.hpp"
namespace Retro namespace Retro
{ {
@ -33,6 +35,18 @@ public:
g_particleLifetimePercentTweenInt = g_particleLifetimePercentTweenFloat; g_particleLifetimePercentTweenInt = g_particleLifetimePercentTweenFloat;
g_particleLifetimePercentTweenIntFloatRem = g_particleLifetimePercentTweenFloat - g_particleLifetimePercentTweenInt; g_particleLifetimePercentTweenIntFloatRem = g_particleLifetimePercentTweenFloat - g_particleLifetimePercentTweenInt;
} }
static float* g_papValues;
struct SParticleMetrics
{
Zeus::CVector3f x0_ploc;
Zeus::CVector3f x10_plco;
Zeus::CVector3f x1c_pvel;
float x2c_psll;
float x30_prlw;
};
static SParticleMetrics* g_particleMetrics;
}; };
} }

View File

@ -1,5 +1,8 @@
#include "CRealElement.hpp" #include "CRealElement.hpp"
#include "CParticleGlobals.hpp" #include "CParticleGlobals.hpp"
#include "CRandom16.hpp"
#include <math.h>
#include <float.h>
namespace Retro namespace Retro
{ {
@ -103,4 +106,215 @@ bool CREClamp::GetValue(int frame, float &valOut) const
return false; return false;
} }
bool CRERandom::GetValue(int frame, float& valOut) const
{
float a, b;
x4_min->GetValue(frame, a);
x8_max->GetValue(frame, b);
float rand = CRandom16::GetRandomNumber()->Float();
valOut = b * rand + a * (1.0f - rand);
return false;
}
bool CREPulse::GetValue(int frame, float& valOut) const
{
int a, b;
x4_aDuration->GetValue(frame, a);
x8_bDuration->GetValue(frame, b);
int cv = std::max(1, a + b + 1);
if (b >= 1)
{
int cv2 = frame % cv;
if (cv2 >= a)
x10_valB->GetValue(frame, valOut);
else
xc_valA->GetValue(frame, valOut);
}
else
xc_valA->GetValue(frame, valOut);
return false;
}
bool CRETimeScale::GetValue(int frame, float& valOut) const
{
float a;
x4_a->GetValue(frame, a);
valOut = float(frame) * a;
return false;
}
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;
return false;
}
bool CRESineWave::GetValue(int frame, float& valOut) const
{
float a, b, c;
x4_magnitude->GetValue(frame, a);
x8_linearFrame->GetValue(frame, b);
xc_constantFrame->GetValue(frame, c);
valOut = sinf((frame * b + c) * M_PI / 180.f) * a;
return false;
}
bool CREISWT::GetValue(int frame, float& valOut) const
{
if (frame == 0)
x4_a->GetValue(frame, valOut);
else
x8_b->GetValue(frame, valOut);
return false;
}
bool CRECompareLessThan::GetValue(int frame, float& valOut) const
{
float a, b;
x4_a->GetValue(frame, a);
x8_b->GetValue(frame, b);
if (a < b)
xc_c->GetValue(frame, valOut);
else
x10_d->GetValue(frame, valOut);
return false;
}
bool CRECompareEquals::GetValue(int frame, float& valOut) const
{
float a, b;
x4_a->GetValue(frame, a);
x8_b->GetValue(frame, b);
if (fabsf(a-b) < 0.00001)
xc_c->GetValue(frame, valOut);
else
x10_d->GetValue(frame, valOut);
return false;
}
bool CREParticleAccessParam1::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[0];
return false;
}
bool CREParticleAccessParam2::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[1];
return false;
}
bool CREParticleAccessParam3::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[2];
return false;
}
bool CREParticleAccessParam4::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[3];
return false;
}
bool CREParticleAccessParam5::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[4];
return false;
}
bool CREParticleAccessParam6::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[5];
return false;
}
bool CREParticleAccessParam7::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[6];
return false;
}
bool CREParticleAccessParam8::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_papValues[7];
return false;
}
bool CREPSLL::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_particleMetrics->x2c_psll;
return false;
}
bool CREPRLW::GetValue(int frame, float& valOut) const
{
valOut = CParticleGlobals::g_particleMetrics->x30_prlw;
return false;
}
bool CRESubtract::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 CREVectorMagnitude::GetValue(int frame, float& valOut) const
{
Zeus::CVector3f a;
x4_a->GetValue(frame, a);
valOut = a.magnitude();
return false;
}
bool CREVectorXToReal::GetValue(int frame, float& valOut) const
{
Zeus::CVector3f a;
x4_a->GetValue(frame, a);
valOut = a[0];
return false;
}
bool CREVectorYToReal::GetValue(int frame, float& valOut) const
{
Zeus::CVector3f a;
x4_a->GetValue(frame, a);
valOut = a[1];
return false;
}
bool CREVectorZToReal::GetValue(int frame, float& valOut) const
{
Zeus::CVector3f a;
x4_a->GetValue(frame, a);
valOut = a[2];
return false;
}
bool CRECEXT::GetValue(int frame, float& valOut) const
{
int a;
x4_a->GetValue(frame, a);
int cv = std::max(0, a);
/* TODO: Figure out how value table is generated/stored in 0-00 */
return false;
}
bool CREITRL::GetValue(int frame, float& valOut) const
{
int a;
x4_a->GetValue(frame, a);
float b;
x8_b->GetValue(frame, b);
valOut = float(a) * b;
return false;
}
} }

View File

@ -6,6 +6,20 @@
namespace Retro namespace Retro
{ {
class CREKeyframeEmitter : public CRealElement
{
u32 x4_percent;
u32 x8_unk1;
bool xc_loop;
bool xd_unk2;
u32 x10_loopEnd;
u32 x14_loopStart;
std::vector<float> x18_keys;
public:
CREKeyframeEmitter(CInputStream& in);
bool GetValue(int frame, float& valOut) const;
};
class CRELifetimeTween : public CRealElement class CRELifetimeTween : public CRealElement
{ {
std::unique_ptr<CRealElement> x4_a; std::unique_ptr<CRealElement> x4_a;
@ -57,20 +71,6 @@ public:
bool GetValue(int frame, float& valOut) const; bool GetValue(int frame, float& valOut) const;
}; };
class CREKeyframeEmitter : public CRealElement
{
u32 x4_percent;
u32 x8_unk1;
bool xc_loop;
bool xd_unk2;
u32 x10_loopEnd;
u32 x14_loopStart;
std::vector<float> x18_keys;
public:
CREKeyframeEmitter(CInputStream& in);
bool GetValue(int frame, float& valOut) const;
};
class CREInitialRandom : public CRealElement class CREInitialRandom : public CRealElement
{ {
std::unique_ptr<CRealElement> x4_min; std::unique_ptr<CRealElement> x4_min;
@ -104,13 +104,13 @@ public:
class CREPulse : public CRealElement class CREPulse : public CRealElement
{ {
std::unique_ptr<CIntElement> x4_a; std::unique_ptr<CIntElement> x4_aDuration;
std::unique_ptr<CIntElement> x8_b; std::unique_ptr<CIntElement> x8_bDuration;
std::unique_ptr<CRealElement> xc_c; std::unique_ptr<CRealElement> xc_valA;
std::unique_ptr<CRealElement> x10_d; std::unique_ptr<CRealElement> x10_valB;
public: public:
CREPulse(CIntElement* a, CIntElement* b, CRealElement* c, CRealElement* d) CREPulse(CIntElement* a, CIntElement* b, CRealElement* c, CRealElement* d)
: x4_a(a), x8_b(b), xc_c(c), x10_d(d) {} : x4_aDuration(a), x8_bDuration(b), xc_valA(c), x10_valB(d) {}
bool GetValue(int frame, float& valOut) const; bool GetValue(int frame, float& valOut) const;
}; };
@ -125,21 +125,21 @@ public:
class CRELifetimePercent : public CRealElement class CRELifetimePercent : public CRealElement
{ {
std::unique_ptr<CRealElement> x4_a; std::unique_ptr<CRealElement> x4_percentVal;
public: public:
CRELifetimePercent(CRealElement* a) CRELifetimePercent(CRealElement* a)
: x4_a(a) {} : x4_percentVal(a) {}
bool GetValue(int frame, float& valOut) const; bool GetValue(int frame, float& valOut) const;
}; };
class CRESineWave : public CRealElement class CRESineWave : public CRealElement
{ {
std::unique_ptr<CRealElement> x4_a; std::unique_ptr<CRealElement> x4_magnitude;
std::unique_ptr<CRealElement> x8_b; std::unique_ptr<CRealElement> x8_linearFrame;
std::unique_ptr<CRealElement> xc_c; std::unique_ptr<CRealElement> xc_constantFrame;
public: public:
CRESineWave(CRealElement* a, CRealElement* b, CRealElement* c) CRESineWave(CRealElement* a, CRealElement* b, CRealElement* c)
: x4_a(a), x8_b(b), xc_c(c) {} : x4_magnitude(a), x8_linearFrame(b), xc_constantFrame(c) {}
bool GetValue(int frame, float& valOut) const; bool GetValue(int frame, float& valOut) const;
}; };
@ -237,12 +237,6 @@ public:
bool GetValue(int frame, float& valOut) const; bool GetValue(int frame, float& valOut) const;
}; };
class CREPSOF : public CRealElement
{
public:
bool GetValue(int frame, float& valOut) const;
};
class CRESubtract : public CRealElement class CRESubtract : public CRealElement
{ {
std::unique_ptr<CRealElement> x4_a; std::unique_ptr<CRealElement> x4_a;

View File

@ -9,7 +9,7 @@ CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntEle
{ {
a->GetValue(0, x10_tileW); a->GetValue(0, x10_tileW);
delete a; delete a;
b->GetValue(0, x14_tileW); b->GetValue(0, x14_tileH);
delete b; delete b;
c->GetValue(0, x18_strideW); c->GetValue(0, x18_strideW);
delete c; delete c;
@ -31,7 +31,7 @@ CUVEAnimTexture::CUVEAnimTexture(TToken<CTexture>&& tex, CIntElement* a, CIntEle
int px = x18_strideW * x; int px = x18_strideW * x;
int px2 = px + x10_tileW; int px2 = px + x10_tileW;
int py = x1c_strideH * y; int py = x1c_strideH * y;
int py2 = py + x14_tileW; int py2 = py + x14_tileH;
x2c_uvElems.push_back({px / widthF, py / heightF, px2 / widthF, py2 / heightF}); x2c_uvElems.push_back({px / widthF, py / heightF, px2 / widthF, py2 / heightF});
} }
} }

View File

@ -54,7 +54,7 @@ struct CUVEAnimTexture : public CUVElement
{ {
TToken<CTexture> x4_tex; TToken<CTexture> x4_tex;
CTexture* xc_directTex; CTexture* xc_directTex;
int x10_tileW, x14_tileW, x18_strideW, x1c_strideH; int x10_tileW, x14_tileH, x18_strideW, x1c_strideH;
int x20_tiles; int x20_tiles;
bool x24_loop; bool x24_loop;
std::unique_ptr<CIntElement> x28_cycleFrameRate; std::unique_ptr<CIntElement> x28_cycleFrameRate;