本文介绍了带三角形条的圆圈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在 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 个三角形需要 30,000 个顶点.对于三角形带,每个圆需要 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.

这篇关于带三角形条的圆圈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:45