简体   繁体   English

检索3D模型上的纹理坐标?

[英]Retrieve texture coordinates on a 3D Model?

Is it possible to retrieve the texture coordinates of an object, for example through hittesting? 是否可以通过例如命中测试来检索对象的纹理坐标?

As an example: I use a 1920x1080 texture on a simple plane, and I want to get the coordinates 1920, 1080 if I click in the right bottom. 例如:我在一个简单的平面上使用1920x1080纹理,如果单击右下角,我想获得1920、1080的坐标。 (The model is in reality slightly more complex, so trying to calculate the position via math isn't as easy) (该模型实际上稍微复杂一些,因此尝试通过数学计算位置并不是那么容易)

When math does not work for some reasons, I used to do the following graphic hit-test: assign unique colors to each texel of your plane, then do one frame rendering to an offscreen surface with lighthing and effects disabled, then read pixel color under the cursor and translate its value back to coordinates. 当数学由于某​​些原因而无法正常工作时,我通常执行以下图形命中测试:为飞机的每个纹理像素分配唯一的颜色,然后在禁用了阴影和效果的情况下对屏幕外表面进行一帧渲染,然后在光标并将其值转换回坐标。 This is quite efficient on complex models when you don't need to do such lookups too often (say, games), because reading pixels back will stop graphics hardware pipeline and drain the performance. 当您不需要太频繁地进行此类查找(例如游戏)时,这在复杂模型上非常有效,因为回读像素会停止图形硬件流水线并降低性能。 Also, this potentially would work with any projections: ortho or perspective. 同样,这可能适用于任何投影:正射或透视。

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

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