2016-02-02 04:29:58 +00:00
|
|
|
#include "ParticleCommon.hpp"
|
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace DataSpec
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
namespace DNAParticle
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
logvisor::Module LogModule("urde::DNAParticle");
|
2016-02-02 04:29:58 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void RealElementFactory::read(athena::io::YAMLDocReader& r)
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
const auto& mapChildren = r.getCurNode()->m_mapChildren;
|
|
|
|
if (mapChildren.empty())
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
const auto& elem = mapChildren[0];
|
|
|
|
if (elem.first.size() < 4)
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
case SBIG('LFTW'):
|
|
|
|
m_elem.reset(new struct RELifetimeTween);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REConstant);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct RETimeChain);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('ADD_'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REAdd);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CLMP'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REClamp);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('KEYE'):
|
|
|
|
case SBIG('KEYP'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REKeyframeEmitter);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('IRND'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REInitialRandom);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('RAND'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct RERandom);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('MULT'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REMultiply);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REPulse);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SCAL'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct RETimeScale);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('RLPT'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct RELifetimePercent);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SINE'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct RESineWave);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('ISWT'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REInitialSwitch);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CLTN'):
|
|
|
|
m_elem.reset(new struct RECompareLessThan);
|
|
|
|
break;
|
|
|
|
case SBIG('CEQL'):
|
|
|
|
m_elem.reset(new struct RECompareEquals);
|
|
|
|
break;
|
|
|
|
case SBIG('PAP1'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam1);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP2'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam2);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP3'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam3);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP4'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam4);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP5'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam5);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP6'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam6);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP7'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam7);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP8'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam8);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PSLL'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleSizeOrLineLength);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PRLW'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleRotationOrLineWidth);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SUB_'):
|
|
|
|
m_elem.reset(new struct RESubtract);
|
|
|
|
break;
|
|
|
|
case SBIG('VMAG'):
|
|
|
|
m_elem.reset(new struct REVectorMagnitude);
|
|
|
|
break;
|
|
|
|
case SBIG('VXTR'):
|
|
|
|
m_elem.reset(new struct REVectorXToReal);
|
|
|
|
break;
|
|
|
|
case SBIG('VYTR'):
|
|
|
|
m_elem.reset(new struct REVectorYToReal);
|
|
|
|
break;
|
|
|
|
case SBIG('VZTR'):
|
|
|
|
m_elem.reset(new struct REVectorZToReal);
|
|
|
|
break;
|
|
|
|
case SBIG('CEXT'):
|
|
|
|
m_elem.reset(new struct RECEXT);
|
|
|
|
break;
|
|
|
|
case SBIG('ITRL'):
|
2016-02-07 00:19:59 +00:00
|
|
|
m_elem.reset(new struct REIntTimesReal);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
2016-02-02 23:41:55 +00:00
|
|
|
default:
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset();
|
2016-02-02 23:41:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = r.enterSubRecord(elem.first.c_str()))
|
|
|
|
m_elem->read(r);
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void RealElementFactory::write(athena::io::YAMLDocWriter& w) const
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
|
|
|
|
m_elem->write(w);
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t RealElementFactory::binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
return m_elem->binarySize(__isz + 4);
|
|
|
|
else
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void RealElementFactory::read(athena::io::IStreamReader& r)
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
uint32_t clsId;
|
|
|
|
r.readBytesToBuf(&clsId, 4);
|
|
|
|
switch (clsId)
|
|
|
|
{
|
|
|
|
case SBIG('LFTW'):
|
|
|
|
m_elem.reset(new struct RELifetimeTween);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
|
|
|
m_elem.reset(new struct REConstant);
|
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
|
|
|
m_elem.reset(new struct RETimeChain);
|
|
|
|
break;
|
|
|
|
case SBIG('ADD_'):
|
|
|
|
m_elem.reset(new struct REAdd);
|
|
|
|
break;
|
|
|
|
case SBIG('CLMP'):
|
|
|
|
m_elem.reset(new struct REClamp);
|
|
|
|
break;
|
|
|
|
case SBIG('KEYE'):
|
2016-02-02 08:22:01 +00:00
|
|
|
case SBIG('KEYP'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct REKeyframeEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('IRND'):
|
|
|
|
m_elem.reset(new struct REInitialRandom);
|
|
|
|
break;
|
|
|
|
case SBIG('RAND'):
|
|
|
|
m_elem.reset(new struct RERandom);
|
|
|
|
break;
|
|
|
|
case SBIG('MULT'):
|
|
|
|
m_elem.reset(new struct REMultiply);
|
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
|
|
|
m_elem.reset(new struct REPulse);
|
|
|
|
break;
|
|
|
|
case SBIG('SCAL'):
|
|
|
|
m_elem.reset(new struct RETimeScale);
|
|
|
|
break;
|
|
|
|
case SBIG('RLPT'):
|
|
|
|
m_elem.reset(new struct RELifetimePercent);
|
|
|
|
break;
|
|
|
|
case SBIG('SINE'):
|
|
|
|
m_elem.reset(new struct RESineWave);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('ISWT'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REInitialSwitch);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CLTN'):
|
|
|
|
m_elem.reset(new struct RECompareLessThan);
|
|
|
|
break;
|
|
|
|
case SBIG('CEQL'):
|
|
|
|
m_elem.reset(new struct RECompareEquals);
|
|
|
|
break;
|
|
|
|
case SBIG('PAP1'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam1);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP2'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam2);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP3'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam3);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP4'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam4);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP5'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam5);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP6'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam6);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP7'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam7);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PAP8'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleAdvanceParam8);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PSLL'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleSizeOrLineLength);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PRLW'):
|
2016-03-02 22:37:10 +00:00
|
|
|
m_elem.reset(new struct REParticleRotationOrLineWidth);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SUB_'):
|
|
|
|
m_elem.reset(new struct RESubtract);
|
|
|
|
break;
|
|
|
|
case SBIG('VMAG'):
|
|
|
|
m_elem.reset(new struct REVectorMagnitude);
|
|
|
|
break;
|
|
|
|
case SBIG('VXTR'):
|
|
|
|
m_elem.reset(new struct REVectorXToReal);
|
|
|
|
break;
|
|
|
|
case SBIG('VYTR'):
|
|
|
|
m_elem.reset(new struct REVectorYToReal);
|
|
|
|
break;
|
|
|
|
case SBIG('VZTR'):
|
|
|
|
m_elem.reset(new struct REVectorZToReal);
|
|
|
|
break;
|
|
|
|
case SBIG('CEXT'):
|
|
|
|
m_elem.reset(new struct RECEXT);
|
|
|
|
break;
|
|
|
|
case SBIG('ITRL'):
|
2016-02-07 00:19:59 +00:00
|
|
|
m_elem.reset(new struct REIntTimesReal);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('NONE'):
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 04:29:58 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "Unknown RealElement class %.4s @%" PRIi64, &clsId, r.position());
|
2016-02-02 04:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_elem->read(r);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void RealElementFactory::write(athena::io::IStreamWriter& w) const
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem->write(w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w.writeBytes((atInt8*)"NONE", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void IntElementFactory::read(athena::io::YAMLDocReader& r)
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
const auto& mapChildren = r.getCurNode()->m_mapChildren;
|
|
|
|
if (mapChildren.empty())
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
const auto& elem = mapChildren[0];
|
|
|
|
if (elem.first.size() < 4)
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
case SBIG('KEYE'):
|
|
|
|
case SBIG('KEYP'):
|
|
|
|
m_elem.reset(new struct IEKeyframeEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('DETH'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEDeath);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CLMP'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEClamp);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IETimeChain);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('ADD_'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEAdd);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEConstant);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('IMPL'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEImpulse);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('ILPT'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IELifetimePercent);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('IRND'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEInitialRandom);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEPulse);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('MULT'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEMultiply);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SPAH'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IESampleAndHold);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('RAND'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IERandom);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('TSCL'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IETimeScale);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('GTCP'):
|
|
|
|
m_elem.reset(new struct IEGTCP);
|
|
|
|
break;
|
|
|
|
case SBIG('MODU'):
|
|
|
|
m_elem.reset(new struct IEModulo);
|
|
|
|
break;
|
|
|
|
case SBIG('SUB_'):
|
|
|
|
m_elem.reset(new struct IESubtract);
|
|
|
|
break;
|
2016-02-02 23:41:55 +00:00
|
|
|
default:
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset();
|
2016-02-02 23:41:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = r.enterSubRecord(elem.first.c_str()))
|
|
|
|
m_elem->read(r);
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void IntElementFactory::write(athena::io::YAMLDocWriter& w) const
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
|
|
|
|
m_elem->write(w);
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t IntElementFactory::binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
return m_elem->binarySize(__isz + 4);
|
|
|
|
else
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void IntElementFactory::read(athena::io::IStreamReader& r)
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
uint32_t clsId;
|
|
|
|
r.readBytesToBuf(&clsId, 4);
|
|
|
|
switch (clsId)
|
|
|
|
{
|
|
|
|
case SBIG('KEYE'):
|
2016-02-02 08:22:01 +00:00
|
|
|
case SBIG('KEYP'):
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem.reset(new struct IEKeyframeEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('DETH'):
|
|
|
|
m_elem.reset(new struct IEDeath);
|
|
|
|
break;
|
|
|
|
case SBIG('CLMP'):
|
|
|
|
m_elem.reset(new struct IEClamp);
|
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
|
|
|
m_elem.reset(new struct IETimeChain);
|
|
|
|
break;
|
|
|
|
case SBIG('ADD_'):
|
|
|
|
m_elem.reset(new struct IEAdd);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
|
|
|
m_elem.reset(new struct IEConstant);
|
|
|
|
break;
|
|
|
|
case SBIG('IMPL'):
|
|
|
|
m_elem.reset(new struct IEImpulse);
|
|
|
|
break;
|
|
|
|
case SBIG('ILPT'):
|
|
|
|
m_elem.reset(new struct IELifetimePercent);
|
|
|
|
break;
|
|
|
|
case SBIG('IRND'):
|
|
|
|
m_elem.reset(new struct IEInitialRandom);
|
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
|
|
|
m_elem.reset(new struct IEPulse);
|
|
|
|
break;
|
|
|
|
case SBIG('MULT'):
|
|
|
|
m_elem.reset(new struct IEMultiply);
|
|
|
|
break;
|
|
|
|
case SBIG('SPAH'):
|
|
|
|
m_elem.reset(new struct IESampleAndHold);
|
|
|
|
break;
|
|
|
|
case SBIG('RAND'):
|
|
|
|
m_elem.reset(new struct IERandom);
|
|
|
|
break;
|
|
|
|
case SBIG('TSCL'):
|
|
|
|
m_elem.reset(new struct IETimeScale);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('GTCP'):
|
|
|
|
m_elem.reset(new struct IEGTCP);
|
|
|
|
break;
|
|
|
|
case SBIG('MODU'):
|
|
|
|
m_elem.reset(new struct IEModulo);
|
|
|
|
break;
|
|
|
|
case SBIG('SUB_'):
|
|
|
|
m_elem.reset(new struct IESubtract);
|
|
|
|
break;
|
|
|
|
case SBIG('NONE'):
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 04:29:58 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "Unknown IntElement class %.4s @%" PRIi64, &clsId, r.position());
|
2016-02-02 04:29:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_elem->read(r);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void IntElementFactory::write(athena::io::IStreamWriter& w) const
|
2016-02-02 04:29:58 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
|
2016-02-02 04:29:58 +00:00
|
|
|
m_elem->write(w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w.writeBytes((atInt8*)"NONE", 4);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void VectorElementFactory::read(athena::io::YAMLDocReader& r)
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
const auto& mapChildren = r.getCurNode()->m_mapChildren;
|
|
|
|
if (mapChildren.empty())
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
const auto& elem = mapChildren[0];
|
|
|
|
if (elem.first.size() < 4)
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
case SBIG('CONE'):
|
|
|
|
m_elem.reset(new struct VECone);
|
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VETimeChain);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('ANGC'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VEAngleCone);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('ADD_'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VEAdd);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CCLU'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VECircleCluster);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VEConstant);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CIRC'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VECircle);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('KEYE'):
|
|
|
|
case SBIG('KEYP'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VEKeyframeEmitter);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('MULT'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VEMultiply);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('RTOV'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VERealToVector);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct VEPulse);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('PVEL'):
|
|
|
|
m_elem.reset(new struct VEParticleVelocity);
|
|
|
|
break;
|
|
|
|
case SBIG('SPOS'):
|
|
|
|
m_elem.reset(new struct VESPOS);
|
|
|
|
break;
|
|
|
|
case SBIG('PLCO'):
|
|
|
|
m_elem.reset(new struct VEPLCO);
|
|
|
|
break;
|
|
|
|
case SBIG('PLOC'):
|
|
|
|
m_elem.reset(new struct VEPLOC);
|
|
|
|
break;
|
|
|
|
case SBIG('PSOR'):
|
|
|
|
m_elem.reset(new struct VEPSOR);
|
|
|
|
break;
|
|
|
|
case SBIG('PSOF'):
|
|
|
|
m_elem.reset(new struct VEPSOF);
|
|
|
|
break;
|
2016-02-02 23:41:55 +00:00
|
|
|
default:
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset();
|
2016-02-02 23:41:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = r.enterSubRecord(elem.first.c_str()))
|
|
|
|
m_elem->read(r);
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void VectorElementFactory::write(athena::io::YAMLDocWriter& w) const
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
|
|
|
|
m_elem->write(w);
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t VectorElementFactory::binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
return m_elem->binarySize(__isz + 4);
|
|
|
|
else
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void VectorElementFactory::read(athena::io::IStreamReader& r)
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
uint32_t clsId;
|
|
|
|
r.readBytesToBuf(&clsId, 4);
|
|
|
|
switch (clsId)
|
|
|
|
{
|
|
|
|
case SBIG('CONE'):
|
|
|
|
m_elem.reset(new struct VECone);
|
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
|
|
|
m_elem.reset(new struct VETimeChain);
|
|
|
|
break;
|
|
|
|
case SBIG('ANGC'):
|
|
|
|
m_elem.reset(new struct VEAngleCone);
|
|
|
|
break;
|
|
|
|
case SBIG('ADD_'):
|
|
|
|
m_elem.reset(new struct VEAdd);
|
|
|
|
break;
|
|
|
|
case SBIG('CCLU'):
|
|
|
|
m_elem.reset(new struct VECircleCluster);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
|
|
|
m_elem.reset(new struct VEConstant);
|
|
|
|
break;
|
|
|
|
case SBIG('CIRC'):
|
|
|
|
m_elem.reset(new struct VECircle);
|
|
|
|
break;
|
|
|
|
case SBIG('KEYE'):
|
|
|
|
case SBIG('KEYP'):
|
|
|
|
m_elem.reset(new struct VEKeyframeEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('MULT'):
|
|
|
|
m_elem.reset(new struct VEMultiply);
|
|
|
|
break;
|
|
|
|
case SBIG('RTOV'):
|
|
|
|
m_elem.reset(new struct VERealToVector);
|
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
|
|
|
m_elem.reset(new struct VEPulse);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('PVEL'):
|
|
|
|
m_elem.reset(new struct VEParticleVelocity);
|
|
|
|
break;
|
|
|
|
case SBIG('SPOS'):
|
|
|
|
m_elem.reset(new struct VESPOS);
|
|
|
|
break;
|
|
|
|
case SBIG('PLCO'):
|
|
|
|
m_elem.reset(new struct VEPLCO);
|
|
|
|
break;
|
|
|
|
case SBIG('PLOC'):
|
|
|
|
m_elem.reset(new struct VEPLOC);
|
|
|
|
break;
|
|
|
|
case SBIG('PSOR'):
|
|
|
|
m_elem.reset(new struct VEPSOR);
|
|
|
|
break;
|
|
|
|
case SBIG('PSOF'):
|
|
|
|
m_elem.reset(new struct VEPSOF);
|
|
|
|
break;
|
|
|
|
case SBIG('NONE'):
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 08:22:01 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "Unknown VectorElement class %.4s @%" PRIi64, &clsId, r.position());
|
2016-02-02 08:22:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_elem->read(r);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void VectorElementFactory::write(athena::io::IStreamWriter& w) const
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem->write(w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w.writeBytes((atInt8*)"NONE", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ColorElementFactory::read(athena::io::YAMLDocReader& r)
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
const auto& mapChildren = r.getCurNode()->m_mapChildren;
|
|
|
|
if (mapChildren.empty())
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
const auto& elem = mapChildren[0];
|
|
|
|
if (elem.first.size() < 4)
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
case SBIG('KEYE'):
|
|
|
|
case SBIG('KEYP'):
|
|
|
|
m_elem.reset(new struct CEKeyframeEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct CEConstant);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct CETimeChain);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CFDE'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct CEFadeEnd);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('FADE'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct CEFade);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct CEPulse);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset();
|
2016-02-02 23:41:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = r.enterSubRecord(elem.first.c_str()))
|
|
|
|
m_elem->read(r);
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ColorElementFactory::write(athena::io::YAMLDocWriter& w) const
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
|
|
|
|
m_elem->write(w);
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t ColorElementFactory::binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
return m_elem->binarySize(__isz + 4);
|
|
|
|
else
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ColorElementFactory::read(athena::io::IStreamReader& r)
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
uint32_t clsId;
|
|
|
|
r.readBytesToBuf(&clsId, 4);
|
|
|
|
switch (clsId)
|
|
|
|
{
|
|
|
|
case SBIG('KEYE'):
|
|
|
|
case SBIG('KEYP'):
|
|
|
|
m_elem.reset(new struct CEKeyframeEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
|
|
|
m_elem.reset(new struct CEConstant);
|
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
|
|
|
m_elem.reset(new struct CETimeChain);
|
|
|
|
break;
|
|
|
|
case SBIG('CFDE'):
|
|
|
|
m_elem.reset(new struct CEFadeEnd);
|
|
|
|
break;
|
|
|
|
case SBIG('FADE'):
|
|
|
|
m_elem.reset(new struct CEFade);
|
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
|
|
|
m_elem.reset(new struct CEPulse);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('NONE'):
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 08:22:01 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "Unknown ColorElement class %.4s @%" PRIi64, &clsId, r.position());
|
2016-02-02 08:22:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_elem->read(r);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ColorElementFactory::write(athena::io::IStreamWriter& w) const
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem->write(w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w.writeBytes((atInt8*)"NONE", 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ModVectorElementFactory::read(athena::io::YAMLDocReader& r)
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
const auto& mapChildren = r.getCurNode()->m_mapChildren;
|
|
|
|
if (mapChildren.empty())
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
const auto& elem = mapChildren[0];
|
|
|
|
if (elem.first.size() < 4)
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());
|
2016-02-02 23:41:55 +00:00
|
|
|
|
|
|
|
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
case SBIG('IMPL'):
|
|
|
|
m_elem.reset(new struct MVEImplosion);
|
|
|
|
break;
|
|
|
|
case SBIG('EMPL'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEExponentialImplosion);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVETimeChain);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('BNCE'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEBounce);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEConstant);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('GRAV'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEGravity);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('EXPL'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEExplode);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SPOS'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVESetPosition);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('LMPL'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVELinearImplosion);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEPulse);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('WIND'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVEWind);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
case SBIG('SWRL'):
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset(new struct MVESwirl);
|
2016-02-02 23:41:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem.reset();
|
2016-02-02 23:41:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = r.enterSubRecord(elem.first.c_str()))
|
|
|
|
m_elem->read(r);
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ModVectorElementFactory::write(athena::io::YAMLDocWriter& w) const
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
|
|
|
|
m_elem->write(w);
|
2016-02-02 08:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t ModVectorElementFactory::binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
return m_elem->binarySize(__isz + 4);
|
|
|
|
else
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ModVectorElementFactory::read(athena::io::IStreamReader& r)
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
uint32_t clsId;
|
|
|
|
r.readBytesToBuf(&clsId, 4);
|
|
|
|
switch (clsId)
|
|
|
|
{
|
|
|
|
case SBIG('IMPL'):
|
|
|
|
m_elem.reset(new struct MVEImplosion);
|
|
|
|
break;
|
|
|
|
case SBIG('EMPL'):
|
|
|
|
m_elem.reset(new struct MVEExponentialImplosion);
|
|
|
|
break;
|
|
|
|
case SBIG('CHAN'):
|
|
|
|
m_elem.reset(new struct MVETimeChain);
|
|
|
|
break;
|
|
|
|
case SBIG('BNCE'):
|
|
|
|
m_elem.reset(new struct MVEBounce);
|
|
|
|
break;
|
|
|
|
case SBIG('CNST'):
|
|
|
|
m_elem.reset(new struct MVEConstant);
|
|
|
|
break;
|
|
|
|
case SBIG('GRAV'):
|
|
|
|
m_elem.reset(new struct MVEGravity);
|
|
|
|
break;
|
|
|
|
case SBIG('EXPL'):
|
|
|
|
m_elem.reset(new struct MVEExplode);
|
|
|
|
break;
|
|
|
|
case SBIG('SPOS'):
|
|
|
|
m_elem.reset(new struct MVESetPosition);
|
|
|
|
break;
|
|
|
|
case SBIG('LMPL'):
|
|
|
|
m_elem.reset(new struct MVELinearImplosion);
|
|
|
|
break;
|
|
|
|
case SBIG('PULS'):
|
|
|
|
m_elem.reset(new struct MVEPulse);
|
|
|
|
break;
|
|
|
|
case SBIG('WIND'):
|
|
|
|
m_elem.reset(new struct MVEWind);
|
|
|
|
break;
|
|
|
|
case SBIG('SWRL'):
|
|
|
|
m_elem.reset(new struct MVESwirl);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('NONE'):
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-02 08:22:01 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "Unknown ModVectorElement class %.4s @%" PRIi64, &clsId, r.position());
|
2016-02-02 08:22:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_elem->read(r);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void ModVectorElementFactory::write(athena::io::IStreamWriter& w) const
|
2016-02-02 08:22:01 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
{
|
2016-02-02 23:41:55 +00:00
|
|
|
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
|
2016-02-02 08:22:01 +00:00
|
|
|
m_elem->write(w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w.writeBytes((atInt8*)"NONE", 4);
|
|
|
|
}
|
|
|
|
|
2016-02-03 03:58:33 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void EmitterElementFactory::read(athena::io::YAMLDocReader& r)
|
2016-02-03 03:58:33 +00:00
|
|
|
{
|
|
|
|
const auto& mapChildren = r.getCurNode()->m_mapChildren;
|
|
|
|
if (mapChildren.empty())
|
|
|
|
{
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto& elem = mapChildren[0];
|
|
|
|
if (elem.first.size() < 4)
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());
|
2016-02-03 03:58:33 +00:00
|
|
|
|
|
|
|
switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
|
|
|
|
{
|
|
|
|
case SBIG('SETR'):
|
|
|
|
m_elem.reset(new struct EESimpleEmitterTR);
|
|
|
|
break;
|
|
|
|
case SBIG('SEMR'):
|
|
|
|
m_elem.reset(new struct EESimpleEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('SPHE'):
|
|
|
|
m_elem.reset(new struct VESphere);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('ASPH'):
|
2016-02-06 00:34:40 +00:00
|
|
|
m_elem.reset(new struct VEAngleSphere);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
2016-02-03 03:58:33 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
|
|
|
}
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = r.enterSubRecord(elem.first.c_str()))
|
|
|
|
m_elem->read(r);
|
2016-02-03 03:58:33 +00:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void EmitterElementFactory::write(athena::io::YAMLDocWriter& w) const
|
2016-02-03 03:58:33 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto rec = w.enterSubRecord(m_elem->ClassID()))
|
|
|
|
m_elem->write(w);
|
2016-02-03 03:58:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t EmitterElementFactory::binarySize(size_t __isz) const
|
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
return m_elem->binarySize(__isz + 4);
|
|
|
|
else
|
|
|
|
return __isz + 4;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void EmitterElementFactory::read(athena::io::IStreamReader& r)
|
2016-02-03 03:58:33 +00:00
|
|
|
{
|
|
|
|
uint32_t clsId;
|
|
|
|
r.readBytesToBuf(&clsId, 4);
|
|
|
|
switch (clsId)
|
|
|
|
{
|
|
|
|
case SBIG('SETR'):
|
|
|
|
m_elem.reset(new struct EESimpleEmitterTR);
|
|
|
|
break;
|
|
|
|
case SBIG('SEMR'):
|
|
|
|
m_elem.reset(new struct EESimpleEmitter);
|
|
|
|
break;
|
|
|
|
case SBIG('SPHE'):
|
|
|
|
m_elem.reset(new struct VESphere);
|
|
|
|
break;
|
2016-02-04 00:55:39 +00:00
|
|
|
case SBIG('ASPH'):
|
2016-02-06 00:34:40 +00:00
|
|
|
m_elem.reset(new struct VEAngleSphere);
|
2016-02-04 00:55:39 +00:00
|
|
|
break;
|
|
|
|
case SBIG('NONE'):
|
|
|
|
m_elem.reset();
|
|
|
|
return;
|
2016-02-03 03:58:33 +00:00
|
|
|
default:
|
|
|
|
m_elem.reset();
|
2016-03-04 23:04:53 +00:00
|
|
|
LogModule.report(logvisor::Fatal, "Unknown EmitterElement class %.4s @%" PRIi64, &clsId, r.position());
|
2016-02-03 03:58:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_elem->read(r);
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
void EmitterElementFactory::write(athena::io::IStreamWriter& w) const
|
2016-02-03 03:58:33 +00:00
|
|
|
{
|
|
|
|
if (m_elem)
|
|
|
|
{
|
|
|
|
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
|
|
|
|
m_elem->write(w);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w.writeBytes((atInt8*)"NONE", 4);
|
|
|
|
}
|
|
|
|
|
2016-02-02 04:29:58 +00:00
|
|
|
}
|
|
|
|
}
|