Calculating planar UV coordinates for arbitrary meshes

我怕爱的太早我们不能终老 提交于 2019-12-09 11:07:23

问题


I have code that generates triangle mesh from 2d shapes. Because those shapes in most cases have uneven vertex distribution on the surface I have an issue with generation of UVs so that it wouldn't cause texture distortion. Anybody can suggest some articles, books, code samples that talk about techniques of UV calculation on planar meshes? Thanks


回答1:


ok lets see if I understood your question.

  • You have a planar mesh with vertices (x_i,y_i,z_i), since the mesh is planar you can find a rotation which leads to coordinates with z_i = 0
  • So I'll assume that your mesh is also 2D with vertices (x_i,y_i)
  • Second, you have a mapping of two uv-coordinates to points in the plane into which you mesh is embedded.
  • Lets assume you have a mapping for uv-coords (0,0) and (1,1) i.e. (0,0) -> (x_0, y_0) and (1,1) -> (x_1, y_1)
  • you can then translate all your vertices by -1*(x_0, y_0), then (0,0) maps to (0,0) on the meshes coord system and (1,1) maps to a new coord (x_1', y_1')

  • So for any vertex in your mesh with new coords (x_i', y_i') the corresponding uv-coordinate is: (x_i' / x_1', y_i' / y_1')

Hope that helps.



来源:https://stackoverflow.com/questions/8960930/calculating-planar-uv-coordinates-for-arbitrary-meshes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!