本文介绍了转换3D点上球体UV坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个球上的三维点,并希望从该转换,到球体上的纹理UV点。

可能有人指明了正确的方向,为好吗?我可以带一个纯数学的解决方案。

编辑:

我现在有这个,不返回正确的UV坐标。p是在球面上的三维点mesh.position是球体的位置

  VAR X =(p.x-mesh.position.x)/ 500;
变种Y =(p.y-mesh.position.y)/ 500;
VAR Z =(p.z-mesh.position.z)/ 500;

变种U = Math.atan2(X,Z)/(2 * Math.PI)+ 0.5;
变种V = Math.asin(Y)/ Math.PI±0.5;
 

解决方案

有关UV映射维基百科是正确的,但是你需要计算的UV坐标网格的每个顶点。然后,你需要变换UV坐标像素坐标:完美(3D)纹理映射在OpenGL 。下面是一个其他例子: http://www.cse.msu.edu/~cse872 /tutorial4.html 。您也可以尝试three.js。您还需要物理复制UV三角形。

I have a 3d point on a sphere and want to convert from that, to a UV point on the sphere's texture.

Could someone point in the right direction for the please? I can take a pure math solution.

Edit:

I currently have this, which does not return the correct UV coordinate.p is the 3d point on the spheremesh.position is the position of the sphere

var x = (p.x-mesh.position.x)/500;
var y = (p.y-mesh.position.y)/500;
var z = (p.z-mesh.position.z)/500;

var u = Math.atan2(x, z) / (2 * Math.PI) + 0.5;
var v = Math.asin(y) / Math.PI + .5;
解决方案

The Wikipedia about uv-mapping is correct however you need to compute the uv coordinate for each vertex of the mesh. Then you need to transform the uv coordinate to pixel coordinate: Perfect (3D) texture mapping in opengl. Here is an other example: http://www.cse.msu.edu/~cse872/tutorial4.html. You can also try three.js. You also need to physically copy the uv triangle.

这篇关于转换3D点上球体UV坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 13:49