2

I'm trying to create a cube using one series of vertices such as attempted in this example (which I believe is wrong) and also talked about on this forum. The answer I'm looking for should look something like this:

 1,  1, -1
-1, -1, -1,
 1,  1,  1

... and so on. I'm hoping to get this down to a minimum of 13 vertices (6 sided cube = 12 triangles).

Is this possible?

4

3 回答 3

5

There's little benefit in minimizing the vertices of a triangle / quad strip. One advantage of having each face has its own vertex (for a sharp-edged mesh like the cube) is the ability to specify different normal to each vertex, which might might be important for you if you want to have correct per-pixel lighting with a specular reflection.

(Anyway, if you're not concerned about normals or anything: The best you can do in terms of sheer efficiency is specify just the 8 vertices and use an index array. This enables the use of vertex cache so your vertex shader is likely to run only once per each vertex, even though it is used by several faces).

于 2010-11-13T16:37:10.377 回答
3

它需要 14 个顶点,因为前 3 个构成一个三角形,然后每个额外的三角形使用一个额外的顶点 (2+num_triangles)。这就是我管理它的方式:

v = ((-w, -h,  d),  # front-bottom-left     0
     ( w, -h,  d),  # front-bottom-right    1
     (-w,  h,  d),  # front-top-left        2
     ( w,  h,  d),  # front-top-right       3
     (-w, -h, -d),  # back-bottom-left      4
     ( w, -h, -d),  # back-bottom-right     5
     (-w,  h, -d),  # back-top-left         6
     ( w,  h, -d))  # back-top-right        7


strip_vertices = (v[7] + v[6] + v[3] + v[2] + v[0] + v[6] + v[4] + 
                  v[7] + v[5] + v[3] + v[1] + v[0] + v[5] + v[4])

如前所述,这会导致法线出现问题,所以我想我会以非条形格式重写它。

于 2013-12-28T20:02:27.883 回答
2

如果我理解正确的话,我可以低至 17

 1: -1,  1,  1
 2:  1,  1,  1
 3: -1, -1,  1
 4:  1, -1,  1
 5: -1, -1, -1
 6:  1, -1, -1
 7: -1,  1, -1
 8:  1,  1, -1
 9: -1,  1,  1
10:  1,  1,  1
11:  1, -1,  1
12:  1,  1, -1
13:  1, -1, -1
14: -1, -1, -1
15: -1,  1, -1
16: -1, -1,  1
17: -1,  1,  1
于 2010-11-11T19:18:19.107 回答