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 "ANIM.hpp"
#define DUMP_KEYS 0
namespace DataSpec
{
namespace DNAANIM
@ -181,12 +183,24 @@ BitstreamReader::read(const atUint8* data,
default: break;
}
}
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 ait = chanAccum.begin();
for (const Channel& chan : channels)
{
#if DUMP_KEYS
if (chan.id != lastId)
{
lastId = chan.id;
fprintf(stderr, "\n");
}
#endif
QuantizedValue& p = *ait;
switch (chan.type)
{
@ -198,6 +212,9 @@ BitstreamReader::read(const atUint8* data,
p[2] += dequantize(data, chan.q[2]);
QuantizedRot qr = {{p[0], p[1], p[2]}, wBit};
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;
}
case Channel::Type::Translation:
@ -209,6 +226,9 @@ BitstreamReader::read(const atUint8* data,
atInt16 val3 = dequantize(data, chan.q[2]);
p[2] += val3;
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;
}
case Channel::Type::Scale:
@ -217,6 +237,9 @@ BitstreamReader::read(const atUint8* data,
p[1] += dequantize(data, chan.q[1]);
p[2] += dequantize(data, chan.q[2]);
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;
}
case Channel::Type::KfHead:
@ -243,7 +266,11 @@ BitstreamReader::read(const atUint8* data,
++kit;
++ait;
}
#if DUMP_KEYS
fprintf(stderr, "\n");
#endif
}
return chanKeys;
}

View File

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

View File

@ -52,22 +52,22 @@ void ANIM::IANIM::sendANIMToBlender(hecl::BlenderConnection::PyOutStream& os, co
if (bone.first == 3)
printf("");
ANIMOutStream ao = os.beginANIMCurve();
{
const std::vector<DNAANIM::Value>& rotKeys = *kit++;
fixedRotKeys.clear();
fixedRotKeys.resize(rotKeys.size());
for (int c=0 ; c<4 ; ++c)
{
size_t idx = 0;
for (const DNAANIM::Value& val : rotKeys)
fixedRotKeys.at(idx++)[c] = val.v4.vec[c];
}
for (zeus::CQuaternion& rot : fixedRotKeys)
rot = rig.transformRotation(bone.first, rot);
for (int c=0 ; c<4 ; ++c)
{
auto frameit = frames.begin();
@ -310,6 +310,7 @@ void ANIM::ANIM2::read(athena::io::IStreamReader& reader)
channels.emplace_back();
DNAANIM::Channel& chan = channels.back();
chan.type = DNAANIM::Channel::Type::Rotation;
chan.id = desc.id;
chan.i[0] = desc.initRX;
chan.q[0] = desc.qRX;
chan.i[1] = desc.initRY;
@ -324,6 +325,7 @@ void ANIM::ANIM2::read(athena::io::IStreamReader& reader)
channels.emplace_back();
DNAANIM::Channel& chan = channels.back();
chan.type = DNAANIM::Channel::Type::Translation;
chan.id = desc.id;
chan.i[0] = desc.initTX;
chan.q[0] = desc.qTX;
chan.i[1] = desc.initTY;

View File

@ -258,8 +258,21 @@ struct SpecMP1 : SpecBase
hecl::ClientProcess process;
int compIdx = 4;
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;
if (!pak.m_doExtract)
continue;

View File

@ -240,7 +240,7 @@ struct SpecMP2 : SpecBase
hecl::ClientProcess process;
int compIdx = 4;
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;
if (!pak.m_doExtract)

View File

@ -371,7 +371,7 @@ struct SpecMP3 : SpecBase
std::mutex msgLock;
hecl::ClientProcess process;
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;
if (!pak.m_doExtract)