问题描述
我有从二维形状生成三角形网格的代码.因为在大多数情况下这些形状在表面上的顶点分布不均匀,所以我在生成 UV 时遇到了问题,因此它不会导致纹理失真.任何人都可以推荐一些讨论平面网格上 UV 计算技术的文章、书籍、代码示例?谢谢
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
推荐答案
好的,看看我是否理解你的问题.
ok lets see if I understood your question.
- 您有一个顶点为 (x_i,y_i,z_i) 的平面网格,因为网格是平面的,您可以找到导致 z_i = 0 坐标的旋转
- 所以我假设您的网格也是具有顶点 (x_i,y_i) 的 2D 网格
- 其次,您有两个 uv 坐标到网格嵌入平面中点的映射.
- 假设你有一个 uv-coords (0,0) 和 (1,1) 的映射即 (0,0) -> (x_0, y_0) 和 (1,1) -> (x_1, y_1)
然后您可以通过 -1*(x_0, y_0) 平移所有顶点,然后 (0,0) 映射到网格坐标系统上的 (0,0) 并且 (1,1) 映射到新坐标 (x_1', y_1')
- 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')
因此,对于网格中具有新坐标 (x_i', y_i') 的任何顶点,相应的 uv 坐标为:(x_i'/x_1', y_i'/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')
希望有所帮助.
这篇关于计算任意网格的平面 UV 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!