diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp index 5b87efb162583a566ce27247e9b0f9489a28674c..504d275fc616ae644d0aa74e4f8bb95ab909a44d 100644 --- a/NIF_Blocks.cpp +++ b/NIF_Blocks.cpp @@ -1603,7 +1603,7 @@ void AParticlesData::Read( istream& file, unsigned int version ) { } //Size exists up to version 10.0.1.0 - if ( version <= VER_10_1_0_0 ) { + if ( version <= VER_10_0_1_0 ) { NifStream( size, file ); } @@ -1928,35 +1928,43 @@ string NiPSysData::asString() const { * ARotatingParticlesData methods **********************************************************/ -void ARotatingParticlesData::Read( istream& in, unsigned int version ) { - AParticlesData::Read( in, version ); +void ARotatingParticlesData::Read( istream& file, unsigned int version ) { + AParticlesData::Read( file, version ); + + //After version 10.1.0.0 there are several new entries + if ( version >= VER_10_1_0_0 ) { + NifStream( numActiveRot, file ); + + bool hasUnkFloats = ReadBool( file, version ); + + if ( hasUnkFloats ) { + unkFloats.resize( vertices.size() ); + NifStream( unkFloats, file ); + } + } - hasRotations = ReadBool( in, version ); + bool hasRotations = ReadBool( file, version ); if ( hasRotations ) { rotations.resize( vertices.size() ); - for ( uint i = 0; i < rotations.size(); ++i ) { - rotations[i].w = ReadFloat( in ); - rotations[i].x = ReadFloat( in ); - rotations[i].y = ReadFloat( in ); - rotations[i].z = ReadFloat( in ); - } + NifStream( rotations, file ); } } -void ARotatingParticlesData::Write( ostream& out, unsigned int version ) const { - AParticlesData::Write( out, version ); +void ARotatingParticlesData::Write( ostream& file, unsigned int version ) const { + AParticlesData::Write( file, version ); - WriteBool( hasRotations, out, version ); + //After version 10.1.0.0 there are several new entries + if ( version >= VER_10_1_0_0 ) { + NifStream( numActiveRot, file ); - if ( hasRotations ) { - for ( uint i = 0; i < rotations.size(); ++i ) { - WriteFloat( rotations[i].w, out ); - WriteFloat( rotations[i].x, out ); - WriteFloat( rotations[i].y, out ); - WriteFloat( rotations[i].z, out ); - } + WriteBool( (unkFloats.size() > 0), file, version ); + + NifStream( unkFloats, file ); } + + WriteBool( (rotations.size() > 0), file, version ); + NifStream( rotations, file ); } string ARotatingParticlesData::asString() const { @@ -1964,16 +1972,33 @@ string ARotatingParticlesData::asString() const { out.setf(ios::fixed, ios::floatfield); out << setprecision(1); - out << AParticlesData::asString() - << "Rotations: "; + out << AParticlesData::asString() << endl + << "Num Active Rot: " << numActiveRot << endl + << "Unknown Floats: "; - if ( hasRotations ) { + if ( unkFloats.size() > 0 ) { + if (verbose) { + out << endl; + for ( uint i = 0; i < unkFloats.size(); ++i) { + out << i << ": " << unkFloats[i] << endl; + } + } else { + out << endl << "<<Data Not Shown>>" << endl; + } + } else { + out << "None" << endl; + } + + out << "Rotations: "; + + if ( rotations.size() > 0 ) { if (verbose) { + out << endl; for ( uint i = 0; i < rotations.size(); ++i) { out << i << ": [" << rotations[i].w << " (" << rotations[i].x << ", " << rotations[i].y << ", " << rotations[1].z << ")]" << endl; } } else { - out << endl << "<<Data Not Shown>>"; + out << endl << "<<Data Not Shown>>" << endl; } } else { out << "None" << endl; diff --git a/NIF_Blocks.h b/NIF_Blocks.h index 69d3f4ec2711a321451bb3ca9f7c5f33d5e78d10..e1268c3a2183387a4568839f50270ccdae60a372 100644 --- a/NIF_Blocks.h +++ b/NIF_Blocks.h @@ -924,7 +924,8 @@ public: void Write( ostream& out, unsigned int version ) const; string asString() const; protected: - bool hasRotations; + ushort numActiveRot; + vector<float> unkFloats; vector<Quaternion> rotations; }; diff --git a/nif_attrs.h b/nif_attrs.h index 5fe51cea73b13be4a176c5ee5bc34968e5f90e5a..ef33e96968c742cc429c89adb605ea1f67c4b36e 100644 --- a/nif_attrs.h +++ b/nif_attrs.h @@ -761,17 +761,17 @@ public: //The only difference is that there is a boolean before this link group bool has_links = ReadBool( in, version ); - //if ( has_links) { + if ( has_links || version >= VER_10_2_0_0 ) { LinkGroupAttr::ReadAttr( in, version ); - //} + } } void WriteAttr( ostream& out, unsigned int version ) const { //The only difference is that there is a boolean before this link group WriteBool( (links.size() > 0), out, version ); - //if ( links.size() > 0 ) { + if ( links.size() > 0 || version >= VER_10_2_0_0) { LinkGroupAttr::WriteAttr( out, version ); - //} + } } };