Cube using single GL_TRIANGLE_STRIP

后端 未结 4 825
滥情空心
滥情空心 2021-02-07 04:03

Is it possible to draw a whole cube using just a single GL_TRIANGLE_STRIP?

Obviously it\'s just the cube combinatorics I\'m concerned about here, it might a

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 04:41

    Yes, after a bit of experimenting I found the answer myself. Imagine the corners of your cube are colored alternatingly black and white. Draw a triangle edge along each face between the two black corners. That way, the diagonals form a tetrahedron inside the cube. For the [0,1]³ cube, a possible sequence of coordinates would be the following:

    Vertex  Triangle    Face
    ------+-----------+-----
    0 0 0
    0 1 0
    1 0 0  000 010 100  **0
    1 1 0  100 010 110  **0
    1 1 1  100 110 111  1**
    0 1 0  111 110 010  *1*
    0 1 1  111 010 011  *1*
    0 0 1  011 010 001  0**
    1 1 1  011 001 111  **1
    1 0 1  111 001 101  **1
    1 0 0  111 101 100  1**
    0 0 1  100 101 001  *0*
    0 0 0  100 001 000  *0*
    0 1 0  000 001 010  0**
    

提交回复
热议问题