问题描述
我一直在试图建立在OpenGL一个圆,但我不能用三角形的球迷,因为我看过他们不具备的DirectX了,我也将使得DirectX的电话。
I have been trying to create a circle in OpenGL but I cannot use triangle fans because I have read they are not available in directx anymore and I will also be making directx calls.
我不是很懂三角带是如何工作的。我所有的实现有孔或怪异怪癖,任何人可以帮助我在这里,我怎么能在尽可能最好的方式实现它?
I could not really understand how triangle strips work. All my implementations had holes or weird quirks, can anybody help me out here, how can I implement it in the best possible way?
也就是真有三角形带和单独的三角形之间的性能差异,为让说10圈每1000个三角形。它将使一个很大的区别?
Also is there really any performance difference between triangle strips and seperate triangles, for lets say 10 circles with 1000 triangles each. Will it make a lot of difference?
推荐答案
指定与三角形带圆圈的一种方法如下:
One way to specify a circle with a triangle strip is as follows:
for each step
add next position on circle
add circle center
这将包括圆的中心位置。不包括中心的另一种方法是这样的:
This will include the circle's center position. Another way without including the center is this:
add left most vertex
for each phi in (-PI/2, Pi/2) //ommit the first and last one
x = r * sin(phi)
y = r * cos(phi)
add (x, y)
add (x, -y)
add right most vertex
您可能需要调整循环取决于你的背面剔除设置
You may need to adjust the loops depending on your backface culling settings
该拓扑需要不同数量的顶点。对于一个三角形列表10圈1000个三角形需要30000顶点。随着三角形带你需要每圈1002个顶点,所以整体10,020顶点。这几乎是三倍更小,传输到CPU时,这应该是快了些。如果此反映在FPS取决于多种因素。
The topologies require different numbers of vertices. For a triangle list 10 circles á 1000 triangles need 30,000 vertices. With a triangle strip you need 1002 vertices per circle, so overall 10,020 vertices. This is almost three times smaller, which should be a bit faster when transferring to the CPU. If this is reflected in the FPS depends on several things.
这篇关于圆与三角形带的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!