Actually read in XYZ_ROTATION_KEY data instead of discarding it.

deque
Arthur Moore 11 years ago
parent e772bb88da
commit b90e4db871

@ -413,12 +413,25 @@ struct NiMorphData : public Record
struct NiKeyframeData : public Record struct NiKeyframeData : public Record
{ {
QuaternionKeyList mRotations; QuaternionKeyList mRotations;
//\FIXME mXYZ_Keys are read, but not used.
FloatKeyList mXYZ_Keys;
Vector3KeyList mTranslations; Vector3KeyList mTranslations;
FloatKeyList mScales; FloatKeyList mScales;
void read(NIFStream *nif) void read(NIFStream *nif)
{ {
mRotations.read(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); mTranslations.read(nif);
mScales.read(nif); mScales.read(nif);
} }

@ -158,57 +158,58 @@ struct KeyListT {
static const int sTBCInterpolation = 3; static const int sTBCInterpolation = 3;
static const int sXYZInterpolation = 4; static const int sXYZInterpolation = 4;
int mInterpolationType; unsigned int mInterpolationType;
VecType mKeys; VecType mKeys;
void read(NIFStream *nif, bool force=false) void read(NIFStream *nif, bool force=false)
{ {
assert(nif); assert(nif);
size_t count = nif->getInt(); size_t count = nif->getUInt();
if(count == 0 && !force) if(count == 0 && !force)
return; return;
mInterpolationType = nif->getInt(); //If we aren't forcing things, make sure that read clears any previous keys
mKeys.resize(count); if(!force)
mKeys.clear();
mInterpolationType = nif->getUInt();
KeyT<T> key;
NIFStream &nifReference = *nif; NIFStream &nifReference = *nif;
if(mInterpolationType == sLinearInterpolation) for(size_t i = 0;i < count;i++)
{ {
for(size_t i = 0;i < count;i++) if(mInterpolationType == sLinearInterpolation)
{ {
readTimeAndValue(nifReference, mKeys[i]); readTimeAndValue(nifReference, key);
mKeys.push_back(key);
} }
} else if(mInterpolationType == sQuadraticInterpolation)
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)
else if(mInterpolationType == sTBCInterpolation)
{
for(size_t i = 0;i < count;i++)
{ {
readTBC(nifReference, mKeys[i]); readTBC(nifReference, key);
mKeys.push_back(key);
} }
} else if(mInterpolationType == sXYZInterpolation)
//\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)
{ {
nif->file->fail("count should always be '1' for XYZ_ROTATION_KEY. Retrieved Value: "+Ogre::StringConverter::toString(count)); //Don't try to read XYZ keys into the wrong part
return; if(force)
{
readTimeAndValue(nifReference, key);
mKeys.push_back(key);
}
else if ( count != 1 )
nif->file->fail("XYZ_ROTATION_KEY count should always be '1' . Retrieved Value: "+Ogre::StringConverter::toString(count));
} }
readXYZ(nifReference); else if ((0 == mInterpolationType))
} if (count != 0)
else if (mInterpolationType == 0) nif->file->fail("Interpolation type 0 doesn't work with keys");
{ else
if (count != 0) nif->file->fail("Unhandled interpolation type: "+Ogre::StringConverter::toString(mInterpolationType));
nif->file->fail("Interpolation type 0 doesn't work with keys");
} }
else
nif->file->fail("Unhandled interpolation type: "+Ogre::StringConverter::toString(mInterpolationType));
} }
private: private:
@ -238,33 +239,6 @@ private:
key.mBias = nif.getFloat(); key.mBias = nif.getFloat();
key.mContinuity = 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<float,&NIFStream::getFloat> FloatKeyList;
typedef KeyListT<Ogre::Vector3,&NIFStream::getVector3> Vector3KeyList; typedef KeyListT<Ogre::Vector3,&NIFStream::getVector3> Vector3KeyList;

Loading…
Cancel
Save