diff --git a/include/ComplexShape.h b/include/ComplexShape.h index 416d7cebf7d95f1dc290e082cb90f9e2de698abd..0948c992c30f6b0c3492b459d96f9a047b9b9541 100644 --- a/include/ComplexShape.h +++ b/include/ComplexShape.h @@ -41,9 +41,9 @@ public: */ struct SkinInfluence { /*! Constructor */ - SkinInfluence() : influenceIndex(CS_NO_INDEX) {} + NIFLIB_API SkinInfluence() : influenceIndex(CS_NO_INDEX) {} /*! Destructor */ - ~SkinInfluence() {} + NIFLIB_API ~SkinInfluence() {} /*! * Index into the ComplexShape::skinInfluences array of the bone * influence for this skin weight. @@ -73,9 +73,9 @@ public: */ struct TexCoordIndex { /*! Constructor */ - TexCoordIndex() : texCoordSetIndex(CS_NO_INDEX), texCoordIndex(CS_NO_INDEX) {} + NIFLIB_API TexCoordIndex() : texCoordSetIndex(CS_NO_INDEX), texCoordIndex(CS_NO_INDEX) {} /*! Destructor */ - ~TexCoordIndex() {} + NIFLIB_API ~TexCoordIndex() {} /*! * Index into the ComplexShape::texCoordSets array of texture * coordinate sets. @@ -97,9 +97,9 @@ public: */ struct ComplexPoint { /*! Constructor */ - ComplexPoint() : vertexIndex(CS_NO_INDEX), normalIndex(CS_NO_INDEX), colorIndex(CS_NO_INDEX) {} + NIFLIB_API ComplexPoint() : vertexIndex(CS_NO_INDEX), normalIndex(CS_NO_INDEX), colorIndex(CS_NO_INDEX) {} /*! Destructor */ - ~ComplexPoint() {} + NIFLIB_API ~ComplexPoint() {} /*! * Index into the ComplexShape::vertices array which stores the * position and any associated skin weights for this point. @@ -131,9 +131,9 @@ public: */ struct ComplexFace { /*! Constructor */ - ComplexFace() : propGroupIndex(CS_NO_INDEX) {} + NIFLIB_API ComplexFace() : propGroupIndex(CS_NO_INDEX) {} /*! Destructor */ - ~ComplexFace() {} + NIFLIB_API ~ComplexFace() {} /*! A list of points which make up this polygon */ vector<ComplexPoint> points; /*! @@ -172,7 +172,7 @@ public: * information. * \return A referene to the root NiAVObject that was created. */ - Ref<NiAVObject> Split( + NIFLIB_API Ref<NiAVObject> Split( Ref<NiNode> & parent, Matrix44 & transform, int max_bones_per_partition = 4, @@ -188,32 +188,32 @@ public: * or a NiNode that is a split mesh proxy. * \sa NiNode::IsSplitMeshProxy */ - void Merge( const Ref<NiAVObject> & root ); + NIFLIB_API void Merge( const Ref<NiAVObject> & root ); /* * Clears out all the data stored in this ComplexShape */ - void Clear(); + NIFLIB_API void Clear(); //Setters - void SetName( const string & n ); - void SetVertices( const vector<WeightedVertex> & n ); - void SetColors( const vector<Color4> & n ); - void SetNormals( const vector<Vector3> & n ); - void SetTexCoordSets( const vector<TexCoordSet> & n ); - void SetFaces( const vector<ComplexFace> & n ); - void SetPropGroups( const vector< vector< Ref<NiProperty> > > & n ); - void SetSkinInfluences( const vector< Ref<NiNode> > & n ); + NIFLIB_API void SetName( const string & n ); + NIFLIB_API void SetVertices( const vector<WeightedVertex> & n ); + NIFLIB_API void SetColors( const vector<Color4> & n ); + NIFLIB_API void SetNormals( const vector<Vector3> & n ); + NIFLIB_API void SetTexCoordSets( const vector<TexCoordSet> & n ); + NIFLIB_API void SetFaces( const vector<ComplexFace> & n ); + NIFLIB_API void SetPropGroups( const vector< vector< Ref<NiProperty> > > & n ); + NIFLIB_API void SetSkinInfluences( const vector< Ref<NiNode> > & n ); //Getters - string GetName() const; - vector<WeightedVertex> GetVertices() const; - vector<Color4> GetColors() const; - vector<Vector3> GetNormals() const; - vector<TexCoordSet> GetTexCoordSets() const; - vector<ComplexFace> GetFaces() const; - vector< vector< Ref<NiProperty> > > GetPropGroups() const; - vector< Ref<NiNode> > GetSkinInfluences() const; + NIFLIB_API string GetName() const; + NIFLIB_API vector<WeightedVertex> GetVertices() const; + NIFLIB_API vector<Color4> GetColors() const; + NIFLIB_API vector<Vector3> GetNormals() const; + NIFLIB_API vector<TexCoordSet> GetTexCoordSets() const; + NIFLIB_API vector<ComplexFace> GetFaces() const; + NIFLIB_API vector< vector< Ref<NiProperty> > > GetPropGroups() const; + NIFLIB_API vector< Ref<NiNode> > GetSkinInfluences() const; private: vector<WeightedVertex> vertices; diff --git a/include/nif_math.h b/include/nif_math.h index 2a2b7ce2d45f3bf99d1b09d601708c5f0169d079..085d6a58bcb7184f9670973a02b8d8146d9b4ddc 100644 --- a/include/nif_math.h +++ b/include/nif_math.h @@ -316,8 +316,8 @@ struct NIFLIB_API Float2 { /*! Stores a 2 by 2 matrix used for bump maps. */ struct Matrix22 { - /*! The 2x2 identity matrix */ - static const Matrix22 IDENTITY; + /*! Get the 2x2 identity matrix */ + NIFLIB_API static const Matrix22 & Identity(); Float2 rows[2]; /*!< The two rows of Float2 structures which hold two floating point numbers each. */ @@ -372,6 +372,9 @@ struct Matrix22 { throw std::out_of_range("Index out of range for MatrixRow3"); return rows[n]; } +private: + /*! The 2x2 identity matrix constant */ + static const Matrix22 IDENTITY; }; /* Stores three floating point numbers. Used as a row of a Matrix33 and to store the data in attr_vector3 and attr_color3 type attributes. */ @@ -432,8 +435,8 @@ struct NIFLIB_API Float3 { /*! Stores a 3 by 3 matrix used for rotation. */ struct Matrix33 { - /*! The 3x3 identity matrix */ - static const Matrix33 IDENTITY; + /*! Returns the 3x3 identity matrix */ + NIFLIB_API static const Matrix33 & Identity(); Float3 rows[3]; /*!< The three rows of Float3 structures which hold three floating point numbers each. */ @@ -521,6 +524,10 @@ struct Matrix33 { throw std::out_of_range("Index out of range for MatrixRow3"); return rows[n]; } + +private: + /*! The 3x3 identity matrix constant*/ + static const Matrix33 IDENTITY; }; @@ -586,8 +593,8 @@ struct NIFLIB_API Float4 { /*! Stores a 4 by 4 matrix used for combined transformations. */ struct Matrix44 { - /*! The 4x4 identity matrix */ - static const Matrix44 IDENTITY; + /*! Returns the 4x4 identity matrix */ + NIFLIB_API static const Matrix44 & Identity(); Float4 rows[4]; /*!< The three rows of Float3 structures which hold three floating point numbers each. */ @@ -808,6 +815,9 @@ struct Matrix44 { throw std::out_of_range("Index out of range for Matrix44"); return rows[n]; } + + /*! The 4x4 identity matrix constant */ + static const Matrix44 IDENTITY; }; /*! Stores a color along with alpha translucency */ @@ -941,17 +951,17 @@ struct NIFLIB_API Quaternion { //These operators cause SWIG warnings #ifndef SWIG -ostream & operator<<( ostream & out, TexCoord const & val ); -ostream & operator<<( ostream & out, Triangle const & val ); -ostream & operator<<( ostream & out, Vector3 const & val ); -ostream & operator<<( ostream & out, Float2 const & val ); -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 ); +NIFLIB_API ostream & operator<<( ostream & out, TexCoord const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Triangle const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Vector3 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Float2 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Matrix22 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Float3 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Matrix33 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Float4 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Color3 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Color4 const & val ); +NIFLIB_API ostream & operator<<( ostream & out, Quaternion const & val ); #endif diff --git a/include/obj/NiAVObject.h b/include/obj/NiAVObject.h index bcd7d88f6139c9cec2efecaae211aaa1fd0de52d..94118ac89033f731806a48cf3043ed25f65c46d0 100644 --- a/include/obj/NiAVObject.h +++ b/include/obj/NiAVObject.h @@ -76,8 +76,8 @@ public: NIFLIB_API void AddProperty( const Ref<NiProperty> & obj ); NIFLIB_API void RemoveProperty( Ref<NiProperty> obj ); NIFLIB_API void ClearProperties(); - vector< Ref<NiProperty> > GetProperties() const; - Ref<NiProperty> GetPropertyByType( const Type & compare_to ); + NIFLIB_API vector< Ref<NiProperty> > GetProperties() const; + NIFLIB_API Ref<NiProperty> GetPropertyByType( const Type & compare_to ); NIFLIB_API unsigned short GetFlags() const; NIFLIB_API void SetFlags( unsigned short n ); diff --git a/include/obj/NiAlphaProperty.h b/include/obj/NiAlphaProperty.h index 7d060f1d5e4c82a0a869a2330d99b813331b8bce..bf14cb29058e2b858f01da38577e9ba29e26d4a6 100644 --- a/include/obj/NiAlphaProperty.h +++ b/include/obj/NiAlphaProperty.h @@ -32,56 +32,54 @@ public: NIFLIB_HIDDEN virtual void FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, unsigned int version, unsigned int user_version ); NIFLIB_HIDDEN virtual list<NiObjectRef> GetRefs() const; - enum BlendMode - { - BM_ONE = 0x00, - BM_ZERO = 0x01, - BM_SRC_COLOR = 0x02, - BM_ONE_MINUS_SRC_COLOR = 0x03, - BM_DST_COLOR = 0x04, - BM_ONE_MINUS_DST_COLOR = 0x05, - BM_SRC_ALPHA = 0x06, - BM_ONE_MINUS_SRC_ALPHA = 0x07, - BM_DST_ALPHA = 0x08, - BM_ONE_MINUS_DST_ALPHA = 0x08, - BM_SRC_ALPHA_SATURATE = 0x09, - }; - - enum TestMode - { - TM_ALWAYS = 0x00, - TM_LESS = 0x01, - TM_EQUAL = 0x02, - TM_LEQUAL = 0x03, - TM_GREATER = 0x04, - TM_NOTEQUAL = 0x05, - TM_GEQUAL = 0x06, - TM_NEVER = 0x07, - }; - - BlendMode GetSourceBlendMode() const; - void SetSourceBlendMode(BlendMode value); - - BlendMode GetDestBlendMode() const; - void SetDestBlendMode(BlendMode value); - - TestMode GetTestMode() const; - void SetTestMode(TestMode value); - - bool GetAlphaBlend() const; - void SetAlphaBlend(bool value); - - bool GetAlphaTest() const; - void SetAlphaTest(bool value); - - bool GetAlphaSort() const; - void SetAlphaSort(bool value); - - unsigned short GetFlags() const; - void SetFlags( unsigned short n ); - - byte GetAlphaTestThreshold() const; - void SetAlphaTestThreshold( byte n ); + enum BlendMode { + BM_ONE = 0x00, + BM_ZERO = 0x01, + BM_SRC_COLOR = 0x02, + BM_ONE_MINUS_SRC_COLOR = 0x03, + BM_DST_COLOR = 0x04, + BM_ONE_MINUS_DST_COLOR = 0x05, + BM_SRC_ALPHA = 0x06, + BM_ONE_MINUS_SRC_ALPHA = 0x07, + BM_DST_ALPHA = 0x08, + BM_ONE_MINUS_DST_ALPHA = 0x08, + BM_SRC_ALPHA_SATURATE = 0x09, + }; + + enum TestMode { + TM_ALWAYS = 0x00, + TM_LESS = 0x01, + TM_EQUAL = 0x02, + TM_LEQUAL = 0x03, + TM_GREATER = 0x04, + TM_NOTEQUAL = 0x05, + TM_GEQUAL = 0x06, + TM_NEVER = 0x07, + }; + + NIFLIB_API BlendMode GetSourceBlendMode() const; + NIFLIB_API void SetSourceBlendMode(BlendMode value); + + NIFLIB_API BlendMode GetDestBlendMode() const; + NIFLIB_API void SetDestBlendMode(BlendMode value); + + NIFLIB_API TestMode GetTestMode() const; + NIFLIB_API void SetTestMode(TestMode value); + + NIFLIB_API bool GetAlphaBlend() const; + NIFLIB_API void SetAlphaBlend(bool value); + + NIFLIB_API bool GetAlphaTest() const; + NIFLIB_API void SetAlphaTest(bool value); + + NIFLIB_API bool GetAlphaSort() const; + NIFLIB_API void SetAlphaSort(bool value); + + NIFLIB_API unsigned short GetFlags() const; + NIFLIB_API void SetFlags( unsigned short n ); + + NIFLIB_API byte GetAlphaTestThreshold() const; + NIFLIB_API void SetAlphaTestThreshold( byte n ); protected: NI_ALPHA_PROPERTY_MEMBERS private: diff --git a/include/obj/NiMaterialProperty.h b/include/obj/NiMaterialProperty.h index 918c1d4371a62941e1d5e04aa7dede047b05b274..d6bd657053d99d02fadd6ebfc32b316a6ecfc812 100644 --- a/include/obj/NiMaterialProperty.h +++ b/include/obj/NiMaterialProperty.h @@ -19,10 +19,10 @@ typedef Ref<NiMaterialProperty> NiMaterialPropertyRef; class NiMaterialProperty : public NI_MATERIAL_PROPERTY_PARENT { public: - NiMaterialProperty(); - ~NiMaterialProperty(); + NIFLIB_API NiMaterialProperty(); + NIFLIB_API ~NiMaterialProperty(); //Run-Time Type Information - static const Type & TypeConst() { return TYPE; } + NIFLIB_API static const Type & TypeConst() { return TYPE; } private: static const Type TYPE; public: diff --git a/include/obj/NiObject.h b/include/obj/NiObject.h index 0fde6c5aa76446cf657da19d21e240e892b4c636..e32fec7494e128017e5df26639f85cb260cf548b 100644 --- a/include/obj/NiObject.h +++ b/include/obj/NiObject.h @@ -68,9 +68,9 @@ public: NIFLIB_HIDDEN virtual void FixLinks( const map<unsigned int,NiObjectRef> & objects, list<unsigned int> & link_stack, unsigned int version, unsigned int user_version ) {} //Reference Counting - NIFLIB_HIDDEN void AddRef() const; //Should not be called directly - NIFLIB_HIDDEN void SubtractRef() const; //Should not be called directly - NIFLIB_HIDDEN unsigned int GetNumRefs() { return _ref_count; } + NIFLIB_API void AddRef() const; //Should not be called directly + NIFLIB_API void SubtractRef() const; //Should not be called directly + NIFLIB_API unsigned int GetNumRefs(); /*! Returns A new object that contains all the same data that this object does, * but occupies a different part of memory. The data stored in a NIF file varies diff --git a/src/nif_math.cpp b/src/nif_math.cpp index f004899a5e404e26c1408fdb9a1e59109048f51b..73d24e41f0e2ea1e845f769dfe14d62c30a03d1c 100644 --- a/src/nif_math.cpp +++ b/src/nif_math.cpp @@ -12,13 +12,25 @@ const Matrix44 Matrix44::IDENTITY( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); +const Matrix44 & Matrix44::Identity() { + return IDENTITY; +}; + const Matrix33 Matrix33::IDENTITY( 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f ); +const Matrix33 & Matrix33::Identity() { + return IDENTITY; +}; + const Matrix22 Matrix22::IDENTITY( 1.0f, 0.0f, 0.0f, 1.0f ); +const Matrix22 & Matrix22::Identity() { + return IDENTITY; +}; + /* TexCoord Methods * */ diff --git a/src/obj/NiObject.cpp b/src/obj/NiObject.cpp index 399ae6fab71e719c7e739a878295dc5628a2bd77..8e46f2f6f6dd141ae163ebd4421d918594cb6d84 100644 --- a/src/obj/NiObject.cpp +++ b/src/obj/NiObject.cpp @@ -98,4 +98,8 @@ NiObjectRef NiObject::Clone( unsigned int version, unsigned int user_version ) { const Type & NiObject::GetType() const { return TYPE; -}; \ No newline at end of file +}; + +unsigned int NiObject::GetNumRefs() { + return _ref_count; +} \ No newline at end of file