我正在创建一堆房间,需要从第一人称(我已经介绍过)和上方显示它们以显示房间内的内容。问题是我不知道如何为上面的视图切断屋顶,所以它只会显示里面的东西,而不是屋顶/天花板。
这是我到目前为止所拥有的:
public void display(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// the "up" direction
for ( int i=0; i<2; i++ ){
//display first-person view here
if(i == 0){
gl.glViewport(0, 0, 600, 600);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluPerspective(90., 1., .5, 100.);
gl.glLoadIdentity();
glu.gluLookAt(eyex, eyey, eyez,
eyex+Math.cos(Math.toRadians(viewangle)),
eyey,
eyez-Math.sin(Math.toRadians(viewangle)),
0f,1f,0f);
}
gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
//display from above view here
if(i == 1){
gl.glViewport(600, 0, 600, 600);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluPerspective(90., 1., .5, 100.);
gl.glLoadIdentity();
glu.gluLookAt(59, 90, 59.999,
60, 0, 60,
0f,1f,0f);
}
room1.draw(gl);
room2.draw(gl);
room3.draw(gl);
room4.draw(gl);
room5.draw(gl);
room6.draw(gl);
room7.draw(gl);
creature.draw(gl);
}
int error = gl.glGetError();
if (error != GL.GL_NO_ERROR)
System.out.println("OpenGL Error: " );
}