added option to add "gutter" space around planar parametrization (default is no gutter)
This commit is contained in:
parent
e4d83262fe
commit
a214eb3b66
|
|
@ -49,9 +49,9 @@ typedef typename MeshType::FaceType FaceType;
|
||||||
typedef typename MeshType::FacePointer FacePointer;
|
typedef typename MeshType::FacePointer FacePointer;
|
||||||
typedef typename MeshType::FaceIterator FaceIterator;
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
|
|
||||||
static void WedgeTexFromPlane(ComputeMeshType &m, const Point3<ScalarType> &uVec, const Point3<ScalarType> &vVec, bool aspectRatio)
|
static void WedgeTexFromPlane(ComputeMeshType &m, const Point3<ScalarType> &uVec, const Point3<ScalarType> &vVec, bool aspectRatio, ScalarType sideGutter=0.0)
|
||||||
{
|
{
|
||||||
// First just project
|
Box2f bb;
|
||||||
|
|
||||||
FaceIterator fi;
|
FaceIterator fi;
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
||||||
|
|
@ -61,22 +61,26 @@ static void WedgeTexFromPlane(ComputeMeshType &m, const Point3<ScalarType> &uVec
|
||||||
{
|
{
|
||||||
(*fi).WT(i).U()= (*fi).V(i)->cP() * uVec;
|
(*fi).WT(i).U()= (*fi).V(i)->cP() * uVec;
|
||||||
(*fi).WT(i).V()= (*fi).V(i)->cP() * vVec;
|
(*fi).WT(i).V()= (*fi).V(i)->cP() * vVec;
|
||||||
}
|
|
||||||
}
|
|
||||||
// second Loop normalize to
|
|
||||||
Box2f bb;
|
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
|
||||||
if(!(*fi).IsD())
|
|
||||||
{
|
|
||||||
for(int i=0;i<3;++i)
|
|
||||||
{
|
|
||||||
bb.Add((*fi).WT(i).P());
|
bb.Add((*fi).WT(i).P());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ScalarType wideU = bb.max[0]- bb.min[0];
|
ScalarType wideU = bb.max[0]- bb.min[0];
|
||||||
ScalarType wideV = bb.max[1]- bb.min[1];
|
ScalarType wideV = bb.max[1]- bb.min[1];
|
||||||
|
|
||||||
|
if (sideGutter>0.0)
|
||||||
|
{
|
||||||
|
ScalarType deltaGutter = std::min(wideU, wideV) * min(sideGutter, (ScalarType)0.5);
|
||||||
|
|
||||||
|
bb.max[0] += deltaGutter;
|
||||||
|
bb.min[0] -= deltaGutter;
|
||||||
|
bb.max[1] += deltaGutter;
|
||||||
|
bb.min[1] -= deltaGutter;
|
||||||
|
|
||||||
|
wideU = bb.max[0] - bb.min[0];
|
||||||
|
wideV = bb.max[1] - bb.min[1];
|
||||||
|
}
|
||||||
|
|
||||||
if (aspectRatio) {
|
if (aspectRatio) {
|
||||||
wideU = std::max(wideU, wideV);
|
wideU = std::max(wideU, wideV);
|
||||||
wideV = wideU;
|
wideV = wideU;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue