Fixes and Swoosh factory

This commit is contained in:
Phillip Stephens 2016-02-13 00:23:17 -08:00
parent 5a5d09a410
commit 4595b7b6ab
7 changed files with 185 additions and 15 deletions

View File

@ -12,6 +12,7 @@ class CRandom16
u32 m_seed;
static CRandom16* g_randomNumber;
public:
CRandom16() = default;
CRandom16(u32 p) : m_seed(p) {}
inline u32 Next()

View File

@ -2,11 +2,18 @@
#define __RETRO_CELECTRICDESCRIPTION_HPP__
#include "CParticleDataFactory.hpp"
#include "CRealElement.hpp"
#include "CIntElement.hpp"
#include "CVectorElement.hpp"
#include "CModVectorElement.hpp"
#include "CColorElement.hpp"
#include "CUVElement.hpp"
namespace Retro
{
class CElectricDescription
{
public:
std::unique_ptr<CIntElement> x0_LIFE;
std::unique_ptr<CIntElement> x4_SLIF;
std::unique_ptr<CRealElement> x8_GRAT;
@ -20,9 +27,9 @@ class CElectricDescription
bool x28_LWD1;
bool x2c_LWD2;
bool x30_LWD3;
bool x34_LCL1;
bool x38_LCL2;
bool x3c_LCL3;
std::unique_ptr<CColorElement> x34_LCL1;
std::unique_ptr<CColorElement> x38_LCL2;
std::unique_ptr<CColorElement> x3c_LCL3;
SSwooshGeneratorDesc x40_SSWH;
SChildGeneratorDesc x50_GPSM;
SChildGeneratorDesc x60_EPSM;

View File

@ -1,10 +1,12 @@
#include "CParticleElectricDataFactory.hpp"
#include "CElectricDescription.hpp"
#include "CToken.hpp"
#include "CSimplePool.hpp"
#include "CRandom16.hpp"
namespace Retro
{
static LogVisor::LogModule Log("Retro::CParticleElectricDataFactory");
using CPF = CParticleDataFactory;
@ -15,13 +17,13 @@ CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStrea
CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream &in, CSimplePool *resPool)
{
FourCC cid = CParticleDataFactory::GetClassID(in);
FourCC cid = CPF::GetClassID(in);
if (cid == FOURCC('ELSM'))
{
CElectricDescription* ret = new CElectricDescription;
CElectricDescription* desc = new CElectricDescription;
CreateELSM(desc, in, resPool);
LoadELSMTokens(ret);
return ret;
LoadELSMTokens(desc);
return desc;
}
return nullptr;
@ -36,7 +38,7 @@ bool CParticleElectricDataFactory::CreateELSM(CElectricDescription *desc, CInput
CGlobalRandom gr(rand);
switch(clsId)
{
case SBIG(''):
case SBIG('LIFE'):
desc->x0_LIFE.reset(CPF::GetIntElement(in));
break;
case SBIG('SLIF'):
@ -111,7 +113,7 @@ bool CParticleElectricDataFactory::CreateELSM(CElectricDescription *desc, CInput
return false;
}
}
clsId = GetClassID(in);
clsId = CPF::GetClassID(in);
}
return true;
}

View File

@ -12,12 +12,11 @@ class CElectricDescription;
class CSimplePool;
class CParticleElectricDataFactory
{
public:
static CElectricDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
static CElectricDescription* CreateElectricDescription(CInputStream& in, CSimplePool* resPool);
static bool CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool);
static bool LoadELSMTokens(CElectricDescription* desc);
public:
static CElectricDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
};
std::unique_ptr<IObj> FParticleElectricDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms);

View File

