2016-02-10 22:54:47 +00:00
|
|
|
#include "CParticleSwooshDataFactory.hpp"
|
|
|
|
#include "CSwooshDescription.hpp"
|
2016-02-17 05:20:34 +00:00
|
|
|
#include "CElectricDescription.hpp"
|
|
|
|
#include "CGenDescription.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "Graphics/CModel.hpp"
|
2016-02-13 08:23:17 +00:00
|
|
|
#include "CRandom16.hpp"
|
2016-02-10 22:54:47 +00:00
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2016-02-10 22:54:47 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
static logvisor::Module Log("urde::CParticleSwooshDataFactory");
|
2016-02-13 08:23:17 +00:00
|
|
|
|
|
|
|
using CPF = CParticleDataFactory;
|
|
|
|
|
2017-02-13 21:29:00 +00:00
|
|
|
CSwooshDescription* CParticleSwooshDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool)
|
2016-02-13 08:23:17 +00:00
|
|
|
{
|
|
|
|
return CreateGeneratorDescription(in, resPool);
|
|
|
|
}
|
|
|
|
|
2017-02-13 21:29:00 +00:00
|
|
|
CSwooshDescription* CParticleSwooshDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool)
|
2016-02-13 08:23:17 +00:00
|
|
|
{
|
|
|
|
FourCC clsId = CPF::GetClassID(in);
|
|
|
|
if (clsId == FOURCC('SWSH'))
|
|
|
|
{
|
|
|
|
CSwooshDescription* desc = new CSwooshDescription;
|
2016-02-23 10:34:19 +00:00
|
|
|
if (CreateWPSM(desc, in, resPool))
|
|
|
|
return desc;
|
|
|
|
else
|
|
|
|
delete desc;
|
2016-02-13 08:23:17 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CParticleSwooshDataFactory::CreateWPSM(CSwooshDescription* desc, CInputStream& in, CSimplePool* resPool)
|
|
|
|
{
|
2016-02-15 08:23:50 +00:00
|
|
|
CRandom16 rand{99};
|
2016-02-13 08:23:17 +00:00
|
|
|
FourCC clsId = CPF::GetClassID(in);
|
|
|
|
while (clsId != SBIG('_END'))
|
|
|
|
{
|
|
|
|
CGlobalRandom gr(rand);
|
2017-02-13 21:29:00 +00:00
|
|
|
switch (clsId)
|
2016-02-13 08:23:17 +00:00
|
|
|
{
|
|
|
|
case SBIG('PSLT'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x0_PSLT = CPF::GetIntElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('TIME'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x4_TIME = CPF::GetRealElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('LRAD'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x8_LRAD = CPF::GetRealElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('RRAD'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->xc_RRAD = CPF::GetRealElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('LENG'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x10_LENG = CPF::GetIntElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('COLR'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x14_COLR = CPF::GetColorElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('SIDE'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x18_SIDE = CPF::GetIntElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('IROT'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x1c_IROT = CPF::GetRealElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('ROTM'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x20_ROTM = CPF::GetRealElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('POFS'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x24_POFS = CPF::GetVectorElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('IVEL'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x28_IVEL = CPF::GetVectorElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('NPOS'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x2c_NPOS = CPF::GetVectorElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('VELM'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x30_VELM = CPF::GetModVectorElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('VLM2'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x34_VLM2 = CPF::GetModVectorElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('SPLN'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x38_SPLN = CPF::GetIntElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('TEXR'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x3c_TEXR = CPF::GetTextureElement(in, resPool);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('TSPN'):
|
2018-05-20 06:14:57 +00:00
|
|
|
desc->x40_TSPN = CPF::GetIntElement(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('LLRD'):
|
|
|
|
desc->x44_24_LLRD = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('CROS'):
|
|
|
|
desc->x44_25_CROS = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('VLS1'):
|
|
|
|
desc->x44_26_VLS1 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('VLS2'):
|
|
|
|
desc->x44_27_VLS2 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('SROT'):
|
|
|
|
desc->x44_28_SROT = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('WIRE'):
|
|
|
|
desc->x44_29_WIRE = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('TEXW'):
|
|
|
|
desc->x44_30_TEXW = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('AALP'):
|
|
|
|
desc->x44_31_AALP = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('ZBUF'):
|
|
|
|
desc->x45_24_ZBUF = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('ORNT'):
|
|
|
|
desc->x45_25_ORNT = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('CRND'):
|
|
|
|
desc->x45_26_CRND = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 08:23:17 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
uint32_t clsName = clsId.toUint32();
|
2016-03-04 23:04:53 +00:00
|
|
|
Log.report(logvisor::Fatal, "Unknown SWSH class %.4s @%" PRIi64, &clsName, in.position());
|
2016-02-13 08:23:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clsId = CPF::GetClassID(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-10 22:54:47 +00:00
|
|
|
|
2017-02-13 21:29:00 +00:00
|
|
|
CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
|
|
|
CObjectReference*)
|
2016-02-10 22:54:47 +00:00
|
|
|
{
|
2016-12-23 06:41:39 +00:00
|
|
|
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
2017-02-13 21:29:00 +00:00
|
|
|
return TToken<CSwooshDescription>::GetIObjObjectFor(
|
|
|
|
std::unique_ptr<CSwooshDescription>(CParticleSwooshDataFactory::GetGeneratorDesc(in, sp)));
|
2016-02-10 22:54:47 +00:00
|
|
|
}
|
|
|
|
}
|