0

我有这个房子以(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 以获得等距投影的参数吗?

4

1 回答 1

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 声望。:(

于 2014-02-04T10:34:48.543 回答