Added a PerWedgeMakeUnitaryUV to normalize for packing

This commit is contained in:
Paolo Cignoni 2012-07-02 08:29:11 +00:00
parent ad9a7a237d
commit 52fed4c451
1 changed files with 18 additions and 1 deletions

View File

@ -30,6 +30,7 @@ namespace vcg {
template <class MeshType> template <class MeshType>
class UV_Utils class UV_Utils
{ {
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::ScalarType ScalarType; typedef typename MeshType::ScalarType ScalarType;
typedef typename MeshType::FaceType FaceType; typedef typename MeshType::FaceType FaceType;
typedef typename MeshType::VertexType VertexType; typedef typename MeshType::VertexType VertexType;
@ -65,6 +66,22 @@ namespace vcg {
return UVBox; return UVBox;
} }
void PerWedgeMakeUnitaryUV(MeshType &m)
{
vcg::Box2<typename MeshType::ScalarType> UVBox = PerWedgeUVBox(m);
typename MeshType::FaceIterator fi;
Point2f boxSize(UVBox.max-UVBox.min);
for (fi=m.face.begin();fi!=m.face.end();fi++)
{
if ((*fi).IsD()) continue;
for (int i=0;i<3;i++)
{
(*fi).WT(i).U() = ((*fi).WT(i).U()-UVBox.min[0])/boxSize[0] ;
(*fi).WT(i).V() = ((*fi).WT(i).V()-UVBox.min[1])/boxSize[1] ;
}
}
}
///transform curvature to UV space ///transform curvature to UV space
static UVCoordType Coord3DtoUV(FaceType &f,const CoordType &dir) static UVCoordType Coord3DtoUV(FaceType &f,const CoordType &dir)
{ {