mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Revert "Allow NIF rotation matrices that include scale values"
This reverts commit f57ddec6a2
.
Conflicts:
components/nif/nifstream.hpp
(Fixes #2168)
This commit is contained in:
parent
3519d23518
commit
e6c59f5585
6 changed files with 13 additions and 23 deletions
|
@ -272,7 +272,7 @@ class NiSkinData : public Record
|
||||||
public:
|
public:
|
||||||
struct BoneTrafo
|
struct BoneTrafo
|
||||||
{
|
{
|
||||||
Ogre::Matrix3 rotationScale; // Rotation offset from bone, non-uniform scale
|
Ogre::Matrix3 rotation; // Rotation offset from bone?
|
||||||
Ogre::Vector3 trans; // Translation
|
Ogre::Vector3 trans; // Translation
|
||||||
float scale; // Probably scale (always 1)
|
float scale; // Probably scale (always 1)
|
||||||
};
|
};
|
||||||
|
@ -295,7 +295,7 @@ public:
|
||||||
|
|
||||||
void read(NIFStream *nif)
|
void read(NIFStream *nif)
|
||||||
{
|
{
|
||||||
trafo.rotationScale = nif->getMatrix3();
|
trafo.rotation = nif->getMatrix3();
|
||||||
trafo.trans = nif->getVector3();
|
trafo.trans = nif->getVector3();
|
||||||
trafo.scale = nif->getFloat();
|
trafo.scale = nif->getFloat();
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ public:
|
||||||
{
|
{
|
||||||
BoneInfo &bi = bones[i];
|
BoneInfo &bi = bones[i];
|
||||||
|
|
||||||
bi.trafo.rotationScale = nif->getMatrix3();
|
bi.trafo.rotation = nif->getMatrix3();
|
||||||
bi.trafo.trans = nif->getVector3();
|
bi.trafo.trans = nif->getVector3();
|
||||||
bi.trafo.scale = nif->getFloat();
|
bi.trafo.scale = nif->getFloat();
|
||||||
bi.unknown = nif->getVector4();
|
bi.unknown = nif->getVector4();
|
||||||
|
|
|
@ -76,7 +76,7 @@ Transformation NIFStream::getTrafo()
|
||||||
{
|
{
|
||||||
Transformation t;
|
Transformation t;
|
||||||
t.pos = getVector3();
|
t.pos = getVector3();
|
||||||
t.rotationScale = getMatrix3();
|
t.rotation = getMatrix3();
|
||||||
t.scale = getFloat();
|
t.scale = getFloat();
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Nif
|
||||||
struct Transformation
|
struct Transformation
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos;
|
Ogre::Vector3 pos;
|
||||||
Ogre::Matrix3 rotationScale;
|
Ogre::Matrix3 rotation;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
static const Transformation& getIdentity()
|
static const Transformation& getIdentity()
|
||||||
|
|
|
@ -42,9 +42,8 @@ void Node::getProperties(const Nif::NiTexturingProperty *&texprop,
|
||||||
|
|
||||||
Ogre::Matrix4 Node::getLocalTransform() const
|
Ogre::Matrix4 Node::getLocalTransform() const
|
||||||
{
|
{
|
||||||
Ogre::Matrix4 mat4 = Ogre::Matrix4(trafo.rotationScale);
|
Ogre::Matrix4 mat4 = Ogre::Matrix4(Ogre::Matrix4::IDENTITY);
|
||||||
mat4.setTrans(trafo.pos);
|
mat4.makeTransform(trafo.pos, Ogre::Vector3(trafo.scale), Ogre::Quaternion(trafo.rotation));
|
||||||
mat4.setScale(Ogre::Vector3(trafo.rotationScale[0][0], trafo.rotationScale[1][1], trafo.rotationScale[2][2]) * trafo.scale);
|
|
||||||
return mat4;
|
return mat4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,10 +138,9 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape
|
||||||
const Nif::NodeList &bones = skin->bones;
|
const Nif::NodeList &bones = skin->bones;
|
||||||
for(size_t b = 0;b < bones.length();b++)
|
for(size_t b = 0;b < bones.length();b++)
|
||||||
{
|
{
|
||||||
const Ogre::Matrix3& rotationScale = data->bones[b].trafo.rotationScale;
|
Ogre::Matrix4 mat;
|
||||||
Ogre::Matrix4 mat (rotationScale);
|
mat.makeTransform(data->bones[b].trafo.trans, Ogre::Vector3(data->bones[b].trafo.scale),
|
||||||
mat.setTrans(data->bones[b].trafo.trans);
|
Ogre::Quaternion(data->bones[b].trafo.rotation));
|
||||||
mat.setScale(Ogre::Vector3(rotationScale[0][0], rotationScale[1][1], rotationScale[2][2]) * data->bones[b].trafo.scale);
|
|
||||||
mat = bones[b]->getWorldTransform() * mat;
|
mat = bones[b]->getWorldTransform() * mat;
|
||||||
|
|
||||||
const std::vector<Nif::NiSkinData::VertWeight> &weights = data->bones[b].weights;
|
const std::vector<Nif::NiSkinData::VertWeight> &weights = data->bones[b].weights;
|
||||||
|
|
|
@ -36,17 +36,9 @@ void NIFSkeletonLoader::buildBones(Ogre::Skeleton *skel, const Nif::Node *node,
|
||||||
if(parent) parent->addChild(bone);
|
if(parent) parent->addChild(bone);
|
||||||
mNifToOgreHandleMap[node->recIndex] = bone->getHandle();
|
mNifToOgreHandleMap[node->recIndex] = bone->getHandle();
|
||||||
|
|
||||||
// decompose the local transform into position, scale and orientation.
|
bone->setOrientation(node->trafo.rotation);
|
||||||
// this is required for cases where the rotationScale matrix includes scaling, which the NIF format allows :(
|
bone->setPosition(node->trafo.pos);
|
||||||
// the code would look a bit nicer if Ogre allowed setting the transform matrix of a Bone directly, but we can't do that.
|
bone->setScale(Ogre::Vector3(node->trafo.scale));
|
||||||
Ogre::Matrix4 mat(node->getLocalTransform());
|
|
||||||
Ogre::Vector3 position, scale;
|
|
||||||
Ogre::Quaternion orientation;
|
|
||||||
mat.decomposition(position, scale, orientation);
|
|
||||||
bone->setOrientation(orientation);
|
|
||||||
bone->setPosition(position);
|
|
||||||
bone->setScale(scale);
|
|
||||||
|
|
||||||
bone->setBindingPose();
|
bone->setBindingPose();
|
||||||
|
|
||||||
if(!(node->recType == Nif::RC_NiNode || /* Nothing special; children traversed below */
|
if(!(node->recType == Nif::RC_NiNode || /* Nothing special; children traversed below */
|
||||||
|
|
Loading…
Reference in a new issue