From c6a79f93549a865f6bd2ce5adbf7aae02b37092f Mon Sep 17 00:00:00 2001 From: Alecu100 <lui_alecu@yahoo.co.uk> Date: Mon, 30 Jan 2012 10:20:43 +0200 Subject: [PATCH] added support for skyrim and added some new ways to check the user version of a nif file to check if it's a skyrim file. --- include/niflib.h | 8 ++++++++ include/obj/BSShaderTextureSet.h | 8 ++++---- include/obj/NiGeometry.h | 12 ++++++++++++ src/niflib.cpp | 15 +++++++++++++++ src/obj/BSShaderTextureSet.cpp | 8 ++++---- src/obj/NiGeometry.cpp | 9 +++++++++ 6 files changed, 52 insertions(+), 8 deletions(-) diff --git a/include/niflib.h b/include/niflib.h index 70715385..1b8edc6f 100644 --- a/include/niflib.h +++ b/include/niflib.h @@ -107,6 +107,14 @@ enum ExportOptions { */ NIFLIB_API unsigned int GetNifVersion( string const & file_name ); +/*! + * Returns the nif info without reading the entire file which includes the nif version, + * the nif user version1 and the nif user version2 + * \param The full path to the nif file which includes the file name and the location of the nif file + * \return The nif info structure which contains the nif header info + */ +NIFLIB_API NifInfo ReadHeaderInfo( string const & file_name ); + /*! * Return the missing link stack with objects replaced from nif trees at specified root. */ diff --git a/include/obj/BSShaderTextureSet.h b/include/obj/BSShaderTextureSet.h index 6b12d499..3156127a 100644 --- a/include/obj/BSShaderTextureSet.h +++ b/include/obj/BSShaderTextureSet.h @@ -57,20 +57,20 @@ public: // Textures // \return The current value. - vector<string > GetTextures() const; + NIFLIB_API vector<string > getTextures() const; // Textures // \param[in] value The new value. - void SetTextures( const vector<string >& value ); + NIFLIB_API void setTextures( const vector<string >& value ); // Textures // \return The current value. - string GetTexture( size_t i ) const; + NIFLIB_API string getTexture( size_t i ) const; // Textures // \param[in] i Index of texture to set // \param[in] value The new value. - void SetTexture( size_t i, const string& value); + NIFLIB_API void setTexture( size_t i, const string& value); //--END CUSTOM CODE--// protected: diff --git a/include/obj/NiGeometry.h b/include/obj/NiGeometry.h index 8a2f23c6..02edf9cb 100644 --- a/include/obj/NiGeometry.h +++ b/include/obj/NiGeometry.h @@ -166,6 +166,18 @@ public: // \return The current value. NIFLIB_API bool HasShader() const; + /* + * Returns the array of the only 2 properties that are specific to Bethesda + * \return Returns the array of the 2 properties + */ + NIFLIB_API array<2,Ref<NiProperty > > getBsProperties(); + + /* + * Sets the array of the only 2 properties that are specific to Bethesda + * \param[in] The new array of properties + */ + NIFLIB_API void setBsProperties( array<2, Ref<NiProperty>> value); + //--END CUSTOM CODE--// protected: /*! Data index (NiTriShapeData/NiTriStripData). */ diff --git a/src/niflib.cpp b/src/niflib.cpp index 673227db..fb579069 100644 --- a/src/niflib.cpp +++ b/src/niflib.cpp @@ -114,6 +114,21 @@ unsigned int GetNifVersion( string const & file_name ) { return info.version; } + +NifInfo ReadHeaderInfo( string const & file_name ) { + //--Open File--// + ifstream in( file_name.c_str(), ifstream::binary ); + + //--Read Header Info--// + + Header nif_header; + NifInfo info; + info = nif_header.Read(in); + + return info; +} + + vector<NiObjectRef> ReadNifList( string const & file_name, NifInfo * info ) { //--Open File--// diff --git a/src/obj/BSShaderTextureSet.cpp b/src/obj/BSShaderTextureSet.cpp index 895452f7..66144f6a 100644 --- a/src/obj/BSShaderTextureSet.cpp +++ b/src/obj/BSShaderTextureSet.cpp @@ -129,21 +129,21 @@ std::list<NiObject *> BSShaderTextureSet::GetPtrs() const { //--BEGIN MISC CUSTOM CODE--// -vector<string > BSShaderTextureSet::GetTextures() const { +vector<string > BSShaderTextureSet::getTextures() const { return textures; } -void BSShaderTextureSet::SetTextures( const vector<string >& value ) { +void BSShaderTextureSet::setTextures( const vector<string >& value ) { textures = value; } -string BSShaderTextureSet::GetTexture(size_t i) const { +string BSShaderTextureSet::getTexture(size_t i) const { if (i >= textures.size()) throw runtime_error("Invalid Texture Index specified"); return textures[i]; } -void BSShaderTextureSet::SetTexture( size_t i, const string& value) { +void BSShaderTextureSet::setTexture( size_t i, const string& value) { if (i >= textures.size()) textures.resize(i+1); textures[i] = value; diff --git a/src/obj/NiGeometry.cpp b/src/obj/NiGeometry.cpp index e9c29623..00cc9c54 100644 --- a/src/obj/NiGeometry.cpp +++ b/src/obj/NiGeometry.cpp @@ -633,5 +633,14 @@ bool NiGeometry::HasShader() const { return hasShader; } +array<2,Ref<NiProperty > > Niflib::NiGeometry::getBsProperties() { + return this->bsProperties; +} + +void Niflib::NiGeometry::setBsProperties( array<2, Ref<NiProperty>> value ) { + this->bsProperties = value; +} //--END CUSTOM CODE--// + + -- GitLab