将球体上的 3d 点转换为 UV 坐标 [英] Convert 3d point on sphere to UV coordinate

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

问题描述

我在球体上有一个 3d 点,想从中转换为球体纹理上的 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.

我目前有这个,它没有返回正确的 UV 坐标.p 是球体上的 3d 点mesh.position 是球体的位置

I currently have this, which does not return the correct UV coordinate. p is the 3d point on the sphere mesh.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;

推荐答案

维基百科关于 uv 映射是正确的,但是您需要计算网格每个顶点的 uv 坐标.然后需要将uv坐标转换为像素坐标:opengl中的完美(3D)纹理映射.这是另一个示例:http://www.cse.msu.edu/~cse872/tutorial4.html.你也可以试试three.js.您还需要物理复制 uv 三角形.

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 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