diff --git a/include/obj/NiGeometryData.h b/include/obj/NiGeometryData.h index 4cab63ce783845efb9f9902e9dec0e8f494b3a58..c9e571da88bb44f6c00347bb2b8993cd4fdc9387 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 f9cddd326778c1390462b98ad311644c48161463..ed51d6c3d6aec4944340687dca14f90eeb61e778 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;