diff --git a/include/gen/Polygon.h b/include/gen/Polygon.h new file mode 100644 index 0000000000000000000000000000000000000000..81f045fbc8c5f9fcf2dd295f7bd368bdfd2fdf54 --- /dev/null +++ b/include/gen/Polygon.h @@ -0,0 +1,37 @@ +/* Copyright (c) 2006, NIF File Format Library and Tools +All rights reserved. Please see niflib.h for license. */ + +//---THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT---// + +//To change this file, alter the niftools/docsys/gen_niflib.py Python script. + +#ifndef _POLYGON_H_ +#define _POLYGON_H_ + +#include "../NIF_IO.h" + +namespace Niflib { + + +/*! Two dimensional screen elements. */ +struct Polygon { + /*! Default Constructor */ + NIFLIB_API Polygon(); + /*! Default Destructor */ + NIFLIB_API ~Polygon(); + /*! Copy Constructor */ + NIFLIB_API Polygon( const Polygon & src ); + /*! Copy Operator */ + NIFLIB_API Polygon & operator=( const Polygon & src ); + /*! Number of vertices in this polygon */ + unsigned short numVertices; + /*! Vertex Offset */ + unsigned short vertexOffset; + /*! Number of faces in this polygon */ + unsigned short numTriangles; + /*! Triangle offset in shape */ + unsigned short triangleOffset; +}; + +} +#endif diff --git a/include/obj/NiPSysMeshUpdateModifier.h b/include/obj/NiPSysMeshUpdateModifier.h index cdf6e16094179890fe7d5f7a66c0b9a1f5e4346c..5cecadc681294f8e0d6f836ad224e0ff29753acc 100644 --- a/include/obj/NiPSysMeshUpdateModifier.h +++ b/include/obj/NiPSysMeshUpdateModifier.h @@ -20,7 +20,7 @@ All rights reserved. Please see niflib.h for license. */ namespace Niflib { // Forward define of referenced NIF objects -class NiNode; +class NiAVObject; class NiPSysMeshUpdateModifier; typedef Ref<NiPSysMeshUpdateModifier> NiPSysMeshUpdateModifierRef; @@ -62,8 +62,8 @@ public: protected: /*! The number of object references that follow. */ mutable unsigned int numMeshes; - /*! Not sure here... Group of target NiNodes? */ - vector<Ref<NiNode > > meshes; + /*! Group of target NiNodes or NiTriShapes? */ + vector<Ref<NiAVObject > > meshes; public: /*! NIFLIB_HIDDEN function. For internal use only. */ NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); diff --git a/include/obj/NiPersistentSrcTextureRendererData.h b/include/obj/NiPersistentSrcTextureRendererData.h new file mode 100644 index 0000000000000000000000000000000000000000..f44a274535d468a9d158232438f9464ad114c647 --- /dev/null +++ b/include/obj/NiPersistentSrcTextureRendererData.h @@ -0,0 +1,139 @@ +/* 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 _NIPERSISTENTSRCTEXTURERENDERERDATA_H_ +#define _NIPERSISTENTSRCTEXTURERENDERERDATA_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 NiPersistentSrcTextureRendererData; +typedef Ref<NiPersistentSrcTextureRendererData> NiPersistentSrcTextureRendererDataRef; + +/*! */ +class NiPersistentSrcTextureRendererData : public NiObject { +public: + /*! Constructor */ + NIFLIB_API NiPersistentSrcTextureRendererData(); + + /*! Destructor */ + NIFLIB_API virtual ~NiPersistentSrcTextureRendererData(); + + /*! + * 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; + /*! Unknown */ + mutable unsigned int numPixels; + /*! Unknown */ + unsigned int unknownInt6; + /*! Unknown */ + mutable unsigned int numFaces; + /*! Unknown */ + unsigned int unknownInt7; + /*! + * Raw pixel data holding the mipmaps. Mipmap zero is the full-size texture and + * they get smaller by half as the number increases. + */ + vector< vector<byte > > pixelData; +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/NiPixelData.h b/include/obj/NiPixelData.h index b53bec06057068732844723dea07d3926a7cdbb8..5c9970357d6f8951f2ddaab218414a9ad61d1f70 100644 --- a/include/obj/NiPixelData.h +++ b/include/obj/NiPixelData.h @@ -19,8 +19,6 @@ All rights reserved. Please see niflib.h for license. */ #include "../gen/ChannelData.h" #include "../Ref.h" #include "../gen/MipMap.h" -#include "../gen/ByteArray.h" -#include "../gen/ByteMatrix.h" namespace Niflib { // Forward define of referenced NIF objects @@ -153,16 +151,15 @@ protected: unsigned int bytesPerPixel; /*! Mipmap descriptions (width, height, offset). */ vector<MipMap > mipmaps; + /*! Total number of pixels */ + mutable unsigned int numPixels; + /*! Unknown */ + mutable unsigned int numFaces; /*! * Raw pixel data holding the mipmaps. Mipmap zero is the full-size texture and * they get smaller by half as the number increases. */ - ByteArray pixelData; - /*! - * Raw pixel data holding the mipmaps. Mipmap zero is the full-size texture and - * they get smaller by half as the number increases. - */ - ByteMatrix pixelDataMatrix; + vector< vector<byte > > pixelData; public: /*! NIFLIB_HIDDEN function. For internal use only. */ NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); diff --git a/include/obj/NiScreenElements.h b/include/obj/NiScreenElements.h new file mode 100644 index 0000000000000000000000000000000000000000..64c1405724034b02dfce6478fd828c724c285c0c --- /dev/null +++ b/include/obj/NiScreenElements.h @@ -0,0 +1,75 @@ +/* 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 _NISCREENELEMENTS_H_ +#define _NISCREENELEMENTS_H_ + +//--BEGIN FILE HEAD CUSTOM CODE--// + +//--END CUSTOM CODE--// + +#include "NiTriShape.h" +namespace Niflib { + +class NiScreenElements; +typedef Ref<NiScreenElements> NiScreenElementsRef; + +/*! Two dimensional screen elements. */ +class NiScreenElements : public NiTriShape { +public: + /*! Constructor */ + NIFLIB_API NiScreenElements(); + + /*! Destructor */ + NIFLIB_API virtual ~NiScreenElements(); + + /*! + * 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--// +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/NiScreenElementsData.h b/include/obj/NiScreenElementsData.h new file mode 100644 index 0000000000000000000000000000000000000000..19c13d647edc9207036360c16135396c715e5fbb --- /dev/null +++ b/include/obj/NiScreenElementsData.h @@ -0,0 +1,97 @@ +/* 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 _NISCREENELEMENTSDATA_H_ +#define _NISCREENELEMENTSDATA_H_ + +//--BEGIN FILE HEAD CUSTOM CODE--// + +//--END CUSTOM CODE--// + +#include "NiTriShapeData.h" + +// Include structures +#include "../gen/Polygon.h" +namespace Niflib { + +class NiScreenElementsData; +typedef Ref<NiScreenElementsData> NiScreenElementsDataRef; + +/*! Two dimensional screen elements. */ +class NiScreenElementsData : public NiTriShapeData { +public: + /*! Constructor */ + NIFLIB_API NiScreenElementsData(); + + /*! Destructor */ + NIFLIB_API virtual ~NiScreenElementsData(); + + /*! + * 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: + /*! Maximum number of polygons? */ + mutable unsigned short maxPolygons; + /*! Polygons */ + vector<Polygon > polygons; + /*! Polygon Indices */ + vector<unsigned short > polygonIndices; + /*! Unknown */ + unsigned short unknownUshort1; + /*! Number of Polygons actually in use */ + unsigned short numPolygons; + /*! Number of in-use vertices */ + unsigned short usedVertices; + /*! Unknown */ + unsigned short unknownUshort2; + /*! Number of in-use triangles */ + unsigned short usedTrianglePoints; + /*! Maximum number of faces */ + unsigned short unknownUshort3; +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/NiSourceTexture.h b/include/obj/NiSourceTexture.h index 6a7bd201d48f9951142434809e6708580e66d36d..6395e91a93e2c9e9a55b563ae7bb10655dab9edd 100644 --- a/include/obj/NiSourceTexture.h +++ b/include/obj/NiSourceTexture.h @@ -11,6 +11,7 @@ All rights reserved. Please see niflib.h for license. */ #define _NISOURCETEXTURE_H_ //--BEGIN FILE HEAD CUSTOM CODE--// +#include "NiPixelData.h" //--END CUSTOM CODE--// #include "NiTexture.h" @@ -21,7 +22,6 @@ namespace Niflib { // Forward define of referenced NIF objects class NiObject; -class NiPixelData; class NiSourceTexture; typedef Ref<NiSourceTexture> NiSourceTextureRef; @@ -137,8 +137,8 @@ protected: Ref<NiObject > unknownLink; /*! Unknown. */ byte unknownByte; - /*! Pixel data object index. */ - Ref<NiPixelData > pixelData; + /*! Pixel data object index. NiPixelData or NiPersistentSrcTextureRendererData */ + Ref<NiObject > pixelData; /*! Specifies the way the image will be stored. */ PixelLayout pixelLayout; /*! Specifies whether mip maps are used. */ diff --git a/include/obj/bhkRigidBody.h b/include/obj/bhkRigidBody.h index a5ae39fe89512a7659ff2a1ee6c847acf8fab286..76104f3f10f2e4611c8f32fd02b0160a5d83f278 100644 --- a/include/obj/bhkRigidBody.h +++ b/include/obj/bhkRigidBody.h @@ -338,7 +338,7 @@ protected: * balancing objects in contraints. */ Vector4 center; - /*! The body's mass. */ + /*! The body's mass in kg. A mass of zero represents an immovable object. */ float mass; /*! * Damping value for linear movement. A value that is too small fixes the object in diff --git a/niflib.vcproj b/niflib.vcproj index 40f1df0fb3da337594dd47ba8369a0c4d8ffa903..0effb42d41b91e5841e02cfabae094eca63cf9cd 100644 --- a/niflib.vcproj +++ b/niflib.vcproj @@ -1359,6 +1359,10 @@ RelativePath=".\src\obj\NiPathInterpolator.cpp" > </File> + <File + RelativePath=".\src\obj\NiPersistentSrcTextureRendererData.cpp" + > + </File> <File RelativePath=".\src\obj\NiPhysXActorDesc.cpp" > @@ -1595,6 +1599,14 @@ RelativePath=".\src\obj\NiRotatingParticlesData.cpp" > </File> + <File + RelativePath=".\src\obj\NiScreenElements.cpp" + > + </File> + <File + RelativePath=".\src\obj\NiScreenElementsData.cpp" + > + </File> <File RelativePath=".\src\obj\NiScreenLODData.cpp" > @@ -1923,6 +1935,10 @@ RelativePath=".\src\gen\physXMaterialRef.cpp" > </File> + <File + RelativePath=".\src\gen\Polygon.cpp" + > + </File> <File RelativePath=".\src\gen\QuaternionXYZW.cpp" > @@ -2777,6 +2793,10 @@ RelativePath=".\include\obj\NiPathInterpolator.h" > </File> + <File + RelativePath=".\include\obj\NiPersistentSrcTextureRendererData.h" + > + </File> <File RelativePath=".\include\obj\NiPhysXActorDesc.h" > @@ -3013,6 +3033,14 @@ RelativePath=".\include\obj\NiRotatingParticlesData.h" > </File> + <File + RelativePath=".\include\obj\NiScreenElements.h" + > + </File> + <File + RelativePath=".\include\obj\NiScreenElementsData.h" + > + </File> <File RelativePath=".\include\obj\NiScreenLODData.h" > @@ -3349,6 +3377,10 @@ RelativePath=".\include\gen\physXMaterialRef.h" > </File> + <File + RelativePath=".\include\gen\Polygon.h" + > + </File> <File RelativePath=".\include\gen\QuaternionXYZW.h" > diff --git a/niflib_VC2008.vcproj b/niflib_VC2008.vcproj index 4a0299521a496cd3045bbd339f6416be0be5fec4..e121f1cca78db541c52db46a5723237d36805889 100644 --- a/niflib_VC2008.vcproj +++ b/niflib_VC2008.vcproj @@ -1352,6 +1352,10 @@ RelativePath=".\src\obj\NiPathInterpolator.cpp" > </File> + <File + RelativePath=".\src\obj\NiPersistentSrcTextureRendererData.cpp" + > + </File> <File RelativePath=".\src\obj\NiPhysXActorDesc.cpp" > @@ -1588,6 +1592,14 @@ RelativePath=".\src\obj\NiRotatingParticlesData.cpp" > </File> + <File + RelativePath=".\src\obj\NiScreenElements.cpp" + > + </File> + <File + RelativePath=".\src\obj\NiScreenElementsData.cpp" + > + </File> <File RelativePath=".\src\obj\NiScreenLODData.cpp" > @@ -1920,6 +1932,10 @@ RelativePath=".\src\gen\physXMaterialRef.cpp" > </File> + <File + RelativePath=".\src\gen\Polygon.cpp" + > + </File> <File RelativePath=".\src\gen\QuaternionXYZW.cpp" > diff --git a/src/gen/Polygon.cpp b/src/gen/Polygon.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a764dbf8ca3b80bb48a7d261ab113879a3893ffd --- /dev/null +++ b/src/gen/Polygon.cpp @@ -0,0 +1,29 @@ +/* Copyright (c) 2006, NIF File Format Library and Tools +All rights reserved. Please see niflib.h for license. */ + +//---THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT---// + +//To change this file, alter the niftools/docsys/gen_niflib.py Python script. + +#include "../../include/gen/Polygon.h" +using namespace Niflib; + +//Constructor +Polygon::Polygon() : numVertices((unsigned short)0), vertexOffset((unsigned short)0), numTriangles((unsigned short)0), triangleOffset((unsigned short)0) {}; + +//Copy Constructor +Polygon::Polygon( const Polygon & src ) { + *this = src; +}; + +//Copy Operator +Polygon & Polygon::operator=( const Polygon & src ) { + this->numVertices = src.numVertices; + this->vertexOffset = src.vertexOffset; + this->numTriangles = src.numTriangles; + this->triangleOffset = src.triangleOffset; + return *this; +}; + +//Destructor +Polygon::~Polygon() {}; diff --git a/src/gen/register.cpp b/src/gen/register.cpp index cf5800869422f1ee13f560153461c28109e1e9b0..b8e46bd844cc84a3603e88d9a9675438f4cca59b 100644 --- a/src/gen/register.cpp +++ b/src/gen/register.cpp @@ -286,6 +286,9 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/obj/NiArkShaderExtraData.h" #include "../../include/obj/NiLines.h" #include "../../include/obj/NiLinesData.h" +#include "../../include/obj/NiScreenElementsData.h" +#include "../../include/obj/NiScreenElements.h" +#include "../../include/obj/NiPersistentSrcTextureRendererData.h" namespace Niflib { void RegisterObjects() { @@ -570,6 +573,9 @@ namespace Niflib { ObjectRegistry::RegisterObject( "NiArkShaderExtraData", NiArkShaderExtraData::Create ); ObjectRegistry::RegisterObject( "NiLines", NiLines::Create ); 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/NiPSysMeshUpdateModifier.cpp b/src/obj/NiPSysMeshUpdateModifier.cpp index e13156545e106e6ecd70430b9e29096e755e1c28..edd51c7ae516b504fdd3e439dcebfc915051d6a0 100644 --- a/src/obj/NiPSysMeshUpdateModifier.cpp +++ b/src/obj/NiPSysMeshUpdateModifier.cpp @@ -14,7 +14,7 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/ObjectRegistry.h" #include "../../include/NIF_IO.h" #include "../../include/obj/NiPSysMeshUpdateModifier.h" -#include "../../include/obj/NiNode.h" +#include "../../include/obj/NiAVObject.h" using namespace Niflib; //Definition of TYPE constant @@ -111,7 +111,7 @@ void NiPSysMeshUpdateModifier::FixLinks( const map<unsigned int,NiObjectRef> & o NiPSysModifier::FixLinks( objects, link_stack, info ); for (unsigned int i1 = 0; i1 < meshes.size(); i1++) { - meshes[i1] = FixLink<NiNode>( objects, link_stack, info ); + meshes[i1] = FixLink<NiAVObject>( objects, link_stack, info ); }; //--BEGIN POST-FIXLINKS CUSTOM CODE--// diff --git a/src/obj/NiPersistentSrcTextureRendererData.cpp b/src/obj/NiPersistentSrcTextureRendererData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c849dac7604f8d5db1cc5d1227bd9717b8fa0ff9 --- /dev/null +++ b/src/obj/NiPersistentSrcTextureRendererData.cpp @@ -0,0 +1,309 @@ +/* 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/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 ); + +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) { + //--BEGIN CONSTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +NiPersistentSrcTextureRendererData::~NiPersistentSrcTextureRendererData() { + //--BEGIN DESTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +const Type & NiPersistentSrcTextureRendererData::GetType() const { + return TYPE; +} + +NiObject * NiPersistentSrcTextureRendererData::Create() { + return new NiPersistentSrcTextureRendererData; +} + +void NiPersistentSrcTextureRendererData::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 ); + }; + NifStream( numPixels, in, info ); + NifStream( unknownInt6, in, info ); + NifStream( numFaces, in, info ); + NifStream( unknownInt7, in, info ); + pixelData.resize(numFaces); + for (unsigned int i1 = 0; i1 < pixelData.size(); i1++) { + pixelData[i1].resize(numPixels); + for (unsigned int i2 = 0; i2 < pixelData[i1].size(); i2++) { + NifStream( pixelData[i1][i2], in, info ); + }; + }; + + //--BEGIN POST-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void NiPersistentSrcTextureRendererData::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 ); + 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 ); + NifStream( unknownInt7, out, info ); + for (unsigned int i1 = 0; i1 < pixelData.size(); i1++) { + for (unsigned int i2 = 0; i2 < pixelData[i1].size(); i2++) { + NifStream( pixelData[i1][i2], out, info ); + }; + }; + + //--BEGIN POST-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::string NiPersistentSrcTextureRendererData::asString( bool verbose ) const { + //--BEGIN PRE-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// + + stringstream out; + unsigned int array_output_count = 0; + out << NiObject::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; + out << " Unknown Int 7: " << unknownInt7 << endl; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < pixelData.size(); i1++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; + break; + }; + for (unsigned int i2 = 0; i2 < pixelData[i1].size(); i2++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + break; + }; + out << " Pixel Data[" << i2 << "]: " << pixelData[i1][i2] << endl; + array_output_count++; + }; + }; + return out.str(); + + //--BEGIN POST-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void NiPersistentSrcTextureRendererData::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> NiPersistentSrcTextureRendererData::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/NiPixelData.cpp b/src/obj/NiPixelData.cpp index 5c418786e0189b3dd0375eed59a38adc2d662803..57f42a9e114c9f5d87872440788a4f7d6f3002cb 100644 --- a/src/obj/NiPixelData.cpp +++ b/src/obj/NiPixelData.cpp @@ -16,15 +16,13 @@ All rights reserved. Please see niflib.h for license. */ #include "../../include/obj/NiPixelData.h" #include "../../include/gen/ChannelData.h" #include "../../include/gen/MipMap.h" -#include "../../include/gen/ByteArray.h" -#include "../../include/gen/ByteMatrix.h" #include "../../include/obj/NiPalette.h" using namespace Niflib; //Definition of TYPE constant const Type NiPixelData::TYPE("NiPixelData", &NiObject::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) { +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) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// } @@ -44,6 +42,9 @@ NiObject * NiPixelData::Create() { void NiPixelData::Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ) { //--BEGIN PRE-READ CUSTOM CODE--// + if ( info.version <= 0x0A020000 ) { + pixelData.resize(1); + } //--END CUSTOM CODE--// unsigned int block_num; @@ -93,21 +94,22 @@ void NiPixelData::Read( istream& in, list<unsigned int> & link_stack, const NifI NifStream( mipmaps[i1].height, in, info ); NifStream( mipmaps[i1].offset, in, info ); }; - if ( info.version <= 0x0A020000 ) { - NifStream( pixelData.dataSize, in, info ); - pixelData.data.resize(pixelData.dataSize); - for (unsigned int i2 = 0; i2 < pixelData.data.size(); i2++) { - NifStream( pixelData.data[i2], in, info ); + NifStream( numPixels, in, info ); + if ( info.version >= 0x14000004 ) { + NifStream( numFaces, in, info ); + pixelData.resize(numFaces); + for (unsigned int i2 = 0; i2 < pixelData.size(); i2++) { + pixelData[i2].resize(numPixels); + for (unsigned int i3 = 0; i3 < pixelData[i2].size(); i3++) { + NifStream( pixelData[i2][i3], in, info ); + }; }; }; - if ( info.version >= 0x14000004 ) { - NifStream( pixelDataMatrix.dataSize1, in, info ); - NifStream( pixelDataMatrix.dataSize2, in, info ); - pixelDataMatrix.data.resize(pixelDataMatrix.dataSize2); - for (unsigned int i2 = 0; i2 < pixelDataMatrix.data.size(); i2++) { - pixelDataMatrix.data[i2].resize(pixelDataMatrix.dataSize1); - for (unsigned int i3 = 0; i3 < pixelDataMatrix.data[i2].size(); i3++) { - NifStream( pixelDataMatrix.data[i2][i3], in, info ); + if ( info.version <= 0x0A020000 ) { + for (unsigned int i2 = 0; i2 < 1; i2++) { + pixelData[i2].resize(numPixels); + for (unsigned int i3 = 0; i3 < pixelData[i2].size(); i3++) { + NifStream( pixelData[i2][i3], in, info ); }; }; }; @@ -121,6 +123,8 @@ void NiPixelData::Write( ostream& out, const map<NiObjectRef,unsigned int> & lin //--END CUSTOM CODE--// NiObject::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 ) { @@ -173,21 +177,19 @@ void NiPixelData::Write( ostream& out, const map<NiObjectRef,unsigned int> & lin NifStream( mipmaps[i1].height, out, info ); NifStream( mipmaps[i1].offset, out, info ); }; - if ( info.version <= 0x0A020000 ) { - pixelData.dataSize = (unsigned int)(pixelData.data.size()); - NifStream( pixelData.dataSize, out, info ); - for (unsigned int i2 = 0; i2 < pixelData.data.size(); i2++) { - NifStream( pixelData.data[i2], out, info ); + NifStream( numPixels, out, info ); + if ( info.version >= 0x14000004 ) { + NifStream( numFaces, out, info ); + for (unsigned int i2 = 0; i2 < pixelData.size(); i2++) { + for (unsigned int i3 = 0; i3 < pixelData[i2].size(); i3++) { + NifStream( pixelData[i2][i3], out, info ); + }; }; }; - if ( info.version >= 0x14000004 ) { - pixelDataMatrix.dataSize2 = (unsigned int)(pixelDataMatrix.data.size()); - pixelDataMatrix.dataSize1 = (unsigned int)((pixelDataMatrix.data.size() > 0) ? pixelDataMatrix.data[0].size() : 0); - NifStream( pixelDataMatrix.dataSize1, out, info ); - NifStream( pixelDataMatrix.dataSize2, out, info ); - for (unsigned int i2 = 0; i2 < pixelDataMatrix.data.size(); i2++) { - for (unsigned int i3 = 0; i3 < pixelDataMatrix.data[i2].size(); i3++) { - NifStream( pixelDataMatrix.data[i2][i3], out, info ); + if ( info.version <= 0x0A020000 ) { + for (unsigned int i2 = 0; i2 < 1; i2++) { + for (unsigned int i3 = 0; i3 < pixelData[i2].size(); i3++) { + NifStream( pixelData[i2][i3], out, info ); }; }; }; @@ -203,6 +205,8 @@ std::string NiPixelData::asString( bool verbose ) const { stringstream out; unsigned int array_output_count = 0; out << NiObject::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; @@ -264,35 +268,19 @@ std::string NiPixelData::asString( bool verbose ) const { out << " Height: " << mipmaps[i1].height << endl; out << " Offset: " << mipmaps[i1].offset << endl; }; - pixelData.dataSize = (unsigned int)(pixelData.data.size()); - out << " Data Size: " << pixelData.dataSize << endl; + out << " Num Pixels: " << numPixels << endl; + out << " Num Faces: " << numFaces << endl; array_output_count = 0; - for (unsigned int i1 = 0; i1 < pixelData.data.size(); i1++) { + for (unsigned int i1 = 0; i1 < pixelData.size(); 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 << " Data[" << i1 << "]: " << pixelData.data[i1] << endl; - array_output_count++; - }; - pixelDataMatrix.dataSize2 = (unsigned int)(pixelDataMatrix.data.size()); - pixelDataMatrix.dataSize1 = (unsigned int)((pixelDataMatrix.data.size() > 0) ? pixelDataMatrix.data[0].size() : 0); - out << " Data Size 1: " << pixelDataMatrix.dataSize1 << endl; - out << " Data Size 2: " << pixelDataMatrix.dataSize2 << endl; - array_output_count = 0; - for (unsigned int i1 = 0; i1 < pixelDataMatrix.data.size(); i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - for (unsigned int i2 = 0; i2 < pixelDataMatrix.data[i1].size(); i2++) { + for (unsigned int i2 = 0; i2 < pixelData[i1].size(); i2++) { if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { break; }; - out << " Data[" << i2 << "]: " << pixelDataMatrix.data[i1][i2] << endl; + out << " Pixel Data[" << i2 << "]: " << pixelData[i1][i2] << endl; array_output_count++; }; }; @@ -354,14 +342,8 @@ void NiPixelData::Reset( int new_width, int new_height, PixelFormat px_fmt ) { } //Delete any data that was previously held - pixelData.data.clear(); - //if ( pixelData.data != NULL ) { - // delete [] pixelData.data; - // pixelData.data = NULL; - // pixelData.dataSize = 0; - //} - - //pixelData.dataSize = 0; + pixelData.clear(); + mipmaps.resize(1); @@ -438,18 +420,18 @@ vector<Color4> NiPixelData::GetColors() const { switch(pixelFormat) { case PX_FMT_RGB8: for ( unsigned int i = 0; i < pixels.size(); ++i ) { - pixels[i].r = float(pixelData.data[i * 3]) / 255.0f; - pixels[i].g = float(pixelData.data[i * 3 + 1]) / 255.0f; - pixels[i].b = float(pixelData.data[i * 3 + 2]) / 255.0f; + pixels[i].r = float(pixelData[0][i * 3]) / 255.0f; + pixels[i].g = float(pixelData[0][i * 3 + 1]) / 255.0f; + pixels[i].b = float(pixelData[0][i * 3 + 2]) / 255.0f; pixels[i].a = 1.0f; } break; case PX_FMT_RGBA8: for ( unsigned int i = 0; i < pixels.size(); ++i ) { - pixels[i].r = float(pixelData.data[i * 4]) / 255.0f; - pixels[i].g = float(pixelData.data[i * 4 + 1]) / 255.0f; - pixels[i].b = float(pixelData.data[i * 4 + 2]) / 255.0f; - pixels[i].a = float(pixelData.data[i * 4 + 3]) / 255.0f; + pixels[i].r = float(pixelData[0][i * 4]) / 255.0f; + pixels[i].g = float(pixelData[0][i * 4 + 1]) / 255.0f; + pixels[i].b = float(pixelData[0][i * 4 + 2]) / 255.0f; + pixels[i].a = float(pixelData[0][i * 4 + 3]) / 255.0f; } break; default: @@ -506,15 +488,8 @@ void NiPixelData::SetColors( const vector<Color4> & new_pixels, bool generate_mi } } - //Allocate space to store mipmaps - //if ( pixelData.data != NULL ) { - // delete [] pixelData.data; - //} - - //pixelData.dataSize = size * bitsPerPixel / 8; - //pixelData.data = new byte[pixelData.dataSize]; - - pixelData.data.resize( size * bitsPerPixel / 8 ); + pixelData.resize(1); + pixelData[0].resize( size * bitsPerPixel / 8 ); //Copy pixels to Color4 C array Color4 * tmp_image = new Color4[new_pixels.size()]; @@ -594,7 +569,7 @@ void NiPixelData::SetColors( const vector<Color4> & new_pixels, bool generate_mi #endif //Start at offset - byte * map = &pixelData.data[mipmaps[i].offset]; + byte * map = &pixelData[0][mipmaps[i].offset]; switch(pixelFormat) { case PX_FMT_RGB8: diff --git a/src/obj/NiScreenElements.cpp b/src/obj/NiScreenElements.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f631ac021257b6779a392e41295467dd0d3e854 --- /dev/null +++ b/src/obj/NiScreenElements.cpp @@ -0,0 +1,102 @@ +/* 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/NiScreenElements.h" +using namespace Niflib; + +//Definition of TYPE constant +const Type NiScreenElements::TYPE("NiScreenElements", &NiTriShape::TYPE ); + +NiScreenElements::NiScreenElements() { + //--BEGIN CONSTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +NiScreenElements::~NiScreenElements() { + //--BEGIN DESTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +const Type & NiScreenElements::GetType() const { + return TYPE; +} + +NiObject * NiScreenElements::Create() { + return new NiScreenElements; +} + +void NiScreenElements::Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ) { + //--BEGIN PRE-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiTriShape::Read( in, link_stack, info ); + + //--BEGIN POST-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void NiScreenElements::Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, const NifInfo & info ) const { + //--BEGIN PRE-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiTriShape::Write( out, link_map, info ); + + //--BEGIN POST-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::string NiScreenElements::asString( bool verbose ) const { + //--BEGIN PRE-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// + + stringstream out; + unsigned int array_output_count = 0; + out << NiTriShape::asString(); + return out.str(); + + //--BEGIN POST-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void NiScreenElements::FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, const NifInfo & info ) { + //--BEGIN PRE-FIXLINKS CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiTriShape::FixLinks( objects, link_stack, info ); + + //--BEGIN POST-FIXLINKS CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::list<NiObjectRef> NiScreenElements::GetRefs() const { + list<Ref<NiObject> > refs; + refs = NiTriShape::GetRefs(); + return refs; +} + +//--BEGIN MISC CUSTOM CODE--// + +//--END CUSTOM CODE--// diff --git a/src/obj/NiScreenElementsData.cpp b/src/obj/NiScreenElementsData.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d7acb2e74ce7b82af46cc70fc4f89930e59db144 --- /dev/null +++ b/src/obj/NiScreenElementsData.cpp @@ -0,0 +1,169 @@ +/* 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/NiScreenElementsData.h" +#include "../../include/gen/Polygon.h" +using namespace Niflib; + +//Definition of TYPE constant +const Type NiScreenElementsData::TYPE("NiScreenElementsData", &NiTriShapeData::TYPE ); + +NiScreenElementsData::NiScreenElementsData() : maxPolygons((unsigned short)0), unknownUshort1((unsigned short)1), numPolygons((unsigned short)0), usedVertices((unsigned short)0), unknownUshort2((unsigned short)1), usedTrianglePoints((unsigned short)0), unknownUshort3((unsigned short)1) { + //--BEGIN CONSTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +NiScreenElementsData::~NiScreenElementsData() { + //--BEGIN DESTRUCTOR CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +const Type & NiScreenElementsData::GetType() const { + return TYPE; +} + +NiObject * NiScreenElementsData::Create() { + return new NiScreenElementsData; +} + +void NiScreenElementsData::Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ) { + //--BEGIN PRE-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiTriShapeData::Read( in, link_stack, info ); + NifStream( maxPolygons, in, info ); + polygons.resize(maxPolygons); + for (unsigned int i1 = 0; i1 < polygons.size(); i1++) { + NifStream( polygons[i1].numVertices, in, info ); + NifStream( polygons[i1].vertexOffset, in, info ); + NifStream( polygons[i1].numTriangles, in, info ); + NifStream( polygons[i1].triangleOffset, in, info ); + }; + polygonIndices.resize(maxPolygons); + for (unsigned int i1 = 0; i1 < polygonIndices.size(); i1++) { + NifStream( polygonIndices[i1], in, info ); + }; + NifStream( unknownUshort1, in, info ); + NifStream( numPolygons, in, info ); + NifStream( usedVertices, in, info ); + NifStream( unknownUshort2, in, info ); + NifStream( usedTrianglePoints, in, info ); + NifStream( unknownUshort3, in, info ); + + //--BEGIN POST-READ CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void NiScreenElementsData::Write( ostream& out, const map<NiObjectRef,unsigned int> & link_map, const NifInfo & info ) const { + //--BEGIN PRE-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiTriShapeData::Write( out, link_map, info ); + maxPolygons = (unsigned short)(polygons.size()); + NifStream( maxPolygons, out, info ); + for (unsigned int i1 = 0; i1 < polygons.size(); i1++) { + NifStream( polygons[i1].numVertices, out, info ); + NifStream( polygons[i1].vertexOffset, out, info ); + NifStream( polygons[i1].numTriangles, out, info ); + NifStream( polygons[i1].triangleOffset, out, info ); + }; + for (unsigned int i1 = 0; i1 < polygonIndices.size(); i1++) { + NifStream( polygonIndices[i1], out, info ); + }; + NifStream( unknownUshort1, out, info ); + NifStream( numPolygons, out, info ); + NifStream( usedVertices, out, info ); + NifStream( unknownUshort2, out, info ); + NifStream( usedTrianglePoints, out, info ); + NifStream( unknownUshort3, out, info ); + + //--BEGIN POST-WRITE CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::string NiScreenElementsData::asString( bool verbose ) const { + //--BEGIN PRE-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// + + stringstream out; + unsigned int array_output_count = 0; + out << NiTriShapeData::asString(); + maxPolygons = (unsigned short)(polygons.size()); + out << " Max Polygons: " << maxPolygons << endl; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < polygons.size(); i1++) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; + break; + }; + out << " Num Vertices: " << polygons[i1].numVertices << endl; + out << " Vertex Offset: " << polygons[i1].vertexOffset << endl; + out << " Num Triangles: " << polygons[i1].numTriangles << endl; + out << " Triangle Offset: " << polygons[i1].triangleOffset << endl; + }; + array_output_count = 0; + for (unsigned int i1 = 0; i1 < polygonIndices.size(); 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 << " Polygon Indices[" << i1 << "]: " << polygonIndices[i1] << endl; + array_output_count++; + }; + out << " Unknown UShort 1: " << unknownUshort1 << endl; + out << " Num Polygons: " << numPolygons << endl; + out << " Used Vertices: " << usedVertices << endl; + out << " Unknown UShort 2: " << unknownUshort2 << endl; + out << " Used Triangle Points: " << usedTrianglePoints << endl; + out << " Unknown UShort 3: " << unknownUshort3 << endl; + return out.str(); + + //--BEGIN POST-STRING CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +void NiScreenElementsData::FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, const NifInfo & info ) { + //--BEGIN PRE-FIXLINKS CUSTOM CODE--// + + //--END CUSTOM CODE--// + + NiTriShapeData::FixLinks( objects, link_stack, info ); + + //--BEGIN POST-FIXLINKS CUSTOM CODE--// + + //--END CUSTOM CODE--// +} + +std::list<NiObjectRef> NiScreenElementsData::GetRefs() const { + list<Ref<NiObject> > refs; + refs = NiTriShapeData::GetRefs(); + return refs; +} + +//--BEGIN MISC CUSTOM CODE--// + +//--END CUSTOM CODE--// diff --git a/src/obj/NiSourceTexture.cpp b/src/obj/NiSourceTexture.cpp index 4705e5f8a35636d200e29c78c21e29beb1df7a3d..b06b5eb51ae779486cdf6f97c68b4bde27106f54 100644 --- a/src/obj/NiSourceTexture.cpp +++ b/src/obj/NiSourceTexture.cpp @@ -15,7 +15,6 @@ 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/NiPixelData.h" using namespace Niflib; //Definition of TYPE constant @@ -181,7 +180,7 @@ void NiSourceTexture::FixLinks( const map<unsigned int,NiObjectRef> & objects, l }; }; if ( (useExternal == 0) ) { - pixelData = FixLink<NiPixelData>( objects, link_stack, info ); + pixelData = FixLink<NiObject>( objects, link_stack, info ); }; //--BEGIN POST-FIXLINKS CUSTOM CODE--// @@ -226,7 +225,7 @@ string NiSourceTexture::GetTextureFileName() const { } Ref<NiPixelData> NiSourceTexture::GetPixelData() const { - return pixelData; + return DynamicCast<NiPixelData>(pixelData); } PixelLayout NiSourceTexture::GetPixelLayout() const {