mirror of https://github.com/AxioDL/metaforce.git
Implement CParticleElectricDataFactory
This commit is contained in:
parent
acf65c561a
commit
5349db23ad
|
@ -7,6 +7,26 @@ namespace Retro
|
||||||
{
|
{
|
||||||
class CElectricDescription
|
class CElectricDescription
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<CIntElement> x0_LIFE;
|
||||||
|
std::unique_ptr<CIntElement> x4_SLIF;
|
||||||
|
std::unique_ptr<CRealElement> x8_GRAT;
|
||||||
|
std::unique_ptr<CIntElement> xc_SCNT;
|
||||||
|
std::unique_ptr<CIntElement> x10_SSEG;
|
||||||
|
std::unique_ptr<CColorElement> x14_COLR;
|
||||||
|
bool x18_IEMT;
|
||||||
|
bool x1c_FEMT;
|
||||||
|
bool x20_AMPL;
|
||||||
|
bool x24_AMPD;
|
||||||
|
bool x28_LWD1;
|
||||||
|
bool x2c_LWD2;
|
||||||
|
bool x30_LWD3;
|
||||||
|
bool x34_LCL1;
|
||||||
|
bool x38_LCL2;
|
||||||
|
bool x3c_LCL3;
|
||||||
|
SSwooshGeneratorDesc x40_SSWH;
|
||||||
|
SChildGeneratorDesc x50_GPSM;
|
||||||
|
SChildGeneratorDesc x60_EPSM;
|
||||||
|
bool x70_ZERY;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,4 +97,50 @@ bool CMVETimeChain::GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f&
|
||||||
return x4_a->GetValue(frame, pVel, pPos);
|
return x4_a->GetValue(frame, pVel, pPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMVEBounce::CMVEBounce(CVectorElement *a, CVectorElement *b, CRealElement *c, CRealElement *d, bool f)
|
||||||
|
: x4_a(a), x8_b(b), xc_c(c), x10_d(d), x14_e(false), x15_f(f), x24_j(0.0)
|
||||||
|
{
|
||||||
|
if (x4_a && x8_b && x4_a->IsFastConstant() && x8_b->IsFastConstant())
|
||||||
|
{
|
||||||
|
x14_e = true;
|
||||||
|
x8_b->GetValue(0, x18_g);
|
||||||
|
|
||||||
|
if (x18_g.magSquared() > 0.0)
|
||||||
|
x18_g.normalize();
|
||||||
|
Zeus::CVector3f a;
|
||||||
|
x4_a->GetValue(0, a);
|
||||||
|
x24_j = x18_g.dot(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMVEBounce::GetValue(int frame, Zeus::CVector3f &pVel, Zeus::CVector3f &pPos) const
|
||||||
|
{
|
||||||
|
if (!x14_e)
|
||||||
|
{
|
||||||
|
x8_b->GetValue(frame, ((Zeus::CVector3f&)x18_g));
|
||||||
|
((Zeus::CVector3f&)x18_g).normalize();
|
||||||
|
|
||||||
|
Zeus::CVector3f a;
|
||||||
|
x4_a->GetValue(frame, a);
|
||||||
|
|
||||||
|
(float&)(x24_j) = x18_g.dot(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
float dot = x18_g.dot(pPos);
|
||||||
|
if ((dot - x24_j) <= 0.0f)
|
||||||
|
{
|
||||||
|
if (!x15_f)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (pVel.magSquared() > 0.0f)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Zeus::CVector3f delta = pPos - pVel;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,11 @@ class CMVEBounce : public CModVectorElement
|
||||||
std::unique_ptr<CRealElement> xc_c;
|
std::unique_ptr<CRealElement> xc_c;
|
||||||
std::unique_ptr<CRealElement> x10_d;
|
std::unique_ptr<CRealElement> x10_d;
|
||||||
bool x14_e;
|
bool x14_e;
|
||||||
|
bool x15_f;
|
||||||
|
Zeus::CVector3f x18_g;
|
||||||
|
float x24_j;
|
||||||
public:
|
public:
|
||||||
CMVEBounce(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, bool e)
|
CMVEBounce(CVectorElement* a, CVectorElement* b, CRealElement* c, CRealElement* d, bool e);
|
||||||
: x4_a(a), x8_b(b), xc_c(c), x10_d(d), x14_e(e) {}
|
|
||||||
bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const;
|
bool GetValue(int frame, Zeus::CVector3f& pVel, Zeus::CVector3f& pPos) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "CParticleElectricDataFactory.hpp"
|
#include "CParticleElectricDataFactory.hpp"
|
||||||
#include "CElectricDescription.hpp"
|
#include "CElectricDescription.hpp"
|
||||||
#include "CSimplePool.hpp"
|
#include "CSimplePool.hpp"
|
||||||
|
#include "CRandom16.hpp"
|
||||||
|
|
||||||
namespace Retro
|
namespace Retro
|
||||||
{
|
{
|
||||||
|
|
||||||
|
using CPF = CParticleDataFactory;
|
||||||
|
|
||||||
CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream &in, CSimplePool *resPool)
|
CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream &in, CSimplePool *resPool)
|
||||||
{
|
{
|
||||||
return CreateElectricDescription(in, resPool);
|
return CreateElectricDescription(in, resPool);
|
||||||
|
@ -12,9 +15,100 @@ CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStrea
|
||||||
|
|
||||||
CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream &in, CSimplePool *resPool)
|
CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream &in, CSimplePool *resPool)
|
||||||
{
|
{
|
||||||
|
FourCC cid = CParticleDataFactory::GetClassID(in);
|
||||||
|
if (cid == FOURCC('ELSM'))
|
||||||
|
{
|
||||||
|
CElectricDescription* ret = new CElectricDescription;
|
||||||
|
CreateELSM(desc, in, resPool);
|
||||||
|
LoadELSMTokens(ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CParticleElectricDataFactory::CreateELSM(CElectricDescription *desc, CInputStream &in, CSimplePool *resPool)
|
||||||
|
{
|
||||||
|
CRandom16 rand;
|
||||||
|
FourCC clsId = CPF::GetClassID(in);
|
||||||
|
while (clsId != SBIG('_END'))
|
||||||
|
{
|
||||||
|
CGlobalRandom gr(rand);
|
||||||
|
switch(clsId)
|
||||||
|
{
|
||||||
|
case SBIG(''):
|
||||||
|
desc->x0_LIFE.reset(CPF::GetIntElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('SLIF'):
|
||||||
|
desc->x4_SLIF.reset(CPF::GetIntElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('GRAT'):
|
||||||
|
desc->x8_GRAT.reset(CPF::GetRealElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('SCNT'):
|
||||||
|
desc->xc_SCNT.reset(CPF::GetIntElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('SSEG'):
|
||||||
|
desc->x10_SSEG.reset(CPF::GetIntElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('COLR'):
|
||||||
|
desc->x14_COLR.reset(CPF::GetColorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('IEMT'):
|
||||||
|
desc->x18_IEMT = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('FEMT'):
|
||||||
|
desc->x1c_FEMT = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('AMPL'):
|
||||||
|
desc->x20_AMPL = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('AMPD'):
|
||||||
|
desc->x24_AMPD = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('LWD1'):
|
||||||
|
desc->x28_LWD1 = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('LWD2'):
|
||||||
|
desc->x2c_LWD2 = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('LWD3'):
|
||||||
|
desc->x30_LWD3 = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
case SBIG('LCL1'):
|
||||||
|
desc->x34_LCL1.reset(CPF::GetColorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('LCL2'):
|
||||||
|
desc->x38_LCL2.reset(CPF::GetColorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('LCL3'):
|
||||||
|
desc->x3c_LCL3.reset(CPF::GetColorElement(in));
|
||||||
|
break;
|
||||||
|
case SBIG('SSWH'):
|
||||||
|
desc->x40_SSWH = CPF::GetSwooshGeneratorDesc(in, resPool);
|
||||||
|
break;
|
||||||
|
case SBIG('GPSM'):
|
||||||
|
{
|
||||||
|
std::vector<TResId> tracker;
|
||||||
|
tracker.reserve(8);
|
||||||
|
desc->x50_GPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SBIG('EPSM'):
|
||||||
|
{
|
||||||
|
std::vector<TResId> tracker;
|
||||||
|
tracker.reserve(8);
|
||||||
|
desc->x60_EPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SBIG('ZERY'):
|
||||||
|
desc->x70_ZERY = CPF::GetBool(in);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Retro::IObj> FParticleElecrticFactory(const Retro::SObjectTag &tag, Retro::CInputStream &in, const Retro::CVParamTransfer &vparms)
|
std::unique_ptr<Retro::IObj> FParticleElecrticFactory(const Retro::SObjectTag &tag, Retro::CInputStream &in, const Retro::CVParamTransfer &vparms)
|
||||||
{
|
{
|
||||||
CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
|
CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
static CElectricDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
static CElectricDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
||||||
static CElectricDescription* CreateElectricDescription(CInputStream& in, CSimplePool* resPool);
|
static CElectricDescription* CreateElectricDescription(CInputStream& in, CSimplePool* resPool);
|
||||||
|
|
||||||
static bool CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool) { return false; }
|
static bool CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool);
|
||||||
static bool LoadELSMTokens(CElectricDescription* desc);
|
static bool LoadELSMTokens(CElectricDescription* desc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue