mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Actually read in XYZ_ROTATION_KEY data instead of discarding it.
This commit is contained in:
parent
e772bb88da
commit
b90e4db871
2 changed files with 46 additions and 59 deletions
|
@ -413,12 +413,25 @@ struct NiMorphData : public Record
|
|||
struct NiKeyframeData : public Record
|
||||
{
|
||||
QuaternionKeyList mRotations;
|
||||
//\FIXME mXYZ_Keys are read, but not used.
|
||||
FloatKeyList mXYZ_Keys;
|
||||
Vector3KeyList mTranslations;
|
||||
FloatKeyList mScales;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
mRotations.read(nif);
|
||||
if(mRotations.mInterpolationType == mRotations.sXYZInterpolation)
|
||||
{
|
||||
//Chomp unused float
|
||||
nif->getFloat();
|
||||
for(size_t i=0;i<3;++i)
|
||||
{
|
||||
//Read concatenates items together.
|
||||
mXYZ_keys.read(nif,true);
|
||||
}
|
||||
nif->file->warn("XYZ_ROTATION_KEY read, but not used!");
|
||||
}
|
||||
mTranslations.read(nif);
|
||||
mScales.read(nif);
|
||||
}
|
||||
|
|
|
@ -158,58 +158,59 @@ struct KeyListT {
|
|||
static const int sTBCInterpolation = 3;
|
||||
static const int sXYZInterpolation = 4;
|
||||
|
||||
int mInterpolationType;
|
||||
unsigned int mInterpolationType;
|
||||
VecType mKeys;
|
||||
|
||||
void read(NIFStream *nif, bool force=false)
|
||||
{
|
||||
assert(nif);
|
||||
size_t count = nif->getInt();
|
||||
size_t count = nif->getUInt();
|
||||
if(count == 0 && !force)
|
||||
return;
|
||||
|
||||
mInterpolationType = nif->getInt();
|
||||
mKeys.resize(count);
|
||||
//If we aren't forcing things, make sure that read clears any previous keys
|
||||
if(!force)
|
||||
mKeys.clear();
|
||||
|
||||
mInterpolationType = nif->getUInt();
|
||||
|
||||
KeyT<T> key;
|
||||
NIFStream &nifReference = *nif;
|
||||
if(mInterpolationType == sLinearInterpolation)
|
||||
{
|
||||
for(size_t i = 0;i < count;i++)
|
||||
{
|
||||
readTimeAndValue(nifReference, mKeys[i]);
|
||||
}
|
||||
if(mInterpolationType == sLinearInterpolation)
|
||||
{
|
||||
readTimeAndValue(nifReference, key);
|
||||
mKeys.push_back(key);
|
||||
}
|
||||
else if(mInterpolationType == sQuadraticInterpolation)
|
||||
{
|
||||
for(size_t i = 0;i < count;i++)
|
||||
{
|
||||
readQuadratic(nifReference, mKeys[i]);
|
||||
}
|
||||
readQuadratic(nifReference, key);
|
||||
mKeys.push_back(key);
|
||||
}
|
||||
else if(mInterpolationType == sTBCInterpolation)
|
||||
{
|
||||
for(size_t i = 0;i < count;i++)
|
||||
{
|
||||
readTBC(nifReference, mKeys[i]);
|
||||
readTBC(nifReference, key);
|
||||
mKeys.push_back(key);
|
||||
}
|
||||
}
|
||||
//\FIXME This now reads the correct amount of data in the file, but doesn't actually do anything with it.
|
||||
else if(mInterpolationType == sXYZInterpolation)
|
||||
{
|
||||
if (count != 1)
|
||||
//Don't try to read XYZ keys into the wrong part
|
||||
if(force)
|
||||
{
|
||||
nif->file->fail("count should always be '1' for XYZ_ROTATION_KEY. Retrieved Value: "+Ogre::StringConverter::toString(count));
|
||||
return;
|
||||
readTimeAndValue(nifReference, key);
|
||||
mKeys.push_back(key);
|
||||
}
|
||||
readXYZ(nifReference);
|
||||
else if ( count != 1 )
|
||||
nif->file->fail("XYZ_ROTATION_KEY count should always be '1' . Retrieved Value: "+Ogre::StringConverter::toString(count));
|
||||
}
|
||||
else if (mInterpolationType == 0)
|
||||
{
|
||||
else if ((0 == mInterpolationType))
|
||||
if (count != 0)
|
||||
nif->file->fail("Interpolation type 0 doesn't work with keys");
|
||||
}
|
||||
else
|
||||
nif->file->fail("Unhandled interpolation type: "+Ogre::StringConverter::toString(mInterpolationType));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void readTimeAndValue(NIFStream &nif, KeyT<T> &key)
|
||||
|
@ -238,33 +239,6 @@ private:
|
|||
key.mBias = nif.getFloat();
|
||||
key.mContinuity = nif.getFloat();
|
||||
}
|
||||
|
||||
static void readXYZ(NIFStream &nif)
|
||||
{
|
||||
//KeyGroup (see http://niftools.sourceforge.net/doc/nif/NiKeyframeData.html)
|
||||
//Chomp unknown and possibly unused float
|
||||
nif.getFloat();
|
||||
for(size_t i=0;i<3;++i)
|
||||
{
|
||||
const unsigned int numKeys = nif.getInt();
|
||||
if(numKeys != 0)
|
||||
{
|
||||
const int interpolationTypeAgain = nif.getInt();
|
||||
if( interpolationTypeAgain != sLinearInterpolation)
|
||||
{
|
||||
nif.file->fail("XYZ_ROTATION_KEY's KeyGroup keyType must be '1' (Linear Interpolation). Retrieved Value: "+Ogre::StringConverter::toString(interpolationTypeAgain));
|
||||
return;
|
||||
}
|
||||
for(size_t j = 0;j < numKeys;++j)
|
||||
{
|
||||
//For now just chomp these
|
||||
nif.getFloat();
|
||||
nif.getFloat();
|
||||
}
|
||||
}
|
||||
nif.file->warn("XYZ_ROTATION_KEY read, but not used!");
|
||||
}
|
||||
}
|
||||
};
|
||||
typedef KeyListT<float,&NIFStream::getFloat> FloatKeyList;
|
||||
typedef KeyListT<Ogre::Vector3,&NIFStream::getVector3> Vector3KeyList;
|
||||
|
|
Loading…
Reference in a new issue