25 #ifndef __VCG_TRI_UPDATE_TEXTURE
26 #define __VCG_TRI_UPDATE_TEXTURE
38 template <
class ComputeMeshType>
43 typedef ComputeMeshType MeshType;
44 typedef typename MeshType::ScalarType ScalarType;
45 typedef typename MeshType::VertexType VertexType;
46 typedef typename MeshType::VertexPointer VertexPointer;
47 typedef typename MeshType::VertexIterator VertexIterator;
48 typedef typename MeshType::FaceType FaceType;
49 typedef typename MeshType::FacePointer FacePointer;
50 typedef typename MeshType::FaceIterator FaceIterator;
51 typedef typename vcg::Point2<ScalarType> UVCoordType;
58 for(fi=m.face.begin();fi!=m.face.end();++fi)
63 (*fi).WT(i).U()= (*fi).V(i)->cP() * uVec;
64 (*fi).WT(i).V()= (*fi).V(i)->cP() * vVec;
65 bb.Add((*fi).WT(i).P());
69 ScalarType wideU = bb.max[0]- bb.min[0];
70 ScalarType wideV = bb.max[1]- bb.min[1];
74 ScalarType deltaGutter = std::min(wideU, wideV) * std::min(sideGutter, (ScalarType)0.5);
76 bb.max[0] += deltaGutter;
77 bb.min[0] -= deltaGutter;
78 bb.max[1] += deltaGutter;
79 bb.min[1] -= deltaGutter;
81 wideU = bb.max[0] - bb.min[0];
82 wideV = bb.max[1] - bb.min[1];
86 wideU = std::max(wideU, wideV);
90 for (fi = m.face.begin(); fi != m.face.end(); ++fi)
93 for (
int i = 0; i<3; ++i)
95 (*fi).WT(i).U() = ((*fi).WT(i).U() - bb.min[0]) / wideU;
96 (*fi).WT(i).V() = ((*fi).WT(i).V() - bb.min[1]) / wideV;
101 static void WedgeTexFromVertexTex(ComputeMeshType &m)
103 for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
106 for(
int i=0;i<fi->VN();++i)
108 (*fi).WT(i).U() = (*fi).V(i)->T().U();
109 (*fi).WT(i).V() = (*fi).V(i)->T().V();
125 for(fi=m.face.begin();fi!=m.face.end();++fi)
126 if(!(*fi).IsD())
if((*fi).WT(0).N()==-1) found =
true;
129 m.textures.push_back(texturename);
131 int nullId=m.textures.size()-1;
133 for(fi=m.face.begin();fi!=m.face.end();++fi)
134 if(!(*fi).IsD())
if((*fi).WT(0).N()==-1)
136 (*fi).WT(0).N() = nullId;
137 (*fi).WT(1).N() = nullId;
138 (*fi).WT(2).N() = nullId;
150 tri::RequireVFAdjacency(m);
153 face::VFIterator<FaceType> vfi(&v);
154 std::vector<UVCoordType> clusterVec;
155 clusterVec.push_back(vfi.F()->WT(vfi.I()).P());
159 UVCoordType cur= vfi.F()->WT(vfi.I()).P();
161 for(
auto p:clusterVec) {
162 if(p!=cur && Distance(p,cur) < mergeThr){
163 vfi.F()->WT(vfi.I()).P()=p;
169 clusterVec.push_back(cur);
This class is used to update/generate texcoord position according to various critera.
Definition: texture.h:40
static int WedgeTexMergeClose(ComputeMeshType &m, ScalarType mergeThr=ScalarType(1.0/65536.0))
Merge supposedly wrong texcoords It can happens that for rounding errors texcoords on different wedge...
Definition: texture.h:148
static void WedgeTexRemoveNull(ComputeMeshType &m, const std::string &texturename)
Definition: texture.h:119
void ForEachVertex(const MeshType &m, Callable action)
Definition: foreach.h:126
Definition: namespaces.dox:6