From 2f6ae4a915e1a26f75afd6993dd0b06ab40a211b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 3 Apr 2013 20:56:35 -0700 Subject: [PATCH] Read more particle information --- components/nif/controller.hpp | 79 ++++++++++++++++++++++++++++++++--- components/nif/data.hpp | 18 ++++---- components/nif/recordptr.hpp | 1 + 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/components/nif/controller.hpp b/components/nif/controller.hpp index 8331b93b7..2ff25a274 100644 --- a/components/nif/controller.hpp +++ b/components/nif/controller.hpp @@ -62,20 +62,87 @@ public: } }; -class NiBSPArrayController : public Controller +class NiParticleSystemController : public Controller { public: + float velocity; + float velocityRandom; + + float verticalDir; // 0=up, pi/2=horizontal, pi=down + float verticalAngle; + float horizontalDir; + float horizontalAngle; + + float size; + float startTime; + float stopTime; + + float emitRate; + float lifetime; + float lifetimeRandom; + + int emitFlags; // Bit 0: Emit Rate toggle bit (0 = auto adjust, 1 = use Emit Rate value) + Ogre::Vector3 offsetRandom; + + NodePtr emitter; + + int numParticles; + int activeCount; + //std::vector particles; /*numParticles*/ + + RecordPtr modifier; + void read(NIFStream *nif) { Controller::read(nif); - // At the moment, just skip it all - nif->skip(111); - int s = nif->getUShort(); - nif->skip(15 + s*40); + velocity = nif->getFloat(); + velocityRandom = nif->getFloat(); + verticalDir = nif->getFloat(); + verticalAngle = nif->getFloat(); + horizontalDir = nif->getFloat(); + horizontalAngle = nif->getFloat(); + /*normal?*/ nif->getVector3(); + /*color?*/ nif->getVector4(); + size = nif->getFloat(); + startTime = nif->getFloat(); + stopTime = nif->getFloat(); + nif->getChar(); + emitRate = nif->getFloat(); + lifetime = nif->getFloat(); + lifetimeRandom = nif->getFloat(); + + emitFlags = nif->getUShort(); + offsetRandom = nif->getVector3(); + + emitter.read(nif); + + /* Unknown Short, 0? + * Unknown Float, 1.0? + * Unknown Int, 1? + * Unknown Int, 0? + * Unknown Short, 0? + */ + nif->skip(16); + + numParticles = nif->getUShort(); + activeCount = nif->getUShort(); + nif->skip(numParticles*40); + + nif->getUInt(); /* -1? */ + modifier.read(nif); + nif->getUInt(); /* -1? */ + nif->getChar(); + } + + void post(NIFFile *nif) + { + Controller::post(nif); + emitter.post(nif); + modifier.post(nif); } }; -typedef NiBSPArrayController NiParticleSystemController; +typedef NiParticleSystemController NiBSPArrayController; class NiMaterialColorController : public Controller { diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 68ffd19b8..a2c9bb56d 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -165,9 +165,9 @@ public: class NiAutoNormalParticlesData : public ShapeData { public: - int activeCount; + float particleSize; - float activeRadius; + int activeCount; std::vector sizes; @@ -176,15 +176,15 @@ public: ShapeData::read(nif); // Should always match the number of vertices - activeCount = nif->getUShort(); + nif->getUShort(); - activeRadius = nif->getFloat(); - nif->getUShort(); // Number of valid entries in the following arrays ? + particleSize = nif->getFloat(); + activeCount = nif->getUShort(); if(nif->getInt()) { // Particle sizes - nif->getFloats(sizes, activeCount); + nif->getFloats(sizes, vertices.size()); } } }; @@ -200,10 +200,8 @@ public: if(nif->getInt()) { - // 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->getQuaternions(rotations, activeCount); + // Rotation quaternions. + nif->getQuaternions(rotations, vertices.size()); } } }; diff --git a/components/nif/recordptr.hpp b/components/nif/recordptr.hpp index c5bafea12..b7cd122bc 100644 --- a/components/nif/recordptr.hpp +++ b/components/nif/recordptr.hpp @@ -142,6 +142,7 @@ class NiSourceTexture; class NiRotatingParticlesData; class NiAutoNormalParticlesData; +typedef RecordPtrT RecordPtr; typedef RecordPtrT NodePtr; typedef RecordPtrT ExtraPtr; typedef RecordPtrT NiUVDataPtr;