我想要一个矩形立方体。一面墙面朝错,所以看不到粉红色。这是多维数据集的好方面:
在立方体的背面有墙的灰色背面:
这是代码:
glBegin(GL_QUADS);
//floor
glMaterialfv(GL_FRONT, GL_DIFFUSE, floor_diffuse);
glVertex3f(-floor_size_x / 2, 0, floor_size_z / 2);
glVertex3f(floor_size_x / 2, 0, floor_size_z / 2);
glVertex3f(floor_size_x / 2, 0, -floor_size_z / 2);
glVertex3f(-floor_size_x / 2, 0, -floor_size_z / 2);
//roof
glMaterialfv(GL_FRONT, GL_DIFFUSE, roof_diffuse);
glVertex3f(-floor_size_x / 2, wall_height, floor_size_z / 2);
glVertex3f(floor_size_x / 2, wall_height, floor_size_z / 2);
glVertex3f(floor_size_x / 2, wall_height, -floor_size_z / 2);
glVertex3f(-floor_size_x / 2, wall_height, -floor_size_z / 2);
//walls
glMaterialfv(GL_FRONT, GL_DIFFUSE, walls_diffuse);
glVertex3f(-floor_size_x / 2, 0, floor_size_z / 2);
glVertex3f(-floor_size_x / 2, wall_height, floor_size_z / 2);
glVertex3f(-floor_size_x / 2, wall_height, -floor_size_z / 2);
glVertex3f(-floor_size_x / 2, 0, -floor_size_z / 2);
glVertex3f(floor_size_x / 2, 0, floor_size_z / 2);
glVertex3f(floor_size_x / 2, wall_height, floor_size_z / 2);
glVertex3f(floor_size_x / 2, wall_height, -floor_size_z / 2);
glVertex3f(floor_size_x / 2, 0, -floor_size_z / 2);
glVertex3f(-floor_size_x / 2, 0, -floor_size_z / 2);
glVertex3f(-floor_size_x / 2, wall_height, -floor_size_z / 2);
glVertex3f(floor_size_x / 2, wall_height, -floor_size_z / 2);
glVertex3f(floor_size_x / 2, 0, -floor_size_z / 2);
//BAD WALL
glVertex3f(floor_size_x / 2, 0, floor_size_z / 2);
glVertex3f(floor_size_x / 2, wall_height, floor_size_z / 2);
glVertex3f(-floor_size_x / 2, wall_height, floor_size_z / 2);
glVertex3f(-floor_size_x / 2, 0, floor_size_z / 2);
glEnd();
我已尝试顺时针顺序的所有组合(计数器),但结果仍然相同。有任何想法吗?
答案 0 :(得分:0)
我相信你错误地识别你的墙壁。您创建的第一个(X = - floor_size_x / 2
),第三个(Z = - floor_size_z / 2
)和第四个(Z = floor_size_z / 2
)都是顺时针指定的,而第二个(X = floor_size_x / 2
)是指定计数器-顺时针。我猜这实际上是不正确的。