我的房子位于(0,0,0)的原点,尺寸为10x10x20。我想做一个等距投影,但房子没有显示。这是房子的代码:
glBegin(GL_TRIANGLES);
//roof
glColor3f(1,1,0.35);
glVertex3f(-5, 5, 10);
glVertex3f( 5, 5, 10);
glVertex3f( 0, 11.160254, 10);
glColor3f(1,1,0.35);
glVertex3f(-5, 5, -10);
glVertex3f( 5, 5, -10);
glVertex3f( 0, 11.160254, -10);
glEnd();
/* We tell we want to draw quads */
glBegin(GL_QUADS);
/* Every four calls to glVertex, a quad is drawn */
//roof
glColor3f(1,1,0.5);
glVertex3f(-5, 5, 10);
glVertex3f( 0, 11.160254, 10);
glVertex3f( 0, 11.160254, -10);
glVertex3f(-5, 5, -10);
glColor3f(1,1,0.5);
glVertex3f(5, 5, 10);
glVertex3f( 0, 11.160254, 10);
glVertex3f( 0, 11.160254, -10);
glVertex3f(5, 5, -10);
//left face blue
glColor3f(0, 0, 1);
glVertex3f(-5, -5, -10);
glVertex3f(-5, -5, 10);
glVertex3f(-5, 5, 10);
glVertex3f(-5, 5, -10);
//right face cyan
glColor3f(0, 1, 1);
glVertex3f( 5, -5, -10);
glVertex3f( 5, -5, 10);
glVertex3f( 5, 5, 10);
glVertex3f( 5, 5, -10);
//bottom face magenta
glColor3f(1, 0, 1);
glVertex3f(-5, -5, -10);
glVertex3f(-5, -5, 10);
glVertex3f( 5, -5, 10);
glVertex3f( 5, -5, -10);
//top face yellow
glColor3f(1, 1, 0);
glVertex3f(-5, 5, -10);
glVertex3f(-5, 5, 10);
glVertex3f( 5, 5, 10);
glVertex3f( 5, 5, -10);
//red back face
glColor3f(1, 0, 0);
glVertex3f(-5, -5, -10);
glVertex3f(-5, 5, -10);
glVertex3f( 5, 5, -10);
glVertex3f( 5, -5, -10);
//front face green
glColor3f(0, 1, 0);
glVertex3f(-5, -5, 10);
glVertex3f(-5, 5, 10);
glVertex3f( 5, 5, 10);
glVertex3f( 5, -5, 10);
glEnd();
有人可以帮我处理我必须放入gluLookAt的参数以获得等轴测投影吗?
答案 0 :(得分:1)
好的,你可以试试这个:
gluLookAt(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
注视(0.0,0.0,10.0),看中心点(0.0,0.0,0.0),向上是(0.0,1.0,0.0)。
下面是非常清晰的图像来解释这个功能:
(来自http://profs.sci.univr.it/~colombar/html_openGL_tutorial/en/08viewing_005.html)
抱歉,我无法插入图片,因为这需要10个声望。 :(