简体   繁体   English

无法正确定义一个QUAD

[英]Can't define one QUAD properly

I'm want to have a rectangular cube. 我想要一个矩形立方体。 One wall has face on the wrong side so I can't see pink colour. 一堵墙的另一侧有面,所以我看不到粉红色。 This is good side of the cube: 这是多维数据集的好方面:

好的一面

At the back of the cube there is grey back face of the wall: 立方体的背面是墙壁的灰色背面: 坏的一面

This is the code: 这是代码:

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();

I've tried all combinations (counter)clockwise order but result is still the same. 我已经尝试了所有组合(逆时针)顺序,但结果仍然相同。 Any ideas? 有任何想法吗?

I believe you're identifying your walls incorrectly. 我相信您没有正确识别墙壁。 The ones you create as 1st ( X = - floor_size_x / 2 ), 3rd ( Z = - floor_size_z / 2 ) and 4th ( Z = floor_size_z / 2 ) are all specified clockwise, while the 2nd one ( X = floor_size_x / 2 ) is specified counter-clockwise. 您创建的第一个( X = - floor_size_x / 2 ),第3个( Z = - floor_size_z / 2 )和第4个( Z = floor_size_z / 2 )都是顺时针指定的,而第二个( X = floor_size_x / 2 )是逆时针指定。 I'd guess this is actually the incorrect one. 我猜这实际上是不正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM