From ecef94565734445012f84180933a31afe11ec2d2 Mon Sep 17 00:00:00 2001 From: Steve Carrow <sacarrow@users.sourceforge.net> Date: Fri, 23 Jan 2009 21:03:10 +0000 Subject: [PATCH] Added mapping between Max UV map channels and NIF UV set indices. --- include/obj/NiGeometryData.h | 18 +++++++++++++++++- src/obj/NiGeometryData.cpp | 12 ++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/obj/NiGeometryData.h b/include/obj/NiGeometryData.h index 4cab63ce..c9e571da 100644 --- a/include/obj/NiGeometryData.h +++ b/include/obj/NiGeometryData.h @@ -61,6 +61,9 @@ public: protected: /*! The mesh vertex indices. */ vector<int > vertexIndices; + + /*! The mapping between Nif & Max UV sets. */ + std::map<int, int> uvSetMap; // first = Max index, second = Nif index public: //--Counts--// @@ -145,11 +148,18 @@ public: /*! * Used to retrive the vertex indices used by this mesh. The size of the vector will be the same as the vertex count retrieved with the IShapeData::GetVertexIndexCount function. - * \return A vector cntaining the vertex indices used by this mesh. + * \return A vector containing the vertex indices used by this mesh. * \sa IShapeData::SetVertexIndices, IShapeData::GetVertexIndexCount, IShapeData::SetVertexIndexCount. */ NIFLIB_API vector<int> GetVertexIndices() const; + /*! + * Used to retrive the the NIF index corresponding to the Max map channel. If there isn't one, -1 is returned. + * \param maxMapChannel The max map channel of the desired UV set. + * \return A int representing the NIF index of the UV se used. + */ + NIFLIB_API int GetUVSetIndex(int maxMapChannel) const; + //--Setters--// /*! @@ -188,6 +198,12 @@ public: */ NIFLIB_API virtual void SetVertexIndices( const vector<int> & in ); + /*! + * Used to set the UV set mapping data used by this mesh. This info maps the Max map channel to the index used in the NIF. + * \param in A map of UV set indices; first is the Max map channel and the second is the index used in the Nif mesh. + */ + NIFLIB_API virtual void SetUVSetMap( const std::map<int, int> & in ); + /*! * Used to apply a transformation directly to all the vertices and normals in * this mesh. diff --git a/src/obj/NiGeometryData.cpp b/src/obj/NiGeometryData.cpp index f9cddd32..ed51d6c3 100644 --- a/src/obj/NiGeometryData.cpp +++ b/src/obj/NiGeometryData.cpp @@ -440,6 +440,14 @@ vector<int> NiGeometryData::GetVertexIndices() const { return vertexIndices; } +int NiGeometryData::GetUVSetIndex(int maxMapChannel) const +{ + if (uvSetMap.size() == 0) return -1; + map<int,int>::const_iterator it = uvSetMap.find(maxMapChannel); + if (it == uvSetMap.end()) return -1; + return (*it).second; +} + void NiGeometryData::SetUVSetCount(int n) { uvSets.resize(n); hasUv = ( uvSets.size() != 0 ); @@ -532,6 +540,10 @@ void NiGeometryData::SetVertexIndices( const vector<int> & in ) { vertexIndices = in; } +void NiGeometryData::SetUVSetMap( const std::map<int, int> & in ) { + uvSetMap = in; +} + Vector3 NiGeometryData::GetCenter() const { return center; -- GitLab