diff --git a/NIF_IO.cpp b/NIF_IO.cpp index a02bf437b0cb864efc4338d7dc2e3e48763ac863..09c4bf5780da50e5265ecea3cf333495dc093f7f 100644 --- a/NIF_IO.cpp +++ b/NIF_IO.cpp @@ -397,6 +397,19 @@ void NifStream( Matrix44 const & val, ostream& out, uint version ) { } } +//Color3 +void NifStream( Color3 & val, istream& in, uint version ) { + val.r = ReadFloat( in ); + val.g = ReadFloat( in ); + val.b = ReadFloat( in ); +}; + +void NifStream( Color3 const & val, ostream& out, uint version ) { + WriteFloat( val.r, out ); + WriteFloat( val.g, out ); + WriteFloat( val.b, out ); +}; + //Color4 void NifStream( Color4 & val, istream& in, uint version ) { val.r = ReadFloat( in ); diff --git a/NIF_IO.h b/NIF_IO.h index 3558b4b2991447cf0350183430a7c7f41608ba60..673a37b5dbc468d9f38740fa62491b564eb28e5f 100644 --- a/NIF_IO.h +++ b/NIF_IO.h @@ -303,6 +303,10 @@ void NifStream( Float4 const & val, ostream& out, uint version = 0 ); void NifStream( Matrix44 & val, istream& in, uint version = 0 ); void NifStream( Matrix44 const & val, ostream& out, uint version = 0 ); +//Color3 +void NifStream( Color3 & val, istream& in, uint version = 0 ); +void NifStream( Color3 const & val, ostream& out, uint version = 0 ); + //Color4 void NifStream( Color4 & val, istream& in, uint version = 0 ); void NifStream( Color4 const & val, ostream& out, uint version = 0 ); diff --git a/nif_math.cpp b/nif_math.cpp index 1ad11b437b6ead03ecc88ce670d48ca2c60cdb1e..cf89aed573418302ccf2747089ce5228ff01ab92 100644 --- a/nif_math.cpp +++ b/nif_math.cpp @@ -445,8 +445,12 @@ ostream & operator<<( ostream & out, Matrix44 const & val ) { return out; } +ostream & operator<<( ostream & out, Color3 const & val ) { + return out << "{R:" << setw(6) << val.r << " G:" << setw(6) << val.g << " B:" << setw(6) << val.b << "}"; +} + ostream & operator<<( ostream & out, Color4 const & val ) { - return out << "R:" << setw(6) << val.r << " G:" << setw(6) << val.g << " B:" << setw(6) << val.b << " A:" << setw(6) << val.a << "}"; + return out << "{R:" << setw(6) << val.r << " G:" << setw(6) << val.g << " B:" << setw(6) << val.b << " A:" << setw(6) << val.a << "}"; } ostream & operator<<( ostream & out, Quaternion const & val ) { diff --git a/nif_math.h b/nif_math.h index 950eced1d605ce5912e06d7f72ebb2a876e096e9..b5a2c57320294ee214c5b814ccca803377c784b0 100644 --- a/nif_math.h +++ b/nif_math.h @@ -745,6 +745,40 @@ struct Matrix44 { } }; +/*! Stores a color along with alpha translucency */ +struct NIFLIB_API Color3 { + float r; /*!< The red component of this color. Should be between 0.0f and 1.0f. */ + float g; /*!< The green component of this color. Should be between 0.0f and 1.0f. */ + float b; /*!< The blue component of this color. Should be between 0.0f and 1.0f. */ + + /*! Default constructor */ + Color3() {} + + /*! This constructor can be used to set all values in this structure during initialization + * \param r The value to set the red component of this color to. Should be between 0.0f and 1.0f. + * \param g The value to set the green component of this color to. Should be between 0.0f and 1.0f. + * \param b The value to set the blue component of this color to. Should be between 0.0f and 1.0f. + * \param a The value to set the alpha translucency component of this color to. Should be between 0.0f and 1.0f. + */ + Color3(float r, float g, float b) { + this->r = r; + this->g = g; + this->b = b; + } + + /*! This function can be used to set all values in the structure at the same time. + * \param r The value to set the red component of this color to. Should be between 0.0f and 1.0f. + * \param g The value to set the green component of this color to. Should be between 0.0f and 1.0f. + * \param b The value to set the blue component of this color to. Should be between 0.0f and 1.0f. + * \param a The value to set the alpha translucency component of this color to. Should be between 0.0f and 1.0f. + */ + void Set(float r, float g, float b) { + this->r = r; + this->g = g; + this->b = b; + } +}; + /*! Stores a color along with alpha translucency */ struct NIFLIB_API Color4 { float r; /*!< The red component of this color. Should be between 0.0f and 1.0f. */ @@ -840,9 +874,8 @@ ostream & operator<<( ostream & out, Matrix22 const & val ); ostream & operator<<( ostream & out, Float3 const & val ); ostream & operator<<( ostream & out, Matrix33 const & val ); ostream & operator<<( ostream & out, Float4 const & val ); +ostream & operator<<( ostream & out, Color3 const & val ); ostream & operator<<( ostream & out, Color4 const & val ); ostream & operator<<( ostream & out, Quaternion const & val ); -typedef Float3 Color3; - #endif diff --git a/niflib.vcproj b/niflib.vcproj index 6aa18a8efb0f4ad0b91b24848628cb182cfd4167..668b8e289bcd4cdd179606686e4ec9cf9bb6c9c0 100644 --- a/niflib.vcproj +++ b/niflib.vcproj @@ -4,6 +4,7 @@ Version="8.00" Name="NIFlib" ProjectGUID="{19FD8EE6-79CC-4BAC-9744-D9573BE47C7E}" + RootNamespace="NIFlib" Keyword="Win32Proj" > <Platforms> @@ -105,7 +106,8 @@ <Tool Name="VCCLCompilerTool" AdditionalOptions="/FI"pch.h"" - Optimization="3" + Optimization="0" + WholeProgramOptimization="false" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" UsePrecompiledHeader="2" diff --git a/obj/NiAVObject.cpp b/obj/NiAVObject.cpp index 79ebeacbef00831aa6bc2142e630b3c1032d90b8..6a1fb5b02406af6f09c35e0a5aed5ef218b7957b 100644 --- a/obj/NiAVObject.cpp +++ b/obj/NiAVObject.cpp @@ -139,4 +139,44 @@ Ref<NiProperty> NiAVObject::GetPropertyByType( const Type & compare_to ) { } //No matching properties found, return NULL return NULL; +} + +ushort NiAVObject::GetFlags() const { + return flags; +} + +void NiAVObject::SetFlags( ushort n ) { + flags = n; +} + +Matrix33 NiAVObject::GetLocalRotation() const { + return rotation; +} + +void NiAVObject::SetLocalRotation( const Matrix33 & n ) { + rotation = n; +} + +Vector3 NiAVObject::GetLocalTranslation() const { + return translation; +} + +void NiAVObject::SetLocalTranslation( const Vector3 & n ) { + translation = n; +} + +float NiAVObject::GetLocalScale() const { + return scale; +} + +void NiAVObject::SetLocalScale( float n ) { + scale = n; +} + +Vector3 NiAVObject::GetVelocity() const { + return velocity; +} + +void NiAVObject::SetVelocity( const Vector3 & n ) { + velocity = n; } \ No newline at end of file diff --git a/obj/NiAVObject.h b/obj/NiAVObject.h index 53550da7e2523f3e54b78ea5dc024975c509f0e8..863cdf373d45676da9e0708676553c708fdcc6d2 100644 --- a/obj/NiAVObject.h +++ b/obj/NiAVObject.h @@ -83,6 +83,21 @@ public: vector< Ref<NiProperty> > GetProperties() const; Ref<NiProperty> GetPropertyByType( const Type & compare_to ); + ushort GetFlags() const; + void SetFlags( ushort n ); + + Matrix33 GetLocalRotation() const; + void SetLocalRotation( const Matrix33 & n ); + + Vector3 GetLocalTranslation() const; + void SetLocalTranslation( const Vector3 & n ); + + float GetLocalScale() const; + void SetLocalScale( float n ); + + Vector3 GetVelocity() const; + void SetVelocity( const Vector3 & n ); + private: NI_A_V_OBJECT_MEMBERS diff --git a/obj/NiAlphaProperty.cpp b/obj/NiAlphaProperty.cpp index e9d0d5f892e8b3deb095283a99c96509c0f3e498..8a3ac9c8b5c012fb418b800f7dde3ec813a52ce5 100644 --- a/obj/NiAlphaProperty.cpp +++ b/obj/NiAlphaProperty.cpp @@ -34,3 +34,19 @@ const Type & NiAlphaProperty::GetType() const { return TYPE; }; +ushort NiAlphaProperty::GetFlags() const { + return flags; +} + +void NiAlphaProperty::SetFlags( ushort n ) { + flags = n; +} + +byte NiAlphaProperty::GetAlphaTestThreshold() const { + return threshold; +} + +void NiAlphaProperty::SetAlphaTestThreshold( byte n ) { + threshold = n; +} + diff --git a/obj/NiAlphaProperty.h b/obj/NiAlphaProperty.h index dbbab41cf5f9155bddc5e81a8a071053f67ee17e..caceab6bf83217857fffed496d4c27c975c9a37b 100644 --- a/obj/NiAlphaProperty.h +++ b/obj/NiAlphaProperty.h @@ -27,6 +27,12 @@ public: virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version ); virtual list<NiObjectRef> GetRefs() const; virtual const Type & GetType() const; + + ushort GetFlags() const; + void SetFlags( ushort n ); + + byte GetAlphaTestThreshold() const; + void SetAlphaTestThreshold( byte n ); protected: NI_ALPHA_PROPERTY_MEMBERS }; diff --git a/obj/NiMaterialProperty.cpp b/obj/NiMaterialProperty.cpp index 1d5df1d6ecbc9a2e13463185b328fa12707b772f..8c9b07ccef3b20601e5abb325168b5248abaa526 100644 --- a/obj/NiMaterialProperty.cpp +++ b/obj/NiMaterialProperty.cpp @@ -34,3 +34,58 @@ const Type & NiMaterialProperty::GetType() const { return TYPE; }; +ushort NiMaterialProperty::GetFlags() const { + return flags; +} + +void NiMaterialProperty::SetFlags( ushort n ) { + flags = n; +} + +float NiMaterialProperty::GetTransparency() const { + return alpha; +} + +void NiMaterialProperty::SetTransparency( float n ) { + alpha = n; +} + +float NiMaterialProperty::GetGlossiness() const { + return glossiness; +} + +void NiMaterialProperty::SetGlossiness( float n ) { + glossiness = n; +} + +Color3 NiMaterialProperty::GetAmbientColor() const { + return ambientColor; +} + +void NiMaterialProperty::SetAmbientColor( const Color3 & n ) { + ambientColor = n; +} + +Color3 NiMaterialProperty::GetDiffuseColor() const { + return diffuseColor; +} + +void NiMaterialProperty::SetDiffuseColor( const Color3 & n ) { + diffuseColor = n; +} + +Color3 NiMaterialProperty::GetEmissiveColor() const { + return emissiveColor; +} + +void NiMaterialProperty::SetEmissiveColor( const Color3 & n ) { + emissiveColor = n; +} + +Color3 NiMaterialProperty::GetSpecularColor() const { + return specularColor; +} + +void NiMaterialProperty::SetSpecularColor( const Color3 & n ) { + specularColor = n; +} diff --git a/obj/NiMaterialProperty.h b/obj/NiMaterialProperty.h index 0706b2113bd5f17ac1aee46dbbc6d8bb5e3ea3b7..db8938c4328eca981dacf719c740669d0b5159b5 100644 --- a/obj/NiMaterialProperty.h +++ b/obj/NiMaterialProperty.h @@ -27,6 +27,29 @@ public: virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version ); virtual list<NiObjectRef> GetRefs() const; virtual const Type & GetType() const; + + ushort GetFlags() const; + void SetFlags( ushort n ); + + float GetTransparency() const; + void SetTransparency( float n ); + + float GetGlossiness() const; + void SetGlossiness( float n ); + + Color3 GetAmbientColor() const; + void SetAmbientColor( const Color3 & n ); + + Color3 GetDiffuseColor() const; + void SetDiffuseColor( const Color3 & n ); + + Color3 GetEmissiveColor() const; + void SetEmissiveColor( const Color3 & n ); + + Color3 GetSpecularColor() const; + void SetSpecularColor( const Color3 & n ); + + protected: NI_MATERIAL_PROPERTY_MEMBERS }; diff --git a/obj/NiMorphData.cpp b/obj/NiMorphData.cpp index 99bc06dc98a89b092aac37a54fc255a7c65a237f..7398d4a5dcf6137f140ce2559aa199c7d93876f5 100644 --- a/obj/NiMorphData.cpp +++ b/obj/NiMorphData.cpp @@ -52,7 +52,7 @@ int NiMorphData::GetMorphCount() const { } void NiMorphData::SetMorphCount( int n ) { - int old_size = morphs.size(); + uint old_size = uint(morphs.size()); morphs.resize( n ); //Make sure any new vertex groups are the right size diff --git a/obj/NiSourceTexture.cpp b/obj/NiSourceTexture.cpp index dd950235fed6152997456535004655447b42541b..4bfd2ceeb78dbf50abe4e8dba57bc9d1873391b0 100644 --- a/obj/NiSourceTexture.cpp +++ b/obj/NiSourceTexture.cpp @@ -36,3 +36,77 @@ const Type & NiSourceTexture::GetType() const { return TYPE; }; +bool NiSourceTexture::IsTextureExternal () { + return ( useExternal != 0 ); +} + +void NiSourceTexture::SetExternalTexture( string file_name, const Ref<NiObject> & unk_link ) { + useExternal = 0; + pixelData = NULL; + this->originalFileName_.clear(); + + fileName = file_name; + unknownLink = unk_link; +} + + +void NiSourceTexture::SetInternalTexture( byte unk_byte, string original_file_name, const Ref<NiPixelData> & pixel_data ) { + useExternal = 1; + fileName.clear(); + + //TODO: Fix name problem with Unknown Byte in XML + unknownByte = unk_byte; + originalFileName_ = original_file_name; + pixelData = pixel_data; +} + +string NiSourceTexture::GetExternalFileName() const { + return fileName; +} + +Ref<NiObject> NiSourceTexture::GetExternalUnknownLink() const { + return unknownLink; +} + +byte NiSourceTexture::GetInternalUnknownByte() const { + return unknownByte; +} + +string NiSourceTexture::GetInternalOriginalFileName() const { + return originalFileName_; +} + +Ref<NiPixelData> NiSourceTexture::GetInternalPixelData() const { + return pixelData; +} + +PixelLayout NiSourceTexture::GetPixelLayout() const { + return pixelLayout; +} + +void NiSourceTexture::SetPixelLayout( PixelLayout n ) { + pixelLayout = n; +} + +MipMapFormat NiSourceTexture::GetMipMapFormat() const { + return useMipmaps; +} + +void NiSourceTexture::SetMipMapFormat( MipMapFormat n ) { + useMipmaps = n; +} + +AlphaFormat NiSourceTexture::GetAlphaFormat() const { + return alphaFormat; +} + +void NiSourceTexture::SetAlphaFormat( AlphaFormat n ) { + alphaFormat = n; +} + +//TODO: Fix name problem with Unknown Byte in XML +//byte NiSourceTexture::GetUnknownByte2() const; +//SNiSourceTexture::etUnknownByte2( byte n ); +// +//byte NiSourceTexture::GetUnknownByte3() const; +//NiSourceTexture::SetUnknownByte3( byte n ); \ No newline at end of file diff --git a/obj/NiSourceTexture.h b/obj/NiSourceTexture.h index e890233bdf5d65c8a5d3acfe8d4db3defaa6fe29..646b4b29880cf389159b00f01847230b5e6c708a 100644 --- a/obj/NiSourceTexture.h +++ b/obj/NiSourceTexture.h @@ -32,6 +32,35 @@ public: virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version ); virtual list<NiObjectRef> GetRefs() const; virtual const Type & GetType() const; + + bool IsTextureExternal (); + + void SetExternalTexture( string file_name, const Ref<NiObject> & unk_link ); + + void SetInternalTexture( byte unk_byte, string original_file_name, const Ref<NiPixelData> & pixel_data ); + + string GetExternalFileName() const; + Ref<NiObject> GetExternalUnknownLink() const; + + byte GetInternalUnknownByte() const; + string GetInternalOriginalFileName() const; + Ref<NiPixelData> GetInternalPixelData() const; + + PixelLayout GetPixelLayout() const; + void SetPixelLayout( PixelLayout n ); + + MipMapFormat GetMipMapFormat() const; + void SetMipMapFormat( MipMapFormat n ); + + AlphaFormat GetAlphaFormat() const; + void SetAlphaFormat( AlphaFormat n ); + + //TODO: Fix name problem with Unknown Byte in XML + //byte GetUnknownByte2() const; + //SetUnknownByte2( byte n ); + + //byte GetUnknownByte3() const; + //SetUnknownByte3( byte n ); protected: NI_SOURCE_TEXTURE_MEMBERS }; diff --git a/obj/NiTexturingProperty.cpp b/obj/NiTexturingProperty.cpp index c95155682b4f4b5459867e167e380a9abba261d3..808325ea372fab48025a78317aa16342b54bf03a 100644 --- a/obj/NiTexturingProperty.cpp +++ b/obj/NiTexturingProperty.cpp @@ -212,6 +212,8 @@ bool NiTexturingProperty::HasTexture( int n ) const { return hasDecal0Texture; case DECAL_1_MAP: return hasDecal1Texture; + default: + throw("You have specified an invalid texture type."); }; } diff --git a/obj/NiTriBasedGeom.cpp b/obj/NiTriBasedGeom.cpp index cfb0a011e20ce3f40398505a212b18633175d722..505cd7bd39c991abb9d0b159c06f9158b8cd786c 100644 --- a/obj/NiTriBasedGeom.cpp +++ b/obj/NiTriBasedGeom.cpp @@ -37,3 +37,33 @@ const Type & NiTriBasedGeom::GetType() const { return TYPE; }; +Ref<NiTriBasedGeomData> NiTriBasedGeom::GetData() const { + return data; +} + +void NiTriBasedGeom::SetData( const Ref<NiTriBasedGeomData> & n ) { + data = n; +} + +Ref<NiObject> NiTriBasedGeom::GetUnknownLink() const { + return unknownLink; +} + +void NiTriBasedGeom::SetUnknownLink( const Ref<NiObject> & n ) { + unknownLink = n; +} + +string NiTriBasedGeom::GetShader() const { + return shaderName; +} + +void NiTriBasedGeom::SetShader( const string & n ) { + //Check if name is blank, if so clear shader + if ( n.size() == 0 ) { + hasShader = false; + shaderName.clear(); + } else { + shaderName = n; + } +} + \ No newline at end of file diff --git a/obj/NiTriBasedGeom.h b/obj/NiTriBasedGeom.h index 626528d555d4672676eac92969112439b3cf4c82..85034e38a902325a6e71c15f3b90aab20835b022 100644 --- a/obj/NiTriBasedGeom.h +++ b/obj/NiTriBasedGeom.h @@ -33,6 +33,18 @@ public: virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version ); virtual list<NiObjectRef> GetRefs() const; virtual const Type & GetType() const; + + //TODO: Handle attatchment of SkinInstance with new skinning API + + Ref<NiTriBasedGeomData> GetData() const; + void SetData( const Ref<NiTriBasedGeomData> & n ); + + Ref<NiObject> GetUnknownLink() const; + void SetUnknownLink( const Ref<NiObject> & n ); + + string GetShader() const; + void SetShader( const string & n ); + protected: NI_TRI_BASED_GEOM_MEMBERS };