diff --git a/NIF_IO.cpp b/NIF_IO.cpp index 1ec9fcbe936e018f8332946b20e48dc01c5f668c..8657f21bbb034de28950554aa92f4728cdc9d55a 100644 --- a/NIF_IO.cpp +++ b/NIF_IO.cpp @@ -439,14 +439,16 @@ void NifStream( TexDesc & val, istream& in, uint version ) { //From version 10.1.0.0 and up, this unknown val block may exist if ( version >= VER_10_1_0_0 ) { - val.hasUnknownData = ReadBool( in, version ); - if ( val.hasUnknownData == true ) { - for (int i = 0; i < 5; ++i ) { - val.unknown5Floats[i] = ReadFloat( in );; - } - val.unknownInt = ReadUInt( in ); - val.unknownFloat1 = ReadFloat( in ); - val.unknownFloat2 = ReadFloat( in ); + val.hasTextureTransform = ReadBool( in, version ); + if ( val.hasTextureTransform == true ) { + val.translation.u = ReadFloat( in ); + val.translation.v = ReadFloat( in ); + val.tiling.u = ReadFloat( in ); + val.tiling.v = ReadFloat( in ); + val.w_rotation = ReadFloat( in ); + val.transform_type = ReadUInt( in ); + val.center_offset.u = ReadFloat( in ); + val.center_offset.v = ReadFloat( in ); } } } @@ -510,14 +512,16 @@ void NifStream( TexDesc const & val, ostream& out, uint version ) { //From version 10.1.0.0 and up, this unknown val block may exist if ( version >= VER_10_1_0_0 ) { - WriteBool( val.hasUnknownData, out, version ); - if ( val.hasUnknownData == true ) { - for (int i = 0; i < 5; ++i ) { - WriteFloat( val.unknown5Floats[i], out );; - } - WriteUInt( val.unknownInt, out ); - WriteFloat( val.unknownFloat1, out ); - WriteFloat( val.unknownFloat2, out ); + WriteBool( val.hasTextureTransform, out, version ); + if ( val.hasTextureTransform == true ) { + WriteFloat( val.translation.u, out ); + WriteFloat( val.translation.v, out ); + WriteFloat( val.tiling.u, out ); + WriteFloat( val.tiling.v, out ); + WriteFloat( val.w_rotation, out ); + WriteUInt( val.transform_type, out ); + WriteFloat( val.center_offset.u, out ); + WriteFloat( val.center_offset.v, out ); } } } diff --git a/niflib.cpp b/niflib.cpp index a92a8e1741ab938d3ba23e5ee67d5972e4db724d..d7197da42a1266fb42a9a8e62f35ad03886de9b9 100644 --- a/niflib.cpp +++ b/niflib.cpp @@ -936,19 +936,17 @@ string TexDesc::asString() const { << " PS2 L Setting: " << PS2_L << endl << " PS2 K Setting: " << PS2_K << endl << " Unknown Short: " << unknownShort << endl - << " Unknown Data: "; + << " Texture Transform: "; //From version 10.1.0.0 and up, this unknown data block may exist - if ( hasUnknownData == true ) { + if ( hasTextureTransform == true ) { out << endl - << " Unknown 5 Floats:" << endl; - for (int i = 0; i < 5; ++i ) { - out << " " << i + 1 << ": " << unknown5Floats[i] << endl; - } - out << " Unknown Int: " << unknownInt << endl - << " Unknown Float 1: " << unknownFloat1 << endl - << " Unknown Float 2: " << unknownFloat2 << endl; + << " Translation: " << translation.u << ", " << translation.v << endl + << " Tiling: " << tiling.u << ", " << tiling.v << endl + << " W-rotation: " << w_rotation << endl + << " Transform Type: " << transform_type << endl + << " Center Offset: " << center_offset.u << ", " << center_offset.v << endl; } else { out << "None" << endl; } diff --git a/niflib.h b/niflib.h index 907f8c5a6a81f21ee0d6ef602e1145a330c8a3de..bd3aab0bf5433c4b97a31d9acc62072bb38627ea 100644 --- a/niflib.h +++ b/niflib.h @@ -3358,7 +3358,10 @@ protected: /*! Represents a texture description that specifies various properties of the texture that it refers to. The NiTextureSource block that this description refers to can be retrieved by calling asLink on the same attribute. */ struct TexDesc { /*! Default constructor. Sets isUsed to false, clampMode to WRAP_S_WRAP_T, filterMode to FILTER_TRILERP, testureSet to 0, PS2_L to zero, PS2_K to 0xFFB5, and unknownShort to 0x0101.*/ - TexDesc() : isUsed(false), clampMode(WRAP_S_WRAP_T), filterMode(FILTER_TRILERP), textureSet(0), PS2_L(0), PS2_K(0xFFB5), unknownShort(0x0101) {} + TexDesc() : isUsed(false), clampMode(WRAP_S_WRAP_T), filterMode(FILTER_TRILERP), textureSet(0), + PS2_L(0), PS2_K(0xFFB5), unknownShort(0x0101), + hasTextureTransform(false), translation(0.0, 0.0), tiling(0.0, 0.0), + w_rotation(0.0), transform_type(0), center_offset(0.0, 0.0) {} string asString() const; bool isUsed; /*!< Determines whether this texture description is used or not. If this value is true, the other members of this structure are significant. If false, they are ignored. */ blk_ref source; /*!< The NiTextureSource block which points to the texture data. > */ @@ -3368,12 +3371,12 @@ struct TexDesc { unsigned short PS2_L; /*!< Something to do with Play Station 2 texture filtering. Usually 0. Exists up to version 10.2.0.0 */ unsigned short PS2_K; /*!< Something to do with Play Station 2 texture filtering. Usually 0xFFB5. Exists up to version 10.2.0.0 */ short unknownShort; /*!< An unknown short value. Exists up to version 4.1.0.12 */ - //Unknown Block in version 10.1.0.0 and up - bool hasUnknownData; /*!< If this is true, the unknown5Floats, unknownInt, unknownFloat1, and unknownFloat2 members are significant. These properties only exist after version 10.1.0.0. */ - float unknown5Floats[5]; /*!< 5 unkown floating point values that exist from version 10.1.0.0 on. */ - int unknownInt; /*!< An unknown integer value that exists from version 10.1.0.0 on. */ - float unknownFloat1; /*!< An unknown floating point value that exists from version 10.1.0.0 on. */ - float unknownFloat2; /*!< An unknown floating point value that exists from version 10.1.0.0 on. */ + bool hasTextureTransform; /*!< Determines whether or not the texture's coordinates are transformed. */ + TexCoord translation; /*!< The amount to translate the texture coordinates in each direction?. */ + TexCoord tiling; /*!< Number of times the texture is tiled in each direction? */ + float w_rotation; /*!< Rotation of the texture image around the W axis? */ + int transform_type; /*!< The texture transform type? Doesn't seem to do anything. */ + TexCoord center_offset; /*!< The offset from the origin? */ }; //--USER GUIDE DOCUMENTATION--//