|
|
1
Rabbid76
5 年前
什么时候?
Face Culling
如果启用,则根据顶点坐标的缠绕顺序(从视图中看),放弃基本体。
为此,正面的缠绕顺序定义如下:
glFrontFace
. 默认情况下,这是逆时针的。
如果启用背面划船:
GL40.glEnable(GL40.GL_CULL_FACE);
GL40.glCullFace(GL40.GL_BACK);
然后丢弃具有相反缠绕顺序(顺时针)的多边形。
根据你的顶点坐标
float[] vertices = {
-0.5f, 0.5f, -0.5f, 0, 0,
-0.5f, -0.5f, -0.5f, 0, 1,
0.5f, -0.5f, -0.5f, 1, 1,
0.5f, 0.5f, -0.5f, 1, 0,
-0.5f, 0.5f, 0.5f, 0, 0,
-0.5f, -0.5f, 0.5f, 0, 1,
0.5f, -0.5f, 0.5f, 1, 1,
0.5f, 0.5f, 0.5f, 1, 0,
0.5f, 0.5f, -0.5f, 0, 0,
0.5f, -0.5f, -0.5f, 0, 1,
0.5f, -0.5f, 0.5f, 1, 1,
0.5f, 0.5f, 0.5f, 1, 0,
-0.5f, 0.5f, -0.5f, 0, 0,
-0.5f, -0.5f, -0.5f, 0, 1,
-0.5f, -0.5f, 0.5f, 1, 1,
-0.5f, 0.5f, 0.5f, 1, 0,
-0.5f, 0.5f, 0.5f, 0, 0,
-0.5f, 0.5f, -0.5f, 0, 1,
0.5f, 0.5f, -0.5f, 1, 1,
0.5f, 0.5f, 0.5f, 1, 0,
-0.5f, -0.5f, 0.5f, 0, 0,
-0.5f, -0.5f, -0.5f, 0, 1,
0.5f, -0.5f, -0.5f, 1, 1,
0.5f, -0.5f, 0.5f, 1, 0
};
指数
short[] indices = {
0, 1, 3, 3, 1, 2,
4, 5, 7, 7, 5, 6,
8, 9, 11, 11, 9, 10,
12, 13, 15, 15, 13, 14,
16, 17, 19, 19, 17, 18,
20, 21, 23, 23, 21, 22
};
这意味着第一行、第三行和第五行索引的缠绕顺序错误。必须这样:
short[] indices = {
0, 3, 1, 3, 2, 1,
4, 5, 7, 7, 5, 6,
8, 11, 9, 11, 10, 9,
12, 13, 15, 15, 13, 14,
16, 19, 17, 19, 18, 17,
20, 21, 23, 23, 21, 22
};
|