通过 PyOpenGL 将 2D 图像拼凑在一起
我正在尝试拼凑出一个场景,该场景基本上包括:
- 地球的 2D 图像(想想 NASA 卫星摄影),已旋转成类似于 这个 以及
- 我想要放置在特定纬度/经度坐标的圆柱形管。
我已经成功地设置了二维图像,如上面的链接所示,但我正在努力创建圆柱体。 我希望达到的效果应该类似于这个。 不管怎样,我意识到这个描述并不是很多,我想那是因为我知道的太少,我不知道该问什么。
有什么提示吗? 我应该查找的 GL 函数的名称将特别有用。 我正在使用 PyOpenGL 以防万一。
I am trying to cobble together a scene that basically consists of:
- A 2D image of the earth (think NASA satellite photography) that has been rotated into a view similar to this and,
- Cylindrical tubes that I want place at specific lat/lon coordinates.
I have managed to setup the 2d image as depicted in the link above, but I am struggling with creating the cylinders. The effect I am hoping to achieve should look something similar to this. Anyway, I realize this description isn't really a lot to go on, I guess that is because I know so little I am not sure what to ask.
Any hints? Names of GL functions I should lookup would be especially useful. I am using PyOpenGL in case that matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
本教程介绍了如何使用二次方程来节省在 GL 中绘制对象的时间,有一个靠近底部的圆柱体的示例。 该网站也是 OpenGL 整体学习的一个很好的资源。 尽管它使用 C,但您可以看到所使用的函数并根据需要实现它们。
http://nehe.gamedev.net/data/lessons/lesson。 asp?lesson=18
This tutorial explains how to use quadratics to save time drawing objects in GL, there is an example of a cylinder closer to the bottom. This site is also a great learning resource for OpenGL overall. Although it uses C you can see the functions used and implement them as desired.
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=18
GLUT 是一个库,它提供了常用行为的 opengl 调用集合,
包括创建基本形状,例如圆柱体。
一旦你成功地使用 GLUT 创建了一个圆柱体,你就可以使用以下方法来定位圆柱体:
矩阵变换到您想要的位置。
如果您还没有检查过这些内容,它们可能会很有用:
http://pyopengl.sourceforge.net/documentation/< /a>
http://www.opengl.org/documentation/red_book/
http://www.opengl.org/resources/libraries/glut/
GLUT is a library which provides collections of opengl calls for commonly used behaviours,
including creating basic shapes such as cylinders.
Once you manage to create a cylinder using GLUT, you can position the cylinders using
matrix transforms to your desired location.
If you havent checked these out already they might be useful:
http://pyopengl.sourceforge.net/documentation/
http://www.opengl.org/documentation/red_book/
http://www.opengl.org/resources/libraries/glut/
您在原始帖子中提供的视频有许多效果,您可能会也可能不会尝试模仿。
GLU/GLUT 创建的对象是在当前模型视图空间的原点创建的,因此您需要将它们平移/旋转/缩放到所需的位置。
查看 glColor,在绘制圆柱体之前设置渲染颜色。
为了实现透明效果,需要做一些额外的工作。
查找“混合”、glEnable (GL_BLEND)、glBlendFunc,了解透明度的基础知识。
这个 HeNe 教程可能有用: http://nehe.gamedev.net /data/lessons/lesson.asp?lesson=08
渲染透明图像时可能会出现问题的一件事是,由于 z 缓冲区剪切和混合的工作原理,绘制图像的顺序变得很重要。 您可能会发现需要在距查看位置越来越远的位置绘制圆柱体。
The video you supplied in the original post has a number of effects which you may or may not be trying to emulate.
GLU/GLUT created objects are created at the origin of your current modelview space, so you will need to translate/rotate/scale them to your desired location.
Look at glColor, to set the rendering color before you draw your cylinders.
for the transparency effect, a little extra work is required.
Look up 'blending', glEnable (GL_BLEND), glBlendFunc, to learn about the basics of transparency.
This HeNe tutorial might be useful: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08
The one thing which may cause problems with rendering transparent images is that the order you draw images becomes important becuase of how z-buffer clipping and blending works. You might find that you will need to draw the cylinders in decreasing distance to your viewing location.
感谢您的回答。
我读过nehe的教程,他们相当不错。 事实上,它们在 PyOpenGL 中包含的演示中被转换为 python。 我想我的问题更多地与绘制圆柱体后设置其属性有关,我应该更具体,抱歉。 我可能错过了一些简单的东西,但经过几个小时的尝试,我却一无所获。 我确实使用了 GLUT 库并尝试绘制 glutSolidSphere 作为测试。 在我的场景中,我似乎无法使其颜色像我在原始帖子中链接到的光线一样。
我想更好的问题是我应该使用哪些 GL 命令来产生光线动画(OP 中的链接)中可以看到的效果。
Thanks for the answers.
I have read the nehe tutorials, they are quite good. In fact, they are translated to python in the demos included in PyOpenGL. I guess my problem is more to do with setting attributes of the cylinder after I draw it, I should have been more specific, sorry. I am probably missing something simple but after several hours of trying I am coming up empty. I indeed did use the GLUT library and tried to draw a glutSolidSphere as a test. In my scene I cannot seem to make it colored like the rays I link to in the original post.
I guess a better question would have been what GL commands should I look to to produce effects as can be seen in the rays animation (link in OP).