From ee0a20f9ce30cd885a3110df97b6e911095d5d7f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 3 Apr 2013 07:00:24 -0700 Subject: [PATCH] Read some missing particle data from NIFs --- components/nif/data.hpp | 13 +++++++++---- components/nif/nifstream.hpp | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 9bdba6396..68ffd19b8 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -167,6 +167,10 @@ class NiAutoNormalParticlesData : public ShapeData public: int activeCount; + float activeRadius; + + std::vector sizes; + void read(NIFStream *nif) { ShapeData::read(nif); @@ -174,14 +178,13 @@ public: // Should always match the number of vertices activeCount = nif->getUShort(); - // Skip all the info, we don't support particles yet - nif->getFloat(); // Active radius ? + activeRadius = nif->getFloat(); nif->getUShort(); // Number of valid entries in the following arrays ? if(nif->getInt()) { // Particle sizes - nif->skip(activeCount * sizeof(float)); + nif->getFloats(sizes, activeCount); } } }; @@ -189,6 +192,8 @@ public: class NiRotatingParticlesData : public NiAutoNormalParticlesData { public: + std::vector rotations; + void read(NIFStream *nif) { NiAutoNormalParticlesData::read(nif); @@ -198,7 +203,7 @@ public: // Rotation quaternions. I THINK activeCount is correct here, // but verts (vertex number) might also be correct, if there is // any case where the two don't match. - nif->skip(activeCount * 4*sizeof(float)); + nif->getQuaternions(rotations, activeCount); } } }; diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index 02b931b7e..a2595d17b 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -168,6 +168,12 @@ public: for(size_t i = 0;i < vec.size();i++) vec[i] = getVector4(); } + void getQuaternions(std::vector &quat, size_t size) + { + quat.resize(size); + for(size_t i = 0;i < quat.size();i++) + quat[i] = getQuaternion(); + } }; }