## RE: [Algorithms] Generating uv coordinates which follow a shape

 RE: [Algorithms] Generating uv coordinates which follow a shape From: Jon Watte - 2004-04-30 05:58:48 ```> > same thing as assuming the mesh has a defined hairline crack, > > as above. Thus, follow each edge and assign the U, V in an > > interpolative fashion. > This I don't get, how can I interpolate from an edge vertex to a > non-edge vertex, when I only have 1 known uv pair, namely that of the > edge vertex? You have all of the vertices and their connectedness info; each vertex knows who its neighbors are and what the distances to those neighbors are. 1) Generate edge vertices, and interpolate these. I'm assuming this part is clear. 2) "color" each edge vert with one of four colors, let's call them "north", "south", "east" and "west". Typically, "south" will be the side from (0,0) to (1,0) (assuming u grows right and v grows up). 2) For each interior vert, find the shortest distance to each of the colored edges, by following connected edges. This is easiest done in O(n) by first pre-calculating by just flood-filling distance from each known vert, accumulating additional distance traveled as you go, a la Dijkstra's algorithm. (If memory serves -- been a while since college :-) 3) No, you have distance to north, south, east and west edges for each vertex. There are two ways to go: 3a) "south" means "v == 0" and "north" means "v == 1"; use distance-to-south/(distance-to-north + distance-to-south) as your V coordinate. Same with west/east/U. 3b) for each of the closest edge vertices, take their U/V coordianates, and weight them equally based on the respective distances. Cheers, / h+ ```