通过PyOpenGL拼凑2D图像

时间:2021-12-14 05:50:23

I am trying to cobble together a scene that basically consists of:

我正在努力拼凑一个基本上由以下内容组成的场景:

  1. A 2D image of the earth (think NASA satellite photography) that has been rotated into a view similar to this and,
  2. 地球的二维图像(想想NASA卫星摄影)已被旋转成类似于此的视图,

  3. Cylindrical tubes that I want place at specific lat/lon coordinates.
  4. 我想要的圆柱形管放置在特定的纬度/经度坐标处。

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.

我设法设置了2d图像,如上面的链接所示,但我正在努力创建圆柱体。我希望实现的效果应该与此类似。无论如何,我意识到这种描述并不是很多,我猜这是因为我知道这么少,我不知道该问什么。

Any hints? Names of GL functions I should lookup would be especially useful. I am using PyOpenGL in case that matters.

任何提示?我应该查找的GL函数的名称将特别有用。我正在使用PyOpenGL以防万一。

4 个解决方案

#1


1  

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.

本教程解释了如何使用二次方来节省在GL中绘制对象的时间,有一个圆柱靠近底部的示例。该站点也是OpenGL整体的一个很好的学习资源。虽然它使用C,但您可以看到所使用的功能并根据需要实现它们。

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=18

#2


1  

GLUT is a library which provides collections of opengl calls for commonly used behaviours, including creating basic shapes such as cylinders.

GLUT是一个库,它提供常用行为的opengl调用集合,包括创建诸如柱面之类的基本形状。

Once you manage to create a cylinder using GLUT, you can position the cylinders using matrix transforms to your desired location.

一旦您设法使用GLUT创建圆柱体,您可以使用矩阵变换将圆柱体定位到所需位置。

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/

#3


1  

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.

GLU / GLUT创建的对象是在当前模型视图空间的原点创建的,因此您需要将它们平移/旋转/缩放到所需位置。

Look at glColor, to set the rendering color before you draw your cylinders.

查看glColor,在绘制圆柱体之前设置渲染颜色。

for the transparency effect, a little extra work is required.

为了透明效果,需要做一些额外的工作。

Look up 'blending', glEnable (GL_BLEND), glBlendFunc, to learn about the basics of transparency.

查看'blend',glEnable(GL_BLEND),glBlendFunc,了解透明度的基础知识。

This HeNe tutorial might be useful: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08

这个HeNe教程可能很有用:http://nehe.gamedev.net/data/lessons/lesson.asp?withouton = 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.

渲染透明图像可能导致问题的一件事是,绘制图像的顺序变得很重要,因为z缓冲区剪切和混合的工作方式。您可能会发现需要在距离观察位置的距离越来越近的情况下绘制圆柱体。

#4


0  

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.

我已经阅读过nehe教程,它们非常好。实际上,它们在PyOpenGL中包含的演示中被翻译成python。我猜我的问题更多的是在绘制后设置圆柱的属性,我应该更具体,对不起。我可能错过了一些简单的东西,但经过几个小时的尝试后,我才会空着。我确实使用了GLUT库并尝试绘制glutSolidSphere作为测试。在我的场景中,我似乎无法使它像我在原始帖子中链接的光线一样着色。

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).

我想一个更好的问题就是我应该用什么GL命令来产生效果,这可以在光线动画中看到(OP中的链接)。

#1


1  

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.

本教程解释了如何使用二次方来节省在GL中绘制对象的时间,有一个圆柱靠近底部的示例。该站点也是OpenGL整体的一个很好的学习资源。虽然它使用C,但您可以看到所使用的功能并根据需要实现它们。

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=18

#2


1  

GLUT is a library which provides collections of opengl calls for commonly used behaviours, including creating basic shapes such as cylinders.

GLUT是一个库,它提供常用行为的opengl调用集合,包括创建诸如柱面之类的基本形状。

Once you manage to create a cylinder using GLUT, you can position the cylinders using matrix transforms to your desired location.

一旦您设法使用GLUT创建圆柱体,您可以使用矩阵变换将圆柱体定位到所需位置。

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/

#3


1  

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.

GLU / GLUT创建的对象是在当前模型视图空间的原点创建的,因此您需要将它们平移/旋转/缩放到所需位置。

Look at glColor, to set the rendering color before you draw your cylinders.

查看glColor,在绘制圆柱体之前设置渲染颜色。

for the transparency effect, a little extra work is required.

为了透明效果,需要做一些额外的工作。

Look up 'blending', glEnable (GL_BLEND), glBlendFunc, to learn about the basics of transparency.

查看'blend',glEnable(GL_BLEND),glBlendFunc,了解透明度的基础知识。

This HeNe tutorial might be useful: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08

这个HeNe教程可能很有用:http://nehe.gamedev.net/data/lessons/lesson.asp?withouton = 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.

渲染透明图像可能导致问题的一件事是,绘制图像的顺序变得很重要,因为z缓冲区剪切和混合的工作方式。您可能会发现需要在距离观察位置的距离越来越近的情况下绘制圆柱体。

#4


0  

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.

我已经阅读过nehe教程,它们非常好。实际上,它们在PyOpenGL中包含的演示中被翻译成python。我猜我的问题更多的是在绘制后设置圆柱的属性,我应该更具体,对不起。我可能错过了一些简单的东西,但经过几个小时的尝试后,我才会空着。我确实使用了GLUT库并尝试绘制glutSolidSphere作为测试。在我的场景中,我似乎无法使它像我在原始帖子中链接的光线一样着色。

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).

我想一个更好的问题就是我应该用什么GL命令来产生效果,这可以在光线动画中看到(OP中的链接)。