Merge branch 'new-anim' of https://github.com/AxioDL/urde into new-anim

This commit is contained in:
Jack Andersen 2016-04-07 17:38:30 -10:00
commit 84541e1ed7
6 changed files with 50 additions and 7 deletions

View File

@ -1,6 +1,8 @@
#include "zeus/Math.hpp" #include "zeus/Math.hpp"
#include "ANIM.hpp" #include "ANIM.hpp"
#define DUMP_KEYS 0
namespace DataSpec namespace DataSpec
{ {
namespace DNAANIM namespace DNAANIM
@ -181,12 +183,24 @@ BitstreamReader::read(const atUint8* data,
default: break; default: break;
} }
} }
for (size_t f=0 ; f<keyFrameCount ; ++f) for (size_t f=0 ; f<keyFrameCount ; ++f)
{ {
#if DUMP_KEYS
fprintf(stderr, "\nFRAME %" PRISize " %u %u\n", f, (m_bitCur / 32) * 4, m_bitCur % 32);
int lastId = -1;
#endif
auto kit = chanKeys.begin(); auto kit = chanKeys.begin();
auto ait = chanAccum.begin(); auto ait = chanAccum.begin();
for (const Channel& chan : channels) for (const Channel& chan : channels)
{ {
#if DUMP_KEYS
if (chan.id != lastId)
{
lastId = chan.id;
fprintf(stderr, "\n");
}
#endif
QuantizedValue& p = *ait; QuantizedValue& p = *ait;
switch (chan.type) switch (chan.type)
{ {
@ -198,6 +212,9 @@ BitstreamReader::read(const atUint8* data,
p[2] += dequantize(data, chan.q[2]); p[2] += dequantize(data, chan.q[2]);
QuantizedRot qr = {{p[0], p[1], p[2]}, wBit}; QuantizedRot qr = {{p[0], p[1], p[2]}, wBit};
kit->emplace_back(DequantizeRotation(qr, rotDiv)); kit->emplace_back(DequantizeRotation(qr, rotDiv));
#if DUMP_KEYS
fprintf(stderr, "%d R: %d %d %d %d\t", chan.id, wBit, p[0], p[1], p[2]);
#endif
break; break;
} }
case Channel::Type::Translation: case Channel::Type::Translation:
@ -209,6 +226,9 @@ BitstreamReader::read(const atUint8* data,
atInt16 val3 = dequantize(data, chan.q[2]); atInt16 val3 = dequantize(data, chan.q[2]);
p[2] += val3; p[2] += val3;
kit->push_back({p[0] * transMult, p[1] * transMult, p[2] * transMult}); kit->push_back({p[0] * transMult, p[1] * transMult, p[2] * transMult});
#if DUMP_KEYS
fprintf(stderr, "%d T: %d %d %d\t", chan.id, p[0], p[1], p[2]);
#endif
break; break;
} }
case Channel::Type::Scale: case Channel::Type::Scale:
@ -217,6 +237,9 @@ BitstreamReader::read(const atUint8* data,
p[1] += dequantize(data, chan.q[1]); p[1] += dequantize(data, chan.q[1]);
p[2] += dequantize(data, chan.q[2]); p[2] += dequantize(data, chan.q[2]);
kit->push_back({p[0] / float(rotDiv), p[1] / float(rotDiv), p[2] / float(rotDiv)}); kit->push_back({p[0] / float(rotDiv), p[1] / float(rotDiv), p[2] / float(rotDiv)});
#if DUMP_KEYS
fprintf(stderr, "%d S: %d %d %d\t", chan.id, p[0], p[1], p[2]);
#endif
break; break;
} }
case Channel::Type::KfHead: case Channel::Type::KfHead:
@ -243,7 +266,11 @@ BitstreamReader::read(const atUint8* data,
++kit; ++kit;
++ait; ++ait;
} }
#if DUMP_KEYS
fprintf(stderr, "\n");
#endif
} }
return chanKeys; return chanKeys;
} }

View File

@ -52,6 +52,7 @@ struct Channel
KfHead, KfHead,
RotationMP3 RotationMP3
} type; } type;
atInt32 id = -1;
QuantizedValue i = {}; QuantizedValue i = {};
atUint8 q[4] = {}; atUint8 q[4] = {};
}; };

View File

@ -310,6 +310,7 @@ void ANIM::ANIM2::read(athena::io::IStreamReader& reader)
channels.emplace_back(); channels.emplace_back();
DNAANIM::Channel& chan = channels.back(); DNAANIM::Channel& chan = channels.back();
chan.type = DNAANIM::Channel::Type::Rotation; chan.type = DNAANIM::Channel::Type::Rotation;
chan.id = desc.id;
chan.i[0] = desc.initRX; chan.i[0] = desc.initRX;
chan.q[0] = desc.qRX; chan.q[0] = desc.qRX;
chan.i[1] = desc.initRY; chan.i[1] = desc.initRY;
@ -324,6 +325,7 @@ void ANIM::ANIM2::read(athena::io::IStreamReader& reader)
channels.emplace_back(); channels.emplace_back();
DNAANIM::Channel& chan = channels.back(); DNAANIM::Channel& chan = channels.back();
chan.type = DNAANIM::Channel::Type::Translation; chan.type = DNAANIM::Channel::Type::Translation;
chan.id = desc.id;
chan.i[0] = desc.initTX; chan.i[0] = desc.initTX;
chan.q[0] = desc.qTX; chan.q[0] = desc.qTX;
chan.i[1] = desc.initTY; chan.i[1] = desc.initTY;

View File

@ -258,8 +258,21 @@ struct SpecMP1 : SpecBase
hecl::ClientProcess process; hecl::ClientProcess process;
int compIdx = 4; int compIdx = 4;
prog = 0; prog = 0;
for (std::pair<std::string, DNAMP1::PAKBridge*> pair : m_orderedPaks) for (std::pair<const std::string, DNAMP1::PAKBridge*>& pair : m_orderedPaks)
{ {
#if 0
const DNAMP1::PAK::Entry* ent = pair.second->getPAK().lookupEntry(UniqueID32("AF974083"));
if (ent)
{
DNAMP1::ANIM anim;
PAKEntryReadStream rs = ent->beginReadStream(pair.second->getNode());
anim.read(rs);
exit(0);
}
else
continue;
#endif
DNAMP1::PAKBridge& pak = *pair.second; DNAMP1::PAKBridge& pak = *pair.second;
if (!pak.m_doExtract) if (!pak.m_doExtract)
continue; continue;

View File

@ -240,7 +240,7 @@ struct SpecMP2 : SpecBase
hecl::ClientProcess process; hecl::ClientProcess process;
int compIdx = 4; int compIdx = 4;
prog = 0; prog = 0;
for (std::pair<std::string, DNAMP2::PAKBridge*> pair : m_orderedPaks) for (std::pair<const std::string, DNAMP2::PAKBridge*>& pair : m_orderedPaks)
{ {
DNAMP2::PAKBridge& pak = *pair.second; DNAMP2::PAKBridge& pak = *pair.second;
if (!pak.m_doExtract) if (!pak.m_doExtract)

View File

@ -371,7 +371,7 @@ struct SpecMP3 : SpecBase
std::mutex msgLock; std::mutex msgLock;
hecl::ClientProcess process; hecl::ClientProcess process;
prog = 0; prog = 0;
for (std::pair<std::string, DNAMP3::PAKBridge*> pair : m_orderedPaks) for (std::pair<const std::string, DNAMP3::PAKBridge*>& pair : m_orderedPaks)
{ {
DNAMP3::PAKBridge& pak = *pair.second; DNAMP3::PAKBridge& pak = *pair.second;
if (!pak.m_doExtract) if (!pak.m_doExtract)