简体   繁体   English

将纹理映射到球面OpenGL ES

[英]Mapping textures to a sphere OpenGL ES

Right i am just getting into OpenGL ES, and if i am honest it is very daunting. 是的,我只是进入OpenGL ES,如果我说实话,那是非常艰巨的。

Just need a little guidance to point me in the right direction for my current challenge. 只需要一点指导就可以为我当前的挑战指明正确的方向。

I have some code that produces a 3D sphere, that has a texture mapped on to it (A Globe). 我有一些代码可以生成3D球体,并在其上映射纹理(A Globe)。

I can get the touch co-ordinates on the sphere, and have a handle on that, but my question is how do i then add another texture to that sphere? 我可以获取球体上的触摸坐标,并对此有一个控制,但是我的问题是我该如何为该球体添加另一个纹理?

I want to be able to touch the globe and then "Highlight" particular areas, SO i have the "Highlight image" i then want to map that image onto the globe on the touch. 我希望能够触摸地球,然后“突出显示”特定区域,所以我拥有“突出显示图像”,然后我希望通过触摸将该图像映射到地球上。

This image will wrap around the sphere at the touched point. 该图像将在触摸点处环绕球体。

Am i right in thinking this is a case of adding another texture to the already textured sphere? 我是否认为这是在已纹理化的球体上添加另一个纹理的情​​况的正确解释? What would be the right approach to this? 什么是正确的方法呢?

Do i need to just create a 2D texture to be mapped or do i need a 3D texture (is there such a thing?) 我需要只创建要映射的2D纹理还是需要3D纹理(是否有这种东西?)

Do i need to re texture the whole sphere? 我需要重新纹理整个球体吗?

Its all very confusing and some general pointers would be highly appreciated. 所有这些都非常令人困惑,一些通用的指针将不胜感激。

Many thanks in advance! 提前谢谢了!

If you have a highlight image that you want to apply to the point that's been touched, then, in short, you could apply the highlight image to the base texture first (simply rendering one on top of the other in a separate rendering pass), then using the compound image as your texture. 简而言之,如果您想将高光图像应用于触摸的点,则可以先将高光图像应用于基础纹理(只需在单独的渲染过程中将一个图像叠加在另一个图像上),然后使用复合图像作为纹理。

Things to consider: 注意事项:

  • Texture coordinates are independent of your geometry's coordinates, so if you haven't already, you should work out a mapping between the touch point and the point (coordinate pair) on the texture 纹理坐标独立于几何坐标,因此,如果还没有,则应计算出触摸点与纹理上的点(坐标对)之间的映射
  • To get the highlight to wrap over the edge, you must set the appropriate texture parameter - in this case, GL_REPEAT should work 要使高光环绕边缘,必须设置适当的纹理参数-在这种情况下, GL_REPEAT应该起作用

As for your other questions, yes, there are 3D textures in OpenGL ; 至于其他问题,是的, OpenGL中3D纹理 however, I would not consider them relevant to your task. 但是,我认为它们与您的任务无关。

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

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