diff --git a/include/obj/ATextureRenderData.h b/include/obj/ATextureRenderData.h new file mode 100644 index 0000000000000000000000000000000000000000..c7e877e5f5426f41bff2b83023c6455697ca6d58 --- /dev/null +++ b/include/obj/ATextureRenderData.h @@ -0,0 +1,126 @@ +/* Copyright (c) 2006, NIF File Format Library and Tools +All rights reserved. Please see niflib.h for license. */ + +//-----------------------------------NOTICE----------------------------------// +// Some of this file is automatically filled in by a Python script. Only // +// add custom code in the designated areas or it will be overwritten during // +// the next update. // +//-----------------------------------NOTICE----------------------------------// + +#ifndef _ATEXTURERENDERDATA_H_ +#define _ATEXTURERENDERDATA_H_ + +//--BEGIN FILE HEAD CUSTOM CODE--// + +//--END CUSTOM CODE--// + +#include "NiObject.h" + +// Include structures +#include "../gen/ChannelData.h" +#include "../Ref.h" +#include "../gen/MipMap.h" +namespace Niflib { + +// Forward define of referenced NIF objects +class NiPalette; +class ATextureRenderData; +typedef Ref<ATextureRenderData> ATextureRenderDataRef; + +/*! */ +class ATextureRenderData : public NiObject { +public: + /*! Constructor */ + NIFLIB_API ATextureRenderData(); + + /*! Destructor */ + NIFLIB_API virtual ~ATextureRenderData(); + + /*! + * A constant value which uniquly identifies objects of this type. + */ + NIFLIB_API static const Type TYPE; + + /*! + * A factory function used during file reading to create an instance of this type of object. + * \return A pointer to a newly allocated instance of this type of object. + */ + NIFLIB_API static NiObject * Create(); + + /*! + * Summarizes the information contained in this object in English. + * \param[in] verbose Determines whether or not detailed information about large areas of data will be printed out. + * \return A string containing a summary of the information within the object in English. This is the function that Niflyze calls to generate its analysis, so the output is the same. + */ + NIFLIB_API virtual string asString( bool verbose = false ) const; + + /*! + * Used to determine the type of a particular instance of this object. + * \return The type constant for the actual type of the object. + */ + NIFLIB_API virtual const Type & GetType() const; + + //--BEGIN MISC CUSTOM CODE--// + + //--END CUSTOM CODE--// +protected: + /*! The format of the pixels in this internally stored image. */ + PixelFormat pixelFormat; + /*! 0x000000ff (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ + unsigned int redMask; + /*! 0x0000ff00 (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ + unsigned int greenMask; + /*! 0x00ff0000 (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ + unsigned int blueMask; + /*! 0xff000000 (for 32bpp) or 0x00000000 (for 24bpp and 8bpp) */ + unsigned int alphaMask; + /*! Bits per pixel, 0 (?), 8, 24 or 32. */ + byte bitsPerPixel; + /*! Zero? */ + array<3,byte > unknown3Bytes; + /*! + * [96,8,130,0,0,65,0,0] if 24 bits per pixel + * [129,8,130,32,0,65,12,0] if 32 bits per pixel + * [34,0,0,0,0,0,0,0] if 8 bits per pixel + * [4,0,0,0,0,0,0,0] if 0 (?) bits per pixel + */ + array<8,byte > unknown8Bytes; + /*! Seems to always be zero. */ + unsigned int unknownInt; + /*! Unknown. Could be reference pointer. */ + int unknownInt2; + /*! Seems to always be zero. */ + unsigned int unknownInt3; + /*! Flags */ + byte flags; + /*! Seems to always be zero. */ + unsigned int unknownInt4; + /*! Unknown. */ + byte unknownByte1; + /*! Channel Data */ + array<4,ChannelData > channels; + /*! Link to NiPalette, for 8-bit textures. */ + Ref<NiPalette > palette; + /*! Number of mipmaps in the texture. */ + mutable unsigned int numMipmaps; + /*! Bytes per pixel (Bits Per Pixel / 8). */ + unsigned int bytesPerPixel; + /*! Mipmap descriptions (width, height, offset). */ + vector<MipMap > mipmaps; +public: + /*! NIFLIB_HIDDEN function. For internal use only. */ + NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); + /*! NIFLIB_HIDDEN function. For internal use only. */ + NIFLIB_HIDDEN virtual void Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, const NifInfo & info ) const; + /*! NIFLIB_HIDDEN function. For internal use only. */ + NIFLIB_HIDDEN virtual void FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, const NifInfo & info ); + /*! NIFLIB_HIDDEN function. For internal use only. */ + NIFLIB_HIDDEN virtual list<NiObjectRef> GetRefs() const; +}; + +//--BEGIN FILE FOOT CUSTOM CODE--// + +//--END CUSTOM CODE--// + +} //End Niflib namespace +#endif diff --git a/include/obj/NiBSplineBasisData.h b/include/obj/NiBSplineBasisData.h index 25aed0137905e6669b005f8de062fd7777fb42c4..f6a48fc42111fe8091abb281b8768acea8ca995d 100644 --- a/include/obj/NiBSplineBasisData.h +++ b/include/obj/NiBSplineBasisData.h @@ -58,13 +58,13 @@ public: * Retrives the current number of spline control points. This is usually the number of frames for animation. * \return The number of spline control points. */ - NIFLIB_API unsigned int GetNumControlPt() const; + NIFLIB_API unsigned int GetNumControlPoints() const; /*! * Sets the number of spline control points. This is usually the number of frames for animation. * \param[in] value The new number of spline control points. */ - NIFLIB_API void SetNumControlPt( unsigned int value ); + NIFLIB_API void SetNumControlPoints( unsigned int value ); //--END CUSTOM CODE--// protected: diff --git a/include/obj/NiBSplineCompFloatInterpolator.h b/include/obj/NiBSplineCompFloatInterpolator.h index 63a120014cf5ebcbf89a5b6fc3e721fd8923735b..3d689129bd6327ae138ec2ba518611714678a61c 100644 --- a/include/obj/NiBSplineCompFloatInterpolator.h +++ b/include/obj/NiBSplineCompFloatInterpolator.h @@ -108,7 +108,7 @@ public: * Retrieves the number of control points used in the spline curve. * \return The number of control points used in the spline curve. */ - NIFLIB_API int GetNumControlPt() const; + NIFLIB_API int GetNumControlPoints() const; //--END CUSTOM CODE--// protected: /*! Base value when curve not defined. */ diff --git a/include/obj/NiBSplineCompTransformInterpolator.h b/include/obj/NiBSplineCompTransformInterpolator.h index 47e32a3ac1bfe5ce0883ffdd812684c6e9c72b17..3112c94d39b923a5abfbea7e6dbe429db6bd43bc 100644 --- a/include/obj/NiBSplineCompTransformInterpolator.h +++ b/include/obj/NiBSplineCompTransformInterpolator.h @@ -176,7 +176,7 @@ public: * Retrieves the number of control points used in the spline curve. * \return The number of control points used in the spline curve. */ - NIFLIB_API int GetNumControlPt() const; + NIFLIB_API int GetNumControlPoints() const; //--END CUSTOM CODE--// protected: diff --git a/include/obj/NiBSplineTransformInterpolator.h b/include/obj/NiBSplineTransformInterpolator.h index fbed51834a89beca261c0dcc8965919786a52d6f..13f9f3a3d569b4855d6d7d7553bda85ec6907541 100644 --- a/include/obj/NiBSplineTransformInterpolator.h +++ b/include/obj/NiBSplineTransformInterpolator.h @@ -137,7 +137,7 @@ public: * Retrieves the number of control points used in the spline curve. * \return The number of control points used in the spline curve. */ - NIFLIB_API virtual int GetNumControlPt() const; + NIFLIB_API virtual int GetNumControlPoints() const; //--END CUSTOM CODE--// protected: /*! Base translation when translate curve not defined. */ diff --git a/include/obj/NiPersistentSrcTextureRendererData.h b/include/obj/NiPersistentSrcTextureRendererData.h index f44a274535d468a9d158232438f9464ad114c647..89560bd97c06ea264753ad4c6ff11abfad970992 100644 --- a/include/obj/NiPersistentSrcTextureRendererData.h +++ b/include/obj/NiPersistentSrcTextureRendererData.h @@ -14,21 +14,14 @@ All rights reserved. Please see niflib.h for license. */ //--END CUSTOM CODE--// -#include "NiObject.h" - -// Include structures -#include "../gen/ChannelData.h" -#include "../Ref.h" -#include "../gen/MipMap.h" +#include "ATextureRenderData.h" namespace Niflib { -// Forward define of referenced NIF objects -class NiPalette; class NiPersistentSrcTextureRendererData; typedef Ref<NiPersistentSrcTextureRendererData> NiPersistentSrcTextureRendererDataRef; /*! */ -class NiPersistentSrcTextureRendererData : public NiObject { +class NiPersistentSrcTextureRendererData : public ATextureRenderData { public: /*! Constructor */ NIFLIB_API NiPersistentSrcTextureRendererData(); @@ -64,49 +57,6 @@ public: //--END CUSTOM CODE--// protected: - /*! The format of the pixels in this internally stored image. */ - PixelFormat pixelFormat; - /*! 0x000000ff (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ - unsigned int redMask; - /*! 0x0000ff00 (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ - unsigned int greenMask; - /*! 0x00ff0000 (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ - unsigned int blueMask; - /*! 0xff000000 (for 32bpp) or 0x00000000 (for 24bpp and 8bpp) */ - unsigned int alphaMask; - /*! Bits per pixel, 0 (?), 8, 24 or 32. */ - byte bitsPerPixel; - /*! Zero? */ - array<3,byte > unknown3Bytes; - /*! - * [96,8,130,0,0,65,0,0] if 24 bits per pixel - * [129,8,130,32,0,65,12,0] if 32 bits per pixel - * [34,0,0,0,0,0,0,0] if 8 bits per pixel - * [4,0,0,0,0,0,0,0] if 0 (?) bits per pixel - */ - array<8,byte > unknown8Bytes; - /*! Seems to always be zero. */ - unsigned int unknownInt; - /*! Unknown. Could be reference pointer. */ - int unknownInt2; - /*! Seems to always be zero. */ - unsigned int unknownInt3; - /*! Flags */ - byte flags; - /*! Seems to always be zero. */ - unsigned int unknownInt4; - /*! Unknown. */ - byte unknownByte1; - /*! Channel Data */ - array<4,ChannelData > channels; - /*! Link to NiPalette, for 8-bit textures. */ - Ref<NiPalette > palette; - /*! Number of mipmaps in the texture. */ - mutable unsigned int numMipmaps; - /*! Bytes per pixel (Bits Per Pixel / 8). */ - unsigned int bytesPerPixel; - /*! Mipmap descriptions (width, height, offset). */ - vector<MipMap > mipmaps; /*! Unknown */ mutable unsigned int numPixels; /*! Unknown */ diff --git a/include/obj/NiPixelData.h b/include/obj/NiPixelData.h index 5c9970357d6f8951f2ddaab218414a9ad61d1f70..b541b2d211a1418d79bbd9c8f0d2a98ce787158a 100644 --- a/include/obj/NiPixelData.h +++ b/include/obj/NiPixelData.h @@ -13,21 +13,14 @@ All rights reserved. Please see niflib.h for license. */ //--BEGIN FILE HEAD CUSTOM CODE--// //--END CUSTOM CODE--// -#include "NiObject.h" - -// Include structures -#include "../gen/ChannelData.h" -#include "../Ref.h" -#include "../gen/MipMap.h" +#include "ATextureRenderData.h" namespace Niflib { -// Forward define of referenced NIF objects -class NiPalette; class NiPixelData; typedef Ref<NiPixelData> NiPixelDataRef; /*! A texture. */ -class NiPixelData : public NiObject { +class NiPixelData : public ATextureRenderData { public: /*! Constructor */ NIFLIB_API NiPixelData(); @@ -108,49 +101,6 @@ public: //--END CUSTOM CODE--// protected: - /*! The format of the pixels in this internally stored image. */ - PixelFormat pixelFormat; - /*! 0x000000ff (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ - unsigned int redMask; - /*! 0x0000ff00 (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ - unsigned int greenMask; - /*! 0x00ff0000 (for 24bpp and 32bpp) or 0x00000000 (for 8bpp) */ - unsigned int blueMask; - /*! 0xff000000 (for 32bpp) or 0x00000000 (for 24bpp and 8bpp) */ - unsigned int alphaMask; - /*! Bits per pixel, 0 (?), 8, 24 or 32. */ - byte bitsPerPixel; - /*! Zero? */ - array<3,byte > unknown3Bytes; - /*! - * [96,8,130,0,0,65,0,0] if 24 bits per pixel - * [129,8,130,32,0,65,12,0] if 32 bits per pixel - * [34,0,0,0,0,0,0,0] if 8 bits per pixel - * [4,0,0,0,0,0,0,0] if 0 (?) bits per pixel - */ - array<8,byte > unknown8Bytes; - /*! Seems to always be zero. */ - unsigned int unknownInt; - /*! Unknown. Could be reference pointer. */ - int unknownInt2; - /*! Seems to always be zero. */ - unsigned int unknownInt3; - /*! Flags */ - byte flags; - /*! Seems to always be zero. */ - unsigned int unknownInt4; - /*! Unknown. */ - byte unknownByte1; - /*! Channel Data */ - array<4,ChannelData > channels; - /*! Link to NiPalette, for 8-bit textures. */ - Ref<NiPalette > palette; - /*! Number of mipmaps in the texture. */ - mutable unsigned int numMipmaps; - /*! Bytes per pixel (Bits Per Pixel / 8). */ - unsigned int bytesPerPixel; - /*! Mipmap descriptions (width, height, offset). */ - vector<MipMap > mipmaps; /*! Total number of pixels */ mutable unsigned int numPixels; /*! Unknown */ diff --git a/include/obj/NiSourceTexture.h b/include/obj/NiSourceTexture.h index 6395e91a93e2c9e9a55b563ae7bb10655dab9edd..94cd53dd8852376903a8f2b31fad6c96c62db067 100644 --- a/include/obj/NiSourceTexture.h +++ b/include/obj/NiSourceTexture.h @@ -22,6 +22,7 @@ namespace Niflib { // Forward define of referenced NIF objects class NiObject; +class ATextureRenderData; class NiSourceTexture; typedef Ref<NiSourceTexture> NiSourceTextureRef; @@ -138,7 +139,7 @@ protected: /*! Unknown. */ byte unknownByte; /*! Pixel data object index. NiPixelData or NiPersistentSrcTextureRendererData */ - Ref<NiObject > pixelData; + Ref<ATextureRenderData > pixelData; /*! Specifies the way the image will be stored. */ PixelLayout pixelLayout; /*! Specifies whether mip maps are used. */ diff --git a/niflib.vcproj b/niflib.vcproj index 0effb42d41b91e5841e02cfabae094eca63cf9cd..ba817327407efc9df66cf58f0f934a4ab1cc4d31 100644 --- a/niflib.vcproj +++ b/niflib.vcproj @@ -667,6 +667,10 @@ <Filter Name="obj" > + <File + RelativePath=".\src\obj\ATextureRenderData.cpp" + > + </File> <File RelativePath=".\src\obj\AvoidNode.cpp" > diff --git a/niflib_VC2008.vcproj b/niflib_VC2008.vcproj index e121f1cca78db541c52db46a5723237d36805889..d31472d6d3d5d63bbdfc6f32793bc6b21d5a9652 100644 --- a/niflib_VC2008.vcproj +++ b/niflib_VC2008.vcproj @@ -660,6 +660,10 @@ <Filter Name="obj" > + <File + RelativePath=".\src\obj\ATextureRenderData.cpp" + > + </File> <File RelativePath=".\src\obj\AvoidNode.cpp" > @@ -2098,6 +2102,10 @@ <Filter Name="obj" > + <File + RelativePath=".\include\obj\ATextureRenderData.h" + > + </File> <File RelativePath=".\include\obj\AvoidNode.h" > diff --git a/src/gen/register.cpp b/src/gen/register.cpp index b8e46bd844cc84a3603e88d9a9675438f4cca59b..35de0db1843645f40c54c6adecd4381fe7035692 100644 --- a/src/gen/register.cpp +++ b/src/gen/register.cpp @@ -194,6 +194,8 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/obj/NiParticleSystemController.h" #include "../../include/obj/NiBSPArrayController.h" #include "../../include/obj/NiPathController.h" +#include "../../include/obj/ATextureRenderData.h" +#include "../../include/obj/NiPersistentSrcTextureRendererData.h" #include "../../include/obj/NiPixelData.h" #include "../../include/obj/NiPlanarCollider.h" #include "../../include/obj/NiPointLight.h" @@ -288,7 +290,6 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/obj/NiLinesData.h" #include "../../include/obj/NiScreenElementsData.h" #include "../../include/obj/NiScreenElements.h" -#include "../../include/obj/NiPersistentSrcTextureRendererData.h" namespace Niflib { void RegisterObjects() { @@ -481,6 +482,8 @@ namespace Niflib { ObjectRegistry::RegisterObject( "NiParticleSystemController", NiParticleSystemController::Create ); ObjectRegistry::RegisterObject( "NiBSPArrayController", NiBSPArrayController::Create ); ObjectRegistry::RegisterObject( "NiPathController", NiPathController::Create ); + ObjectRegistry::RegisterObject( "ATextureRenderData", ATextureRenderData::Create ); + ObjectRegistry::RegisterObject( "NiPersistentSrcTextureRendererData", NiPersistentSrcTextureRendererData::Create ); ObjectRegistry::RegisterObject( "NiPixelData", NiPixelData::Create ); ObjectRegistry::RegisterObject( "NiPlanarCollider", NiPlanarCollider::Create ); ObjectRegistry::RegisterObject( "NiPointLight", NiPointLight::Create ); @@ -575,7 +578,6 @@ namespace Niflib { ObjectRegistry::RegisterObject( "NiLinesData", NiLinesData::Create ); ObjectRegistry::RegisterObject( "NiScreenElementsData", NiScreenElementsData::Create ); ObjectRegistry::RegisterObject( "NiScreenElements", NiScreenElements::Create ); - ObjectRegistry::RegisterObject( "NiPersistentSrcTextureRendererData", NiPersistentSrcTextureRendererData::Create ); } } diff --git a/src/obj/ATextureRenderData.cpp b/src/obj/ATextureRenderData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a6a4dfee9365f4921116d006114e484fcd05ba7d --- /dev/null +++ b/src/obj/ATextureRenderData.cpp @@ -0,0 +1,267 @@ +/* Copyright (c) 2006, NIF File Format Library and Tools +All rights reserved. Please see niflib.h for license. */ + +//-----------------------------------NOTICE----------------------------------// +// Some of this file is automatically filled in by a Python script. Only // +// add custom code in the designated areas or it will be overwritten during // +// the next update. // +//-----------------------------------NOTICE----------------------------------// + +//--BEGIN FILE HEAD CUSTOM CODE--// + +//--END CUSTOM CODE--// + +#include "../../include/FixLink.h" +#include "../../include/ObjectRegistry.h" +#include "../../include/NIF_IO.h" +#include "../../include/obj/ATextureRenderData.h" +#include "../../include/gen/ChannelData.h" +#include "../../include/gen/MipMap.h" +#include "../../include/obj/NiPalette.h" +using namespace Niflib; + +//Definition of TYPE constant +const Type ATextureRenderData::TYPE("ATextureRenderData", &NiObject::TYPE ); + +ATextureRenderData::ATextureRenderData() : redMask((unsigned int)0), greenMask((unsigned int)0), blueMask((unsigned int)0), alphaMask((unsigned int)0), bitsPerPixel((byte)0), unknownInt((unsigned int)0), unknownInt2((int)0), unknownInt3((unsigned int)0), flags((byte)0), unknownInt4((unsigned int)0), unknownByte1((byte)0), palette(NULL), numMipmaps((unsigned int)0), bytesPerPixel((unsigned int)0) { + //--BEGIN CONSTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +ATextureRenderData::~ATextureRenderData() { + //--BEGIN DESTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +const Type & ATextureRenderData::GetType() const { + return TYPE; +} + +NiObject * ATextureRenderData::Create() { + return new ATextureRenderData; +} + +void ATextureRenderData::Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ) { + //--BEGIN PRE-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// + + unsigned int block_num; + NiObject::Read( in, link_stack, info ); + NifStream( pixelFormat, in, info ); + if ( info.version <= 0x0A020000 ) { + NifStream( redMask, in, info ); + NifStream( greenMask, in, info ); + NifStream( blueMask, in, info ); + NifStream( alphaMask, in, info ); + NifStream( bitsPerPixel, in, info ); + for (unsigned int i2 = 0; i2 < 3; i2++) { + NifStream( unknown3Bytes[i2], in, info ); + }; + for (unsigned int i2 = 0; i2 < 8; i2++) { + NifStream( unknown8Bytes[i2], in, info ); + }; + }; + if ( ( info.version >= 0x0A010000 ) && ( info.version <= 0x0A020000 ) ) { + NifStream( unknownInt, in, info ); + }; + if ( info.version >= 0x14000004 ) { + NifStream( bitsPerPixel, in, info ); + NifStream( unknownInt2, in, info ); + NifStream( unknownInt3, in, info ); + NifStream( flags, in, info ); + NifStream( unknownInt4, in, info ); + }; + if ( info.version >= 0x14030006 ) { + NifStream( unknownByte1, in, info ); + }; + if ( info.version >= 0x14000004 ) { + for (unsigned int i2 = 0; i2 < 4; i2++) { + NifStream( channels[i2].type, in, info ); + NifStream( channels[i2].convention, in, info ); + NifStream( channels[i2].bitsPerChannel, in, info ); + NifStream( channels[i2].unknownByte1, in, info ); + }; + }; + NifStream( block_num, in, info ); + link_stack.push_back( block_num ); + NifStream( numMipmaps, in, info ); + NifStream( bytesPerPixel, in, info ); + mipmaps.resize(numMipmaps); + for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { + NifStream( mipmaps[i1].width, in, info ); + NifStream( mipmaps[i1].height, in, info ); + NifStream( mipmaps[i1].offset, in, info ); + }; + + //--BEGIN POST-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void ATextureRenderData::Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, const NifInfo & info ) const { + //--BEGIN PRE-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiObject::Write( out, link_map, info ); + numMipmaps = (unsigned int)(mipmaps.size()); + NifStream( pixelFormat, out, info ); + if ( info.version <= 0x0A020000 ) { + NifStream( redMask, out, info ); + NifStream( greenMask, out, info ); + NifStream( blueMask, out, info ); + NifStream( alphaMask, out, info ); + NifStream( bitsPerPixel, out, info ); + for (unsigned int i2 = 0; i2 < 3; i2++) { + NifStream( unknown3Bytes[i2], out, info ); + }; + for (unsigned int i2 = 0; i2 < 8; i2++) { + NifStream( unknown8Bytes[i2], out, info ); + }; + }; + if ( ( info.version >= 0x0A010000 ) && ( info.version <= 0x0A020000 ) ) { + NifStream( unknownInt, out, info ); + }; + if ( info.version >= 0x14000004 ) { + NifStream( bitsPerPixel, out, info ); + NifStream( unknownInt2, out, info ); + NifStream( unknownInt3, out, info ); + NifStream( flags, out, info ); + NifStream( unknownInt4, out, info ); + }; + if ( info.version >= 0x14030006 ) { + NifStream( unknownByte1, out, info ); + }; + if ( info.version >= 0x14000004 ) { + for (unsigned int i2 = 0; i2 < 4; i2++) { + NifStream( channels[i2].type, out, info ); + NifStream( channels[i2].convention, out, info ); + NifStream( channels[i2].bitsPerChannel, out, info ); + NifStream( channels[i2].unknownByte1, out, info ); + }; + }; + if ( info.version < VER_3_3_0_13 ) { + NifStream( (unsigned int)&(*palette), out, info ); + } else { + if ( palette != NULL ) { + NifStream( link_map.find( StaticCast<NiObject>(palette) )->second, out, info ); + } else { + NifStream( 0xFFFFFFFF, out, info ); + } + } + NifStream( numMipmaps, out, info ); + NifStream( bytesPerPixel, out, info ); + for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { + NifStream( mipmaps[i1].width, out, info ); + NifStream( mipmaps[i1].height, out, info ); + NifStream( mipmaps[i1].offset, out, info ); + }; + + //--BEGIN POST-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::string ATextureRenderData::asString( bool verbose ) const { + //--BEGIN PRE-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// + + stringstream out; + unsigned int array_output_count = 0; + out << NiObject::asString(); + numMipmaps = (unsigned int)(mipmaps.size()); + out << " Pixel Format: " << pixelFormat << endl; + out << " Red Mask: " << redMask << endl; + out << " Green Mask: " << greenMask << endl; + out << " Blue Mask: " << blueMask << endl; + out << " Alpha Mask: " << alphaMask << endl; + out << " Bits Per Pixel: " << bitsPerPixel << endl; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < 3; i1++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; + break; + }; + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + break; + }; + out << " Unknown 3 Bytes[" << i1 << "]: " << unknown3Bytes[i1] << endl; + array_output_count++; + }; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < 8; i1++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; + break; + }; + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + break; + }; + out << " Unknown 8 Bytes[" << i1 << "]: " << unknown8Bytes[i1] << endl; + array_output_count++; + }; + out << " Unknown Int: " << unknownInt << endl; + out << " Unknown Int 2: " << unknownInt2 << endl; + out << " Unknown Int 3: " << unknownInt3 << endl; + out << " Flags: " << flags << endl; + out << " Unknown Int 4: " << unknownInt4 << endl; + out << " Unknown Byte 1: " << unknownByte1 << endl; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < 4; i1++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; + break; + }; + out << " Type: " << channels[i1].type << endl; + out << " Convention: " << channels[i1].convention << endl; + out << " Bits Per Channel: " << channels[i1].bitsPerChannel << endl; + out << " Unknown Byte 1: " << channels[i1].unknownByte1 << endl; + }; + out << " Palette: " << palette << endl; + out << " Num Mipmaps: " << numMipmaps << endl; + out << " Bytes Per Pixel: " << bytesPerPixel << endl; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; + break; + }; + out << " Width: " << mipmaps[i1].width << endl; + out << " Height: " << mipmaps[i1].height << endl; + out << " Offset: " << mipmaps[i1].offset << endl; + }; + return out.str(); + + //--BEGIN POST-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void ATextureRenderData::FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, const NifInfo & info ) { + //--BEGIN PRE-FIXLINKS CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiObject::FixLinks( objects, link_stack, info ); + palette = FixLink<NiPalette>( objects, link_stack, info ); + + //--BEGIN POST-FIXLINKS CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::list<NiObjectRef> ATextureRenderData::GetRefs() const { + list<Ref<NiObject> > refs; + refs = NiObject::GetRefs(); + if ( palette != NULL ) + refs.push_back(StaticCast<NiObject>(palette)); + return refs; +} + +//--BEGIN MISC CUSTOM CODE--// + +//--END CUSTOM CODE--// diff --git a/src/obj/NiBSplineCompFloatInterpolator.cpp b/src/obj/NiBSplineCompFloatInterpolator.cpp index eb4ce7015288421e07619c2a85f4e5b788c47807..c9a0a56163a80fc143d078e28bb851bf9a5de021 100644 --- a/src/obj/NiBSplineCompFloatInterpolator.cpp +++ b/src/obj/NiBSplineCompFloatInterpolator.cpp @@ -132,7 +132,7 @@ vector< float > NiBSplineCompFloatInterpolator::GetControlData() const { vector< float > value; if ((offset != USHRT_MAX) && splineData && basisData) { // has translation data - int nctrl = basisData->GetNumControlPt(); + int nctrl = basisData->GetNumControlPoints(); int npts = nctrl * SizeofValue; vector<short> points = splineData->GetShortControlPointRange(offset, npts); value.reserve(nctrl); @@ -150,7 +150,7 @@ vector< Key<float> > NiBSplineCompFloatInterpolator::SampleKeys(int npoints, int vector< Key<float> > value; if ((offset != USHRT_MAX) && splineData && basisData) // has rotation data { - int nctrl = basisData->GetNumControlPt(); + int nctrl = basisData->GetNumControlPoints(); int npts = nctrl * SizeofValue; vector<short> points = splineData->GetShortControlPointRange(offset, npts); vector<float> control(npts); @@ -178,11 +178,11 @@ vector< Key<float> > NiBSplineCompFloatInterpolator::SampleKeys(int npoints, int return value; } -int NiBSplineCompFloatInterpolator::GetNumControlPt() const +int NiBSplineCompFloatInterpolator::GetNumControlPoints() const { if (basisData) { - return basisData->GetNumControlPt(); + return basisData->GetNumControlPoints(); } return 0; } diff --git a/src/obj/NiControllerSequence.cpp b/src/obj/NiControllerSequence.cpp index 72ba41ed68d0e63fbfb170c3ebd2eb83caec5e95..4f6aebda16a8a63ba46306901fd18d84a9c1dd97 100644 --- a/src/obj/NiControllerSequence.cpp +++ b/src/obj/NiControllerSequence.cpp @@ -282,7 +282,7 @@ void NiControllerSequence::AddInterpolator( NiSingleInterpController * obj, byte ControllerLink cl; cl.interpolator = interp; - cl.priority_ = priority; + cl.priority = priority; cl.stringPalette = stringPalette; cl.nodeName = target->GetName(); cl.nodeNameOffset = stringPalette->AddSubStr( target->GetName() ); @@ -355,7 +355,7 @@ int NiControllerSequence::GetControllerPriority( int controller ) const { if (controller < 0 && controller < int(controlledBlocks.size())) { throw runtime_error("Invalid controller index."); } - return int(controlledBlocks[controller].priority_); + return int(controlledBlocks[controller].priority); } void NiControllerSequence::SetControllerPriority( int controller, int priority ) { @@ -365,7 +365,7 @@ void NiControllerSequence::SetControllerPriority( int controller, int priority ) if (priority < 0 || priority > int(0xFF)) { throw runtime_error("Invalid priority must be between 0 and 255."); } - controlledBlocks[controller].priority_ = priority; + controlledBlocks[controller].priority = priority; } string NiControllerSequence::GetName() const { diff --git a/src/obj/NiPersistentSrcTextureRendererData.cpp b/src/obj/NiPersistentSrcTextureRendererData.cpp index c849dac7604f8d5db1cc5d1227bd9717b8fa0ff9..9ffd12f344ecb1cc57647b4e73f95a1a4b20b7da 100644 --- a/src/obj/NiPersistentSrcTextureRendererData.cpp +++ b/src/obj/NiPersistentSrcTextureRendererData.cpp @@ -15,15 +15,12 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/ObjectRegistry.h" #include "../../include/NIF_IO.h" #include "../../include/obj/NiPersistentSrcTextureRendererData.h" -#include "../../include/gen/ChannelData.h" -#include "../../include/gen/MipMap.h" -#include "../../include/obj/NiPalette.h" using namespace Niflib; //Definition of TYPE constant -const Type NiPersistentSrcTextureRendererData::TYPE("NiPersistentSrcTextureRendererData", &NiObject::TYPE ); +const Type NiPersistentSrcTextureRendererData::TYPE("NiPersistentSrcTextureRendererData", &ATextureRenderData::TYPE ); -NiPersistentSrcTextureRendererData::NiPersistentSrcTextureRendererData() : redMask((unsigned int)0), greenMask((unsigned int)0), blueMask((unsigned int)0), alphaMask((unsigned int)0), bitsPerPixel((byte)0), unknownInt((unsigned int)0), unknownInt2((int)0), unknownInt3((unsigned int)0), flags((byte)0), unknownInt4((unsigned int)0), unknownByte1((byte)0), palette(NULL), numMipmaps((unsigned int)0), bytesPerPixel((unsigned int)0), numPixels((unsigned int)0), unknownInt6((unsigned int)0), numFaces((unsigned int)0), unknownInt7((unsigned int)0) { +NiPersistentSrcTextureRendererData::NiPersistentSrcTextureRendererData() : numPixels((unsigned int)0), unknownInt6((unsigned int)0), numFaces((unsigned int)0), unknownInt7((unsigned int)0) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// @@ -48,53 +45,7 @@ void NiPersistentSrcTextureRendererData::Read( istream& in, list<unsigned int> & //--END CUSTOM CODE--// - unsigned int block_num; - NiObject::Read( in, link_stack, info ); - NifStream( pixelFormat, in, info ); - if ( info.version <= 0x0A020000 ) { - NifStream( redMask, in, info ); - NifStream( greenMask, in, info ); - NifStream( blueMask, in, info ); - NifStream( alphaMask, in, info ); - NifStream( bitsPerPixel, in, info ); - for (unsigned int i2 = 0; i2 < 3; i2++) { - NifStream( unknown3Bytes[i2], in, info ); - }; - for (unsigned int i2 = 0; i2 < 8; i2++) { - NifStream( unknown8Bytes[i2], in, info ); - }; - }; - if ( ( info.version >= 0x0A010000 ) && ( info.version <= 0x0A020000 ) ) { - NifStream( unknownInt, in, info ); - }; - if ( info.version >= 0x14000004 ) { - NifStream( bitsPerPixel, in, info ); - NifStream( unknownInt2, in, info ); - NifStream( unknownInt3, in, info ); - NifStream( flags, in, info ); - NifStream( unknownInt4, in, info ); - }; - if ( info.version >= 0x14030006 ) { - NifStream( unknownByte1, in, info ); - }; - if ( info.version >= 0x14000004 ) { - for (unsigned int i2 = 0; i2 < 4; i2++) { - NifStream( channels[i2].type, in, info ); - NifStream( channels[i2].convention, in, info ); - NifStream( channels[i2].bitsPerChannel, in, info ); - NifStream( channels[i2].unknownByte1, in, info ); - }; - }; - NifStream( block_num, in, info ); - link_stack.push_back( block_num ); - NifStream( numMipmaps, in, info ); - NifStream( bytesPerPixel, in, info ); - mipmaps.resize(numMipmaps); - for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { - NifStream( mipmaps[i1].width, in, info ); - NifStream( mipmaps[i1].height, in, info ); - NifStream( mipmaps[i1].offset, in, info ); - }; + ATextureRenderData::Read( in, link_stack, info ); NifStream( numPixels, in, info ); NifStream( unknownInt6, in, info ); NifStream( numFaces, in, info ); @@ -117,61 +68,9 @@ void NiPersistentSrcTextureRendererData::Write( ostream& out, const map<NiObject //--END CUSTOM CODE--// - NiObject::Write( out, link_map, info ); + ATextureRenderData::Write( out, link_map, info ); numFaces = (unsigned int)(pixelData.size()); numPixels = (unsigned int)((pixelData.size() > 0) ? pixelData[0].size() : 0); - numMipmaps = (unsigned int)(mipmaps.size()); - NifStream( pixelFormat, out, info ); - if ( info.version <= 0x0A020000 ) { - NifStream( redMask, out, info ); - NifStream( greenMask, out, info ); - NifStream( blueMask, out, info ); - NifStream( alphaMask, out, info ); - NifStream( bitsPerPixel, out, info ); - for (unsigned int i2 = 0; i2 < 3; i2++) { - NifStream( unknown3Bytes[i2], out, info ); - }; - for (unsigned int i2 = 0; i2 < 8; i2++) { - NifStream( unknown8Bytes[i2], out, info ); - }; - }; - if ( ( info.version >= 0x0A010000 ) && ( info.version <= 0x0A020000 ) ) { - NifStream( unknownInt, out, info ); - }; - if ( info.version >= 0x14000004 ) { - NifStream( bitsPerPixel, out, info ); - NifStream( unknownInt2, out, info ); - NifStream( unknownInt3, out, info ); - NifStream( flags, out, info ); - NifStream( unknownInt4, out, info ); - }; - if ( info.version >= 0x14030006 ) { - NifStream( unknownByte1, out, info ); - }; - if ( info.version >= 0x14000004 ) { - for (unsigned int i2 = 0; i2 < 4; i2++) { - NifStream( channels[i2].type, out, info ); - NifStream( channels[i2].convention, out, info ); - NifStream( channels[i2].bitsPerChannel, out, info ); - NifStream( channels[i2].unknownByte1, out, info ); - }; - }; - if ( info.version < VER_3_3_0_13 ) { - NifStream( (unsigned int)&(*palette), out, info ); - } else { - if ( palette != NULL ) { - NifStream( link_map.find( StaticCast<NiObject>(palette) )->second, out, info ); - } else { - NifStream( 0xFFFFFFFF, out, info ); - } - } - NifStream( numMipmaps, out, info ); - NifStream( bytesPerPixel, out, info ); - for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { - NifStream( mipmaps[i1].width, out, info ); - NifStream( mipmaps[i1].height, out, info ); - NifStream( mipmaps[i1].offset, out, info ); - }; NifStream( numPixels, out, info ); NifStream( unknownInt6, out, info ); NifStream( numFaces, out, info ); @@ -194,70 +93,9 @@ std::string NiPersistentSrcTextureRendererData::asString( bool verbose ) const { stringstream out; unsigned int array_output_count = 0; - out << NiObject::asString(); + out << ATextureRenderData::asString(); numFaces = (unsigned int)(pixelData.size()); numPixels = (unsigned int)((pixelData.size() > 0) ? pixelData[0].size() : 0); - numMipmaps = (unsigned int)(mipmaps.size()); - out << " Pixel Format: " << pixelFormat << endl; - out << " Red Mask: " << redMask << endl; - out << " Green Mask: " << greenMask << endl; - out << " Blue Mask: " << blueMask << endl; - out << " Alpha Mask: " << alphaMask << endl; - out << " Bits Per Pixel: " << bitsPerPixel << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 3; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - break; - }; - out << " Unknown 3 Bytes[" << i1 << "]: " << unknown3Bytes[i1] << endl; - array_output_count++; - }; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 8; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - break; - }; - out << " Unknown 8 Bytes[" << i1 << "]: " << unknown8Bytes[i1] << endl; - array_output_count++; - }; - out << " Unknown Int: " << unknownInt << endl; - out << " Unknown Int 2: " << unknownInt2 << endl; - out << " Unknown Int 3: " << unknownInt3 << endl; - out << " Flags: " << flags << endl; - out << " Unknown Int 4: " << unknownInt4 << endl; - out << " Unknown Byte 1: " << unknownByte1 << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 4; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - out << " Type: " << channels[i1].type << endl; - out << " Convention: " << channels[i1].convention << endl; - out << " Bits Per Channel: " << channels[i1].bitsPerChannel << endl; - out << " Unknown Byte 1: " << channels[i1].unknownByte1 << endl; - }; - out << " Palette: " << palette << endl; - out << " Num Mipmaps: " << numMipmaps << endl; - out << " Bytes Per Pixel: " << bytesPerPixel << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - out << " Width: " << mipmaps[i1].width << endl; - out << " Height: " << mipmaps[i1].height << endl; - out << " Offset: " << mipmaps[i1].offset << endl; - }; out << " Num Pixels: " << numPixels << endl; out << " Unknown Int 6: " << unknownInt6 << endl; out << " Num Faces: " << numFaces << endl; @@ -288,8 +126,7 @@ void NiPersistentSrcTextureRendererData::FixLinks( const map<unsigned int,NiObje //--END CUSTOM CODE--// - NiObject::FixLinks( objects, link_stack, info ); - palette = FixLink<NiPalette>( objects, link_stack, info ); + ATextureRenderData::FixLinks( objects, link_stack, info ); //--BEGIN POST-FIXLINKS CUSTOM CODE--// @@ -298,9 +135,7 @@ void NiPersistentSrcTextureRendererData::FixLinks( const map<unsigned int,NiObje std::list<NiObjectRef> NiPersistentSrcTextureRendererData::GetRefs() const { list<Ref<NiObject> > refs; - refs = NiObject::GetRefs(); - if ( palette != NULL ) - refs.push_back(StaticCast<NiObject>(palette)); + refs = ATextureRenderData::GetRefs(); return refs; } diff --git a/src/obj/NiPixelData.cpp b/src/obj/NiPixelData.cpp index 57f42a9e114c9f5d87872440788a4f7d6f3002cb..198d831ef8e7600cf0d7db654fcb706b53bfbd43 100644 --- a/src/obj/NiPixelData.cpp +++ b/src/obj/NiPixelData.cpp @@ -14,15 +14,12 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/ObjectRegistry.h" #include "../../include/NIF_IO.h" #include "../../include/obj/NiPixelData.h" -#include "../../include/gen/ChannelData.h" -#include "../../include/gen/MipMap.h" -#include "../../include/obj/NiPalette.h" using namespace Niflib; //Definition of TYPE constant -const Type NiPixelData::TYPE("NiPixelData", &NiObject::TYPE ); +const Type NiPixelData::TYPE("NiPixelData", &ATextureRenderData::TYPE ); -NiPixelData::NiPixelData() : redMask((unsigned int)0), greenMask((unsigned int)0), blueMask((unsigned int)0), alphaMask((unsigned int)0), bitsPerPixel((byte)0), unknownInt((unsigned int)0), unknownInt2((int)0), unknownInt3((unsigned int)0), flags((byte)0), unknownInt4((unsigned int)0), unknownByte1((byte)0), palette(NULL), numMipmaps((unsigned int)0), bytesPerPixel((unsigned int)0), numPixels((unsigned int)0), numFaces((unsigned int)1) { +NiPixelData::NiPixelData() : numPixels((unsigned int)0), numFaces((unsigned int)1) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// } @@ -47,53 +44,7 @@ void NiPixelData::Read( istream& in, list<unsigned int> & link_stack, const NifI } //--END CUSTOM CODE--// - unsigned int block_num; - NiObject::Read( in, link_stack, info ); - NifStream( pixelFormat, in, info ); - if ( info.version <= 0x0A020000 ) { - NifStream( redMask, in, info ); - NifStream( greenMask, in, info ); - NifStream( blueMask, in, info ); - NifStream( alphaMask, in, info ); - NifStream( bitsPerPixel, in, info ); - for (unsigned int i2 = 0; i2 < 3; i2++) { - NifStream( unknown3Bytes[i2], in, info ); - }; - for (unsigned int i2 = 0; i2 < 8; i2++) { - NifStream( unknown8Bytes[i2], in, info ); - }; - }; - if ( ( info.version >= 0x0A010000 ) && ( info.version <= 0x0A020000 ) ) { - NifStream( unknownInt, in, info ); - }; - if ( info.version >= 0x14000004 ) { - NifStream( bitsPerPixel, in, info ); - NifStream( unknownInt2, in, info ); - NifStream( unknownInt3, in, info ); - NifStream( flags, in, info ); - NifStream( unknownInt4, in, info ); - }; - if ( info.version >= 0x14030006 ) { - NifStream( unknownByte1, in, info ); - }; - if ( info.version >= 0x14000004 ) { - for (unsigned int i2 = 0; i2 < 4; i2++) { - NifStream( channels[i2].type, in, info ); - NifStream( channels[i2].convention, in, info ); - NifStream( channels[i2].bitsPerChannel, in, info ); - NifStream( channels[i2].unknownByte1, in, info ); - }; - }; - NifStream( block_num, in, info ); - link_stack.push_back( block_num ); - NifStream( numMipmaps, in, info ); - NifStream( bytesPerPixel, in, info ); - mipmaps.resize(numMipmaps); - for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { - NifStream( mipmaps[i1].width, in, info ); - NifStream( mipmaps[i1].height, in, info ); - NifStream( mipmaps[i1].offset, in, info ); - }; + ATextureRenderData::Read( in, link_stack, info ); NifStream( numPixels, in, info ); if ( info.version >= 0x14000004 ) { NifStream( numFaces, in, info ); @@ -122,61 +73,9 @@ void NiPixelData::Write( ostream& out, const map<NiObjectRef,unsigned int> & lin //--BEGIN PRE-WRITE CUSTOM CODE--// //--END CUSTOM CODE--// - NiObject::Write( out, link_map, info ); + ATextureRenderData::Write( out, link_map, info ); numFaces = (unsigned int)(pixelData.size()); numPixels = (unsigned int)((pixelData.size() > 0) ? pixelData[0].size() : 0); - numMipmaps = (unsigned int)(mipmaps.size()); - NifStream( pixelFormat, out, info ); - if ( info.version <= 0x0A020000 ) { - NifStream( redMask, out, info ); - NifStream( greenMask, out, info ); - NifStream( blueMask, out, info ); - NifStream( alphaMask, out, info ); - NifStream( bitsPerPixel, out, info ); - for (unsigned int i2 = 0; i2 < 3; i2++) { - NifStream( unknown3Bytes[i2], out, info ); - }; - for (unsigned int i2 = 0; i2 < 8; i2++) { - NifStream( unknown8Bytes[i2], out, info ); - }; - }; - if ( ( info.version >= 0x0A010000 ) && ( info.version <= 0x0A020000 ) ) { - NifStream( unknownInt, out, info ); - }; - if ( info.version >= 0x14000004 ) { - NifStream( bitsPerPixel, out, info ); - NifStream( unknownInt2, out, info ); - NifStream( unknownInt3, out, info ); - NifStream( flags, out, info ); - NifStream( unknownInt4, out, info ); - }; - if ( info.version >= 0x14030006 ) { - NifStream( unknownByte1, out, info ); - }; - if ( info.version >= 0x14000004 ) { - for (unsigned int i2 = 0; i2 < 4; i2++) { - NifStream( channels[i2].type, out, info ); - NifStream( channels[i2].convention, out, info ); - NifStream( channels[i2].bitsPerChannel, out, info ); - NifStream( channels[i2].unknownByte1, out, info ); - }; - }; - if ( info.version < VER_3_3_0_13 ) { - NifStream( (unsigned int)&(*palette), out, info ); - } else { - if ( palette != NULL ) { - NifStream( link_map.find( StaticCast<NiObject>(palette) )->second, out, info ); - } else { - NifStream( 0xFFFFFFFF, out, info ); - } - } - NifStream( numMipmaps, out, info ); - NifStream( bytesPerPixel, out, info ); - for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { - NifStream( mipmaps[i1].width, out, info ); - NifStream( mipmaps[i1].height, out, info ); - NifStream( mipmaps[i1].offset, out, info ); - }; NifStream( numPixels, out, info ); if ( info.version >= 0x14000004 ) { NifStream( numFaces, out, info ); @@ -204,70 +103,9 @@ std::string NiPixelData::asString( bool verbose ) const { stringstream out; unsigned int array_output_count = 0; - out << NiObject::asString(); + out << ATextureRenderData::asString(); numFaces = (unsigned int)(pixelData.size()); numPixels = (unsigned int)((pixelData.size() > 0) ? pixelData[0].size() : 0); - numMipmaps = (unsigned int)(mipmaps.size()); - out << " Pixel Format: " << pixelFormat << endl; - out << " Red Mask: " << redMask << endl; - out << " Green Mask: " << greenMask << endl; - out << " Blue Mask: " << blueMask << endl; - out << " Alpha Mask: " << alphaMask << endl; - out << " Bits Per Pixel: " << bitsPerPixel << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 3; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - break; - }; - out << " Unknown 3 Bytes[" << i1 << "]: " << unknown3Bytes[i1] << endl; - array_output_count++; - }; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 8; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - break; - }; - out << " Unknown 8 Bytes[" << i1 << "]: " << unknown8Bytes[i1] << endl; - array_output_count++; - }; - out << " Unknown Int: " << unknownInt << endl; - out << " Unknown Int 2: " << unknownInt2 << endl; - out << " Unknown Int 3: " << unknownInt3 << endl; - out << " Flags: " << flags << endl; - out << " Unknown Int 4: " << unknownInt4 << endl; - out << " Unknown Byte 1: " << unknownByte1 << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 4; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - out << " Type: " << channels[i1].type << endl; - out << " Convention: " << channels[i1].convention << endl; - out << " Bits Per Channel: " << channels[i1].bitsPerChannel << endl; - out << " Unknown Byte 1: " << channels[i1].unknownByte1 << endl; - }; - out << " Palette: " << palette << endl; - out << " Num Mipmaps: " << numMipmaps << endl; - out << " Bytes Per Pixel: " << bytesPerPixel << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < mipmaps.size(); i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - out << " Width: " << mipmaps[i1].width << endl; - out << " Height: " << mipmaps[i1].height << endl; - out << " Offset: " << mipmaps[i1].offset << endl; - }; out << " Num Pixels: " << numPixels << endl; out << " Num Faces: " << numFaces << endl; array_output_count = 0; @@ -294,8 +132,7 @@ void NiPixelData::FixLinks( const map<unsigned int,NiObjectRef> & objects, list< //--BEGIN PRE-FIXLINKS CUSTOM CODE--// //--END CUSTOM CODE--// - NiObject::FixLinks( objects, link_stack, info ); - palette = FixLink<NiPalette>( objects, link_stack, info ); + ATextureRenderData::FixLinks( objects, link_stack, info ); //--BEGIN POST-FIXLINKS CUSTOM CODE--// //--END CUSTOM CODE--// @@ -303,9 +140,7 @@ void NiPixelData::FixLinks( const map<unsigned int,NiObjectRef> & objects, list< std::list<NiObjectRef> NiPixelData::GetRefs() const { list<Ref<NiObject> > refs; - refs = NiObject::GetRefs(); - if ( palette != NULL ) - refs.push_back(StaticCast<NiObject>(palette)); + refs = ATextureRenderData::GetRefs(); return refs; } diff --git a/src/obj/NiSourceTexture.cpp b/src/obj/NiSourceTexture.cpp index b06b5eb51ae779486cdf6f97c68b4bde27106f54..d14b4914af77ee4b3101cb0696dbad2732752b1c 100644 --- a/src/obj/NiSourceTexture.cpp +++ b/src/obj/NiSourceTexture.cpp @@ -15,6 +15,7 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/NIF_IO.h" #include "../../include/obj/NiSourceTexture.h" #include "../../include/obj/NiObject.h" +#include "../../include/obj/ATextureRenderData.h" using namespace Niflib; //Definition of TYPE constant @@ -180,7 +181,7 @@ void NiSourceTexture::FixLinks( const map<unsigned int,NiObjectRef> & objects, l }; }; if ( (useExternal == 0) ) { - pixelData = FixLink<NiObject>( objects, link_stack, info ); + pixelData = FixLink<ATextureRenderData>( objects, link_stack, info ); }; //--BEGIN POST-FIXLINKS CUSTOM CODE--//