简体   繁体   English

顶点缓冲对象和球体

[英]Vertex buffer objects and glutsolidsphere

I have to draw a great collection of spheres in a 3D physical simulation of a "spring-mass" like system. 我必须在“弹簧质量”式系统的3D物理模拟中绘制大量球体。

I would like to know an efficient method to draw spheres without having to compile a display list at every step of my simulation (each step may vary from milliseconds to seconds, depending on the number of bodies involved in the computation). 我想知道一种有效的方法来绘制球体,而不必在仿真的每个步骤中都编译显示列表(每个步骤可能从毫秒到秒不等,具体取决于计算中涉及的物体数量)。

I've read that vertex-buffer objects are an efficient method to draw objects which need also to be sometimes updated. 我读过顶点缓冲对象是绘制对象的有效方法,有时还需要更新。

Is there any method to draw OpenGL spheres in a way faster than glutSolidSphere? 有没有什么方法可以比glutSolidSphere更快地绘制OpenGL球体?

I would like to know an efficient method to draw spheres without having to compile a display list at every step of my simulation (each step may vary from milliseconds to seconds, depending on the number of bodies involved in the computation). 我想知道一种有效的方法来绘制球体,而不必在仿真的每个步骤中都编译显示列表(每个步骤可能从毫秒到秒不等,具体取决于计算中涉及的物体数量)。

Why are you generating a display list at all, if the geometry you put into is is dynamic. 如果您放入的几何图形是动态的,为什么根本不生成显示列表。 Display lists are meant for static geometry that never or only seldomly changes. 显示列表适用于从未更改或很少更改的静态几何图形。

I've read that vertex-buffer objects are an efficient method to draw objects which need also to be sometimes updated. 我读过顶点缓冲对象是绘制对象的有效方法,有时还需要更新。

Actually VBOs are most efficient with static geometry as well. 实际上,VBO对于静态几何图形也是最有效的。 In general you want to keep the number of actual geometry updates as low as possible. 通常,您希望将实际几何图形更新的数量保持在尽可能低的水平。 In your case the only thing updating are the positions (and maybe the size) of the spheres. 在您的情况下,唯一更新的是球的位置(可能还有大小)。 This is a prime example for instanced drawing. 这是实例化工程图的主要示例。 However this also works well, with updating only a uniform or the transformation matrix and do the call drawing a sphere. 但是,这也很好用,只需更新一个统一矩阵或变换矩阵,然后调用即可绘制一个球体。

The idea of Vertex Arrays and VBOs is, that you draw a whole batch of geometry with a single call. 顶点阵列和VBO的想法是,您可以通过一次调用绘制整个几何图形。 A sphere would be such a batch. 一个球体就是这样一个批次。

Spheres are self-similar; 球是自相似的; every sphere is just a scaled version of any other sphere. 每个球体只是任何其他球体的缩放版本。 I see no need to regenerate any geometry. 我认为不需要重新生成任何几何图形。 Indeed, I see no need to have more than one sphere at all. 确实,我认为根本不需要一个以上的领域

It's simply a matter of providing the proper scaling matrix. 只需提供适当的缩放矩阵即可。 I would suggest a sphere of radius one centered at the origin for your display list or buffer object mesh. 我建议您为显示列表或缓冲区对象网格指定一个以原点为中心的半径为一个球体。 Then you can just transform it to different locations, using a scale to set the new radius. 然后,您可以使用比例尺将其变换为其他位置,以设置新的半径。

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

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