简体   繁体   English

将点映射到2D纹理上

[英]Mapping points onto a 2D texture

Hey this may sound simple but it escapes me, 嘿,这听起来很简单,但我却逃不过来,

I have a list of 3D points (including negative positions) that I would like to map onto a 2D Texture. 我有一个要映射到2D纹理上的3D点(包括负位置)列表。

I'm trying to figure out how to map the points appropriately to the texture and how it differs if it has a specific width/height. 我试图弄清楚如何将这些点正确地映射到纹理,以及在具有特定的宽度/高度的情况下如何不同。

Thanks 谢谢

The simple way: using ortographic projection. 简单的方法:使用地形投影。

x_2d = x_3d + z_3d * scale_x x_2d = x_3d + z_3d * scale_x

y_2d = y_3d + z_3d * scale_y y_2d = y_3d + z_3d * scale_y

Where (scale_x, scale_y) is a vector describing the "direction" of the projection. 其中(scale_x,scale_y)是描述投影“方向”的向量。

If objects with an high position ("far away") should be smaller you should search for perspective projection (eg on Wikipedia: 3D Projection ) 如果位置较高(“远”)的对象应该较小,则应搜索透视投影(例如,在Wikipedia上:3D Projection

In my experience, usually you specify the 2D texture coordinates in your model using glTexCoord2f (one for each 3D point), and let OpenGL take care of the rest. 以我的经验,通常使用glTexCoord2f在模型中指定2D纹理坐标(每个3D点一个),然后让OpenGL负责其余的工作。

Maybe I am misunderstanding what you are trying to do here. 也许我误会了您在这里想要做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM