mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-11 15:40:39 +00:00
Merge branch 'nif' into 'master'
NIF stuff See merge request OpenMW/openmw!1674
This commit is contained in:
commit
dbab48d7da
@ -439,9 +439,8 @@ void NiKeyframeData::read(NIFStream *nif)
|
|||||||
mRotations->read(nif);
|
mRotations->read(nif);
|
||||||
if(mRotations->mInterpolationType == InterpolationType_XYZ)
|
if(mRotations->mInterpolationType == InterpolationType_XYZ)
|
||||||
{
|
{
|
||||||
//Chomp unused float
|
|
||||||
if (nif->getVersion() <= NIFStream::generateVersion(10,1,0,0))
|
if (nif->getVersion() <= NIFStream::generateVersion(10,1,0,0))
|
||||||
nif->getFloat();
|
mAxisOrder = static_cast<AxisOrder>(nif->getInt());
|
||||||
mXRotations = std::make_shared<FloatKeyMap>();
|
mXRotations = std::make_shared<FloatKeyMap>();
|
||||||
mYRotations = std::make_shared<FloatKeyMap>();
|
mYRotations = std::make_shared<FloatKeyMap>();
|
||||||
mZRotations = std::make_shared<FloatKeyMap>();
|
mZRotations = std::make_shared<FloatKeyMap>();
|
||||||
|
@ -240,6 +240,21 @@ struct NiKeyframeData : public Record
|
|||||||
Vector3KeyMapPtr mTranslations;
|
Vector3KeyMapPtr mTranslations;
|
||||||
FloatKeyMapPtr mScales;
|
FloatKeyMapPtr mScales;
|
||||||
|
|
||||||
|
enum class AxisOrder
|
||||||
|
{
|
||||||
|
Order_XYZ = 0,
|
||||||
|
Order_XZY = 1,
|
||||||
|
Order_YZX = 2,
|
||||||
|
Order_YXZ = 3,
|
||||||
|
Order_ZXY = 4,
|
||||||
|
Order_ZYX = 5,
|
||||||
|
Order_XYX = 6,
|
||||||
|
Order_YZY = 7,
|
||||||
|
Order_ZXZ = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
AxisOrder mAxisOrder{AxisOrder::Order_XYZ};
|
||||||
|
|
||||||
void read(NIFStream *nif) override;
|
void read(NIFStream *nif) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,9 +225,10 @@ struct NiNode : Node
|
|||||||
// Discard transformations for the root node, otherwise some meshes
|
// Discard transformations for the root node, otherwise some meshes
|
||||||
// occasionally get wrong orientation. Only for NiNode-s for now, but
|
// occasionally get wrong orientation. Only for NiNode-s for now, but
|
||||||
// can be expanded if needed.
|
// can be expanded if needed.
|
||||||
|
// FIXME: if node 0 is *not* the only root node, this must not happen.
|
||||||
if (0 == recIndex && !Misc::StringUtils::ciEqual(name, "bip01"))
|
if (0 == recIndex && !Misc::StringUtils::ciEqual(name, "bip01"))
|
||||||
{
|
{
|
||||||
static_cast<Nif::Node*>(this)->trafo = Nif::Transformation::getIdentity();
|
trafo = Nif::Transformation::getIdentity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ KeyframeController::KeyframeController(const KeyframeController ©, const osg
|
|||||||
, mZRotations(copy.mZRotations)
|
, mZRotations(copy.mZRotations)
|
||||||
, mTranslations(copy.mTranslations)
|
, mTranslations(copy.mTranslations)
|
||||||
, mScales(copy.mScales)
|
, mScales(copy.mScales)
|
||||||
|
, mAxisOrder(copy.mAxisOrder)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +96,7 @@ KeyframeController::KeyframeController(const Nif::NiKeyframeController *keyctrl)
|
|||||||
mZRotations = FloatInterpolator(interp->data->mZRotations);
|
mZRotations = FloatInterpolator(interp->data->mZRotations);
|
||||||
mTranslations = Vec3Interpolator(interp->data->mTranslations, interp->defaultPos);
|
mTranslations = Vec3Interpolator(interp->data->mTranslations, interp->defaultPos);
|
||||||
mScales = FloatInterpolator(interp->data->mScales, interp->defaultScale);
|
mScales = FloatInterpolator(interp->data->mScales, interp->defaultScale);
|
||||||
|
mAxisOrder = interp->data->mAxisOrder;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -112,6 +114,7 @@ KeyframeController::KeyframeController(const Nif::NiKeyframeController *keyctrl)
|
|||||||
mZRotations = FloatInterpolator(keydata->mZRotations);
|
mZRotations = FloatInterpolator(keydata->mZRotations);
|
||||||
mTranslations = Vec3Interpolator(keydata->mTranslations);
|
mTranslations = Vec3Interpolator(keydata->mTranslations);
|
||||||
mScales = FloatInterpolator(keydata->mScales, 1.f);
|
mScales = FloatInterpolator(keydata->mScales, 1.f);
|
||||||
|
mAxisOrder = keydata->mAxisOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,10 +127,31 @@ osg::Quat KeyframeController::getXYZRotation(float time) const
|
|||||||
yrot = mYRotations.interpKey(time);
|
yrot = mYRotations.interpKey(time);
|
||||||
if (!mZRotations.empty())
|
if (!mZRotations.empty())
|
||||||
zrot = mZRotations.interpKey(time);
|
zrot = mZRotations.interpKey(time);
|
||||||
osg::Quat xr(xrot, osg::Vec3f(1,0,0));
|
osg::Quat xr(xrot, osg::X_AXIS);
|
||||||
osg::Quat yr(yrot, osg::Vec3f(0,1,0));
|
osg::Quat yr(yrot, osg::Y_AXIS);
|
||||||
osg::Quat zr(zrot, osg::Vec3f(0,0,1));
|
osg::Quat zr(zrot, osg::Z_AXIS);
|
||||||
return (xr*yr*zr);
|
switch (mAxisOrder)
|
||||||
|
{
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_XYZ:
|
||||||
|
return xr * yr * zr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_XZY:
|
||||||
|
return xr * zr * yr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_YZX:
|
||||||
|
return yr * zr * xr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_YXZ:
|
||||||
|
return yr * xr * zr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_ZXY:
|
||||||
|
return zr * xr * yr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_ZYX:
|
||||||
|
return zr * yr * xr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_XYX:
|
||||||
|
return xr * yr * xr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_YZY:
|
||||||
|
return yr * zr * yr;
|
||||||
|
case Nif::NiKeyframeData::AxisOrder::Order_ZXZ:
|
||||||
|
return zr * xr * zr;
|
||||||
|
}
|
||||||
|
return xr * yr * zr;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec3f KeyframeController::getTranslation(float time) const
|
osg::Vec3f KeyframeController::getTranslation(float time) const
|
||||||
|
@ -255,6 +255,8 @@ namespace NifOsg
|
|||||||
Vec3Interpolator mTranslations;
|
Vec3Interpolator mTranslations;
|
||||||
FloatInterpolator mScales;
|
FloatInterpolator mScales;
|
||||||
|
|
||||||
|
Nif::NiKeyframeData::AxisOrder mAxisOrder{Nif::NiKeyframeData::AxisOrder::Order_XYZ};
|
||||||
|
|
||||||
osg::Quat getXYZRotation(float time) const;
|
osg::Quat getXYZRotation(float time) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user