@ -1,14 +1,141 @@
#include "CParticleSwooshDataFactory.hpp"
#include "CSwooshDescription.hpp"
#include "CRandom16.hpp"
#include "CSimplePool.hpp"
namespace Retro
{
static LogVisor::LogModule Log("Retro::CParticleSwooshDataFactory");
using CPF = CParticleDataFactory;
CSwooshDescription*CParticleSwooshDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool)
{
return CreateGeneratorDescription(in, resPool);
}
CSwooshDescription*CParticleSwooshDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool)
{
FourCC clsId = CPF::GetClassID(in);
if (clsId == FOURCC('SWSH'))
{
CSwooshDescription* desc = new CSwooshDescription;
CreateWPSM(desc, in, resPool);
return desc;
}
return nullptr;
}
bool CParticleSwooshDataFactory::CreateWPSM(CSwooshDescription* desc, CInputStream& in, CSimplePool* resPool)
{
CRandom16 rand;
FourCC clsId = CPF::GetClassID(in);
while (clsId != SBIG('_END'))
{
CGlobalRandom gr(rand);
switch(clsId)
{
case SBIG('PSLT'):
desc->x0_PSLT.reset(CPF::GetIntElement(in));
break;
case SBIG('TIME'):
desc->x4_TIME.reset(CPF::GetRealElement(in));
break;
case SBIG('LRAD'):
desc->x8_LRAD.reset(CPF::GetRealElement(in));
break;
case SBIG('RRAD'):
desc->xc_RRAD.reset(CPF::GetRealElement(in));
break;
case SBIG('LENG'):
desc->x10_LENG.reset(CPF::GetIntElement(in));
break;
case SBIG('COLR'):
desc->x14_COLR.reset(CPF::GetColorElement(in));
break;
case SBIG('SIDE'):
desc->x18_SIDE.reset(CPF::GetIntElement(in));
break;
case SBIG('IROT'):
desc->x1c_IROT.reset(CPF::GetRealElement(in));
break;
case SBIG('ROTM'):
desc->x20_ROTM.reset(CPF::GetRealElement(in));
break;
case SBIG('POFS'):
desc->x24_POFS.reset(CPF::GetVectorElement(in));
break;
case SBIG('IVEL'):
desc->x28_IVEL.reset(CPF::GetVectorElement(in));
break;
case SBIG('NPOS'):
desc->x2c_NPOS.reset(CPF::GetVectorElement(in));
break;
case SBIG('VELM'):
desc->x30_VELM.reset(CPF::GetModVectorElement(in));
break;
case SBIG('VLM2'):
desc->x34_VLM2.reset(CPF::GetModVectorElement(in));
break;
case SBIG('SPLN'):
desc->x38_SPLN.reset(CPF::GetIntElement(in));
break;
case SBIG('TEXR'):
desc->x3c_TEXR.reset(CPF::GetTextureElement(in, resPool));
break;
case SBIG('TSPN'):
desc->x40_TSPN.reset(CPF::GetIntElement(in));
break;
case SBIG('LLRD'):
desc->x44_24_LLRD = CPF::GetBool(in);
break;
case SBIG('CROS'):
desc->x44_25_CROS = CPF::GetBool(in);
break;
case SBIG('VLS1'):
desc->x44_26_VLS1 = CPF::GetBool(in);
break;
case SBIG('VLS2'):
desc->x44_27_VLS2 = CPF::GetBool(in);
break;
case SBIG('SROT'):
desc->x44_28_SROT = CPF::GetBool(in);
break;
case SBIG('WIRE'):
desc->x44_29_WIRE = CPF::GetBool(in);
break;
case SBIG('TEXW'):
desc->x44_30_TEXW = CPF::GetBool(in);
break;
case SBIG('AALP'):
desc->x44_31_AALP = CPF::GetBool(in);
break;
case SBIG('ZBUF'):
desc->x45_24_ZBUF = CPF::GetBool(in);
break;
case SBIG('ORNT'):
desc->x45_25_ORNT = CPF::GetBool(in);
break;
case SBIG('CRND'):
desc->x45_26_CRND = CPF::GetBool(in);
break;
default:
{
uint32_t clsName = clsId.toUint32();
Log.report(LogVisor::FatalError, "Unknown SSWH class %.4s @%" PRIi64, &clsName, in.position());
return false;
}
}
clsId = CPF::GetClassID(in);
}
return true;
}
std::unique_ptr<Retro::IObj> FParticleSwooshDataFactory(const SObjectTag &tag, CInputStream &in, const CVParamTransfer &vparms)
{
CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
return TToken<CSwooshDescription>::GetIObjObjectFor(std::unique_ptr<CSwooshDescription>(CParticleSwooshDataFactory::GetGeneratorDesc(in, sp)));
}
}

View File

@ -12,10 +12,10 @@ class CSwooshDescription;
class CSimplePool;
class CParticleSwooshDataFactory
{
public:
static CSwooshDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
static CSwooshDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
static bool CreateWPSM(CSwooshDescription* desc, CInputStream& in, CSimplePool* resPool);
public:
static CSwooshDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
};
std::unique_ptr<IObj> FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms);

View File

@ -2,11 +2,45 @@
#define __RETRO_CSWOOSHDESCRIPTION_HPP__
#include "CParticleDataFactory.hpp"
#include "CRealElement.hpp"
#include "CIntElement.hpp"
#include "CVectorElement.hpp"
#include "CModVectorElement.hpp"
#include "CColorElement.hpp"
#include "CUVElement.hpp"
namespace Retro
{
class CSwooshDescription
{
public:
std::unique_ptr<CIntElement> x0_PSLT;
std::unique_ptr<CRealElement> x4_TIME;
std::unique_ptr<CRealElement> x8_LRAD;
std::unique_ptr<CRealElement> xc_RRAD;
std::unique_ptr<CIntElement> x10_LENG;
std::unique_ptr<CColorElement> x14_COLR;
std::unique_ptr<CIntElement> x18_SIDE;
std::unique_ptr<CRealElement> x1c_IROT;
std::unique_ptr<CRealElement> x20_ROTM;
std::unique_ptr<CVectorElement> x24_POFS;
std::unique_ptr<CVectorElement> x28_IVEL;
std::unique_ptr<CVectorElement> x2c_NPOS;
std::unique_ptr<CModVectorElement> x30_VELM;
std::unique_ptr<CModVectorElement> x34_VLM2;
std::unique_ptr<CIntElement> x38_SPLN;
std::unique_ptr<CUVElement> x3c_TEXR;
std::unique_ptr<CIntElement> x40_TSPN;
union
{
struct
{
bool x44_24_LLRD : 1; bool x44_25_CROS : 1; bool x44_26_VLS1 : 1; bool x44_27_VLS2 : 1;
bool x44_28_SROT : 1; bool x44_29_WIRE : 1; bool x44_30_TEXW : 1; bool x44_31_AALP : 1;
bool x45_24_ZBUF : 1; bool x45_25_ORNT : 1; bool x45_26_CRND : 1;
};
u16 dummy = 0;
};
};
}