void room(){
glColor3f(1.0, 1.0 ,0.0);
glNormal3f(0,1,0);
glVertex3f( 500 ,-3.0, 500);
glVertex3f(-500 ,-3.0, 500);
glVertex3f(-500 ,-3.0,-500);
glVertex3f( 500 ,-3.0,-500);
}
现在我想在地板上随机生成很多物体,如立方体,球体,圆柱体。你能帮我吗?怎么做?
答案 0 :(得分:3)
质量问题需要质量响应
for (int i = 0; i < 50000; i++) {
glPushMatrix();
glTranslatef(-500 + rand() % 1000, 7 + rand() % 100, -500 + rand() % 1000);
glutSolidTeapot(10);
glPopMatrix();
}
或者可能没有过剩
GLUquadric* q = gluNewQuadric();
for (int i = 0; i < 50000; i++) {
glPushMatrix();
glTranslatef(-500 + rand() % 1000, 7 + rand() % 100, -500 + rand() % 1000);
gluSphere(q, 10, 10, 10);
glPopMatrix();
}
gluDeleteQuadric(q);