From f6f37e02df0cb64817c8e59834b45c569fe5afb4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 20 Feb 2015 17:56:49 +0100 Subject: [PATCH] NIF Transformation redundancy fix and include fixes --- components/nif/data.hpp | 17 ++++++----------- components/nif/niftypes.hpp | 2 +- components/nif/node.hpp | 4 ++-- components/nif/property.hpp | 3 +++ 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index db5a5643d4..656d27628c 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -26,6 +26,8 @@ #include "base.hpp" +#include "niftypes.hpp" // Transformation + namespace Nif { @@ -270,13 +272,6 @@ public: class NiSkinData : public Record { public: - struct BoneTrafo - { - Matrix3 rotation; // Rotation offset from bone? - osg::Vec3f trans; // Translation - float scale; // Scale - }; - struct VertWeight { short vertex; @@ -285,18 +280,18 @@ public: struct BoneInfo { - BoneTrafo trafo; + Transformation trafo; osg::Vec4f unknown; std::vector weights; }; - BoneTrafo trafo; + Transformation trafo; std::vector bones; void read(NIFStream *nif) { trafo.rotation = nif->getMatrix3(); - trafo.trans = nif->getVector3(); + trafo.pos = nif->getVector3(); trafo.scale = nif->getFloat(); int boneNum = nif->getInt(); @@ -308,7 +303,7 @@ public: BoneInfo &bi = bones[i]; bi.trafo.rotation = nif->getMatrix3(); - bi.trafo.trans = nif->getVector3(); + bi.trafo.pos = nif->getVector3(); bi.trafo.scale = nif->getFloat(); bi.unknown = nif->getVector4(); diff --git a/components/nif/niftypes.hpp b/components/nif/niftypes.hpp index 864795afb5..4f6998200f 100644 --- a/components/nif/niftypes.hpp +++ b/components/nif/niftypes.hpp @@ -39,7 +39,7 @@ struct Matrix3 { for (int i=0;i<3;++i) for (int j=0;j<3;++j) - mValues[i][j] = 0; + mValues[i][j] = (i==j) ? 1.f : 0.f; } }; diff --git a/components/nif/node.hpp b/components/nif/node.hpp index 123b70cad9..7f94c0d05b 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -68,7 +68,7 @@ public: NiNode *parent; // Bone transformation. If set, node is a part of a skeleton. - const NiSkinData::BoneTrafo *boneTrafo; + const Transformation *boneTrafo; // Bone weight info, from NiSkinData const NiSkinData::BoneInfo *boneInfo; @@ -77,7 +77,7 @@ public: // boneTrafo is set it is the root bone in the skeleton. short boneIndex; - void makeRootBone(const NiSkinData::BoneTrafo *tr) + void makeRootBone(const Transformation *tr) { boneTrafo = tr; boneIndex = -1; diff --git a/components/nif/property.hpp b/components/nif/property.hpp index 52ee7f6e16..610f5427ab 100644 --- a/components/nif/property.hpp +++ b/components/nif/property.hpp @@ -26,6 +26,9 @@ #include "base.hpp" +#include "controlled.hpp" +#include "data.hpp" + namespace Nif {