Exemple #1
0
MREA::StreamReader::StreamReader(athena::io::IStreamReader& source,
                                 atUint32 blkCount, atUint32 secIdxCount)
: DNAMP2::MREA::StreamReader(source)
{
    m_blkCount = blkCount;
    m_blockInfos.reserve(blkCount);
    for (atUint32 i=0 ; i<blkCount ; ++i)
    {
        m_blockInfos.emplace_back();
        BlockInfo& info = m_blockInfos.back();
        info.read(source);
        m_totalDecompLen += info.decompSize;
    }
    source.seekAlign32();
    m_secIdxs.reserve(secIdxCount);
    for (atUint32 i=0 ; i<secIdxCount ; ++i)
    {
        m_secIdxs.emplace_back();
        std::pair<DNAFourCC, atUint32>& idx = m_secIdxs.back();
        idx.first.read(source);
        idx.second = source.readUint32Big();
    }
    source.seekAlign32();
    m_blkBase = source.position();
    nextBlock();
}
Exemple #2
0
void STRG::_read(athena::io::IStreamReader& reader)
{
    atUint32 langCount = reader.readUint32Big();
    atUint32 strCount = reader.readUint32Big();

    std::vector<FourCC> readLangs;
    readLangs.reserve(langCount);
    for (atUint32 l=0 ; l<langCount ; ++l)
    {
        DNAFourCC lang;
        lang.read(reader);
        readLangs.emplace_back(lang);
        reader.seek(4);
    }

    langs.clear();
    langs.reserve(langCount);
    for (FourCC& lang : readLangs)
    {
        std::vector<std::wstring> strs;
        reader.seek(strCount * 4 + 4);
        for (atUint32 s=0 ; s<strCount ; ++s)
            strs.emplace_back(reader.readWStringBig());
        langs.emplace_back(lang, strs);
    }

    langMap.clear();
    langMap.reserve(langCount);
    for (std::pair<FourCC, std::vector<std::wstring>>& item : langs)
        langMap.emplace(item.first, &item.second);
}
Exemple #3
0
 void readBGRABig(athena::io::IStreamReader& reader) {
   simd_floats f;
   f[2] = reader.readFloatBig();
   f[1] = reader.readFloatBig();
   f[0] = reader.readFloatBig();
   f[3] = reader.readFloatBig();
   mSimd.copy_from(f);
 }
Exemple #4
0
void STRG::read(athena::io::IStreamReader& reader)
{
    atUint32 magic = reader.readUint32Big();
    if (magic != 0x87654321)
        Log.report(logvisor::Error, "invalid STRG magic");

    atUint32 version = reader.readUint32Big();
    if (version != 0)
        Log.report(logvisor::Error, "invalid STRG version");

    _read(reader);
}
Exemple #5
0
void ColorElementFactory::read(athena::io::IStreamReader& r)
{
    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;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown ColorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
Exemple #6
0
void EmitterElementFactory::read(athena::io::IStreamReader& r)
{
    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;
    case SBIG('ASPH'):
        m_elem.reset(new struct VEAngleSphere);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown EmitterElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
Exemple #7
0
void LittleUInt24::Enumerate<LittleDNA::Read>(athena::io::IStreamReader& reader) {
  union {
    atUint32 val;
    char bytes[4];
  } data = {};
  reader.readBytesToBuf(data.bytes, 3);
  val = SLittle(data.val);
}
Exemple #8
0
void MREA::ReadBabeDeadToBlender_3(hecl::BlenderConnection::PyOutStream& os,
                                   athena::io::IStreamReader& rs)
{
    atUint32 bdMagic = rs.readUint32Big();
    if (bdMagic != 0xBABEDEAD)
        Log.report(logvisor::Fatal, "invalid BABEDEAD magic");
    os << "bpy.context.scene.render.engine = 'CYCLES'\n"
          "bpy.context.scene.world.use_nodes = True\n"
          "bpy.context.scene.render.engine = 'BLENDER_GAME'\n"
          "bg_node = bpy.context.scene.world.node_tree.nodes['Background']\n";
    for (atUint32 s=0 ; s<4 ; ++s)
    {
        atUint32 lightCount = rs.readUint32Big();
        for (atUint32 l=0 ; l<lightCount ; ++l)
        {
            BabeDeadLight light;
            light.read(rs);
            ReadBabeDeadLightToBlender(os, light, s, l);
        }
    }
}
Exemple #9
0
void ModVectorElementFactory::read(athena::io::IStreamReader& r)
{
    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;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown ModVectorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
Exemple #10
0
void ANIM::ANIM2::read(athena::io::IStreamReader& reader)
{
    Header head;
    head.read(reader);
    evnt = head.evnt;
    mainInterval = head.interval;

    WordBitmap keyBmp;
    keyBmp.read(reader, head.keyBitmapBitCount);
    frames.clear();
    atUint32 frameAccum = 0;
    for (bool bit : keyBmp)
    {
        if (bit)
            frames.push_back(frameAccum);
        ++frameAccum;
    }
    reader.seek(8);

    bones.clear();
    bones.reserve(head.boneChannelCount);
    channels.clear();
    channels.reserve(head.boneChannelCount);
    atUint16 keyframeCount = 0;
    for (size_t b=0 ; b<head.boneChannelCount ; ++b)
    {
        ChannelDesc desc;
        desc.read(reader);
        bones.emplace_back(desc.id, desc.keyCount2 != 0);

        if (desc.keyCount1)
        {
            channels.emplace_back();
            DNAANIM::Channel& chan = channels.back();
            chan.type = DNAANIM::Channel::Type::Rotation;
            chan.i[0] = desc.initRX;
            chan.q[0] = desc.qRX;
            chan.i[1] = desc.initRY;
            chan.q[1] = desc.qRY;
            chan.i[2] = desc.initRZ;
            chan.q[2] = desc.qRZ;
        }
        keyframeCount = std::max(keyframeCount, desc.keyCount1);

        if (desc.keyCount2)
        {
            channels.emplace_back();
            DNAANIM::Channel& chan = channels.back();
            chan.type = DNAANIM::Channel::Type::Translation;
            chan.i[0] = desc.initTX;
            chan.q[0] = desc.qTX;
            chan.i[1] = desc.initTY;
            chan.q[1] = desc.qTY;
            chan.i[2] = desc.initTZ;
            chan.q[2] = desc.qTZ;
        }
    }

    size_t bsSize = DNAANIM::ComputeBitstreamSize(keyframeCount, channels);
    std::unique_ptr<atUint8[]> bsData = reader.readUBytes(bsSize);
    DNAANIM::BitstreamReader bsReader;
    chanKeys = bsReader.read(bsData.get(), keyframeCount, channels, head.rotDiv, head.translationMult);
}
Exemple #11
0
void RealElementFactory::read(athena::io::IStreamReader& r)
{
    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'):
    case SBIG('KEYP'):
        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;
    case SBIG('ISWT'):
        m_elem.reset(new struct REInitialSwitch);
        break;
    case SBIG('CLTN'):
        m_elem.reset(new struct RECompareLessThan);
        break;
    case SBIG('CEQL'):
        m_elem.reset(new struct RECompareEquals);
        break;
    case SBIG('PAP1'):
        m_elem.reset(new struct REParticleAdvanceParam1);
        break;
    case SBIG('PAP2'):
        m_elem.reset(new struct REParticleAdvanceParam2);
        break;
    case SBIG('PAP3'):
        m_elem.reset(new struct REParticleAdvanceParam3);
        break;
    case SBIG('PAP4'):
        m_elem.reset(new struct REParticleAdvanceParam4);
        break;
    case SBIG('PAP5'):
        m_elem.reset(new struct REParticleAdvanceParam5);
        break;
    case SBIG('PAP6'):
        m_elem.reset(new struct REParticleAdvanceParam6);
        break;
    case SBIG('PAP7'):
        m_elem.reset(new struct REParticleAdvanceParam7);
        break;
    case SBIG('PAP8'):
        m_elem.reset(new struct REParticleAdvanceParam8);
        break;
    case SBIG('PSLL'):
        m_elem.reset(new struct REParticleSizeOrLineLength);
        break;
    case SBIG('PRLW'):
        m_elem.reset(new struct REParticleRotationOrLineWidth);
        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'):
        m_elem.reset(new struct REIntTimesReal);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown RealElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
Exemple #12
0
CVector3d::CVector3d(Athena::io::IStreamReader& input)
{
    x = input.readDouble();
    y = input.readDouble();
    z = input.readDouble();
}
Exemple #13
0
void IntElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        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;
    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;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown IntElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
Exemple #14
0
void SoundMacroStepDNA<athena::Big>::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
  step = reader.readUint16Big();
}
Exemple #15
0
void PageObjectIdDNA<athena::Big>::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
  id = reader.readUint16Big();
}
Exemple #16
0
void VectorElementFactory::read(athena::io::IStreamReader& r)
{
    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;
    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;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown VectorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
Exemple #17
0
void ANIM::ANIM0::read(athena::io::IStreamReader& reader)
{
    Header head;
    head.read(reader);
    mainInterval = head.interval;

    frames.clear();
    frames.reserve(head.keyCount);
    for (size_t k=0 ; k<head.keyCount ; ++k)
        frames.push_back(k);

    std::map<atUint8, atUint32> boneMap;
    for (size_t b=0 ; b<head.boneSlotCount ; ++b)
    {
        atUint8 idx = reader.readUByte();
        if (idx == 0xff)
            continue;
        boneMap[idx] = b;
    }

    atUint32 boneCount = reader.readUint32Big();
    bones.clear();
    bones.reserve(boneCount);
    channels.clear();
    for (size_t b=0 ; b<boneCount ; ++b)
    {
        bones.emplace_back(boneMap[b], false);
        atUint8 idx = reader.readUByte();
        channels.emplace_back();
        DNAANIM::Channel& chan = channels.back();
        chan.type = DNAANIM::Channel::Type::Rotation;
        if (idx != 0xff)
        {
            bones.back().second = true;
            channels.emplace_back();
            DNAANIM::Channel& chan = channels.back();
            chan.type = DNAANIM::Channel::Type::Translation;
        }
    }

    reader.readUint32Big();
    chanKeys.clear();
    chanKeys.reserve(channels.size());
    for (const std::pair<atUint32, bool>& bone : bones)
    {
        chanKeys.emplace_back();
        std::vector<DNAANIM::Value>& keys = chanKeys.back();
        for (size_t k=0 ; k<head.keyCount ; ++k)
            keys.emplace_back(reader.readVec4fBig());

        if (bone.second)
            chanKeys.emplace_back();
    }

    reader.readUint32Big();
    auto kit = chanKeys.begin();
    for (const std::pair<atUint32, bool>& bone : bones)
    {
        ++kit;
        if (bone.second)
        {
            std::vector<DNAANIM::Value>& keys = *kit++;
            for (size_t k=0 ; k<head.keyCount ; ++k)
                keys.emplace_back(reader.readVec3fBig());
        }
    }

    evnt.read(reader);
}
Exemple #18
0
 CFourCC(Athena::io::IStreamReader& src)
 {
     src.readUBytesToBuf(fourCC, 4);
 }
CPASDatabase::CPASDatabase(Athena::io::IStreamReader& in)
{
    CFourCC magic(in);
    if (magic != skPAS4FourCC)
        THROW_INVALID_DATA_EXCEPTION("Invalid PASDatabase magic expected 'PAS4'' got 0x%.4s", magic);

    atUint32 stateCount = in.readUint32();
    m_defaultState = in.readInt32();
    if (m_defaultState == ~0)
        return;

    while ((stateCount--) > 0)
    {
        SPASAnimState state;
        state.unknown1 = in.readUint32();
        atUint32 parmInfoCount = in.readUint32();
        atUint32 animInfoCount = in.readUint32();

        for (atUint32 i = 0; i < parmInfoCount; i++)
        {
            SPASParmInfo info;
            info.type = (EParmType)in.readUint32();
            info.unknown1 = in.readUint32();
            info.unknown2 = in.readFloat();

            for (atUint32 j = 0; j < 2; j++)
            {
                switch(info.type)
                {
                case eInt32:
                {
                    atInt32 tmp = in.readInt32();
                    info.parameters[j] = CPASInt32Paramater(tmp);
                }
                    break;
                case eUint32:
                {
                    atUint32 tmp = in.readUint32();
                    info.parameters[j] = CPASUint32Parameter(tmp);
                }
                    break;
                case eEnum:
                {
                    atUint32 tmp = in.readUint32();
                    info.parameters[j] = CPASEnumParameter(tmp);
                }
                    break;
                case eReal32:
                {
                    float tmp = in.readFloat();
                    info.parameters[j] = CPASReal32Parameter(tmp);
                }
                    break;
                case eBool:
                {
                    bool tmp = in.readBool();
                    info.parameters[j] = CPASBoolParameter(tmp);
                }
                    break;
                }
            }
            state.parmInfo.push_back(info);
        }

        for (atUint32 i = 0; i < animInfoCount; i++)
        {
            SPASAnimInfo info;
            info.unknown1 = in.readUint32();
            for (atUint32 j = 0; j < parmInfoCount; j++)
            {
                switch(state.parmInfo[j].type)
                {
                case eInt32:
                {
                    atInt32 tmp = in.readInt32();
                    info.parameters.push_back(CPASInt32Paramater(tmp));
                }
                    break;
                case eUint32:
                {
                    atUint32 tmp = in.readUint32();
                    info.parameters.push_back(CPASUint32Parameter(tmp));
                }
                    break;
                case eEnum:
                {
                    atUint32 tmp = in.readUint32();
                    info.parameters.push_back(CPASEnumParameter(tmp));
                }
                    break;
                case eReal32:
                {
                    float tmp = in.readFloat();
                    info.parameters.push_back(CPASReal32Parameter(tmp));
                }
                    break;
                case eBool:
                {
                    bool tmp = in.readBool();
                    info.parameters.push_back(CPASBoolParameter(tmp));
                }
                    break;
                }
            }
            state.animInfo.push_back(info);
        }
        m_states.push_back(state);
    }
}