我有一个程序,可以根据用户的位置在屏幕上渲染场景。随着用户改变位置,平截头体发生变化以提供离轴投影。我想利用该技术在三个不同的显示器上工作,将一个更大的场景拼接在一起,如下所示:
想象一下跨三个显示器渲染的大型真实世界场景。三个显示器应该显示场景,因为它会根据用户的位置在每个显示器上改变视角。我可以使用一个显示器来根据用户的位置渲染场景,但无法想到在三个屏幕上工作的方法。
我创建的类离轴投影基本上执行以下操作:
customCam::project(){
pushMatrices();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(leftNear.x, rightNear.x, bottomNear.y, topNear.y, _near, _far);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(uPos.x, uPos.y, 0, uPos.x, uPos.y, -1, 0, 1, 0); //neglect z scaling for now. In the main program, it's there
glTranslatef(0, 0, uPos.z);
}
如何以使场景看起来像现实世界一样连续的方式缝合三个平截头体?目前,该类的用户绘制场景如下:
cstCam.project();
//draw something here
popMatriceS(); //which were pushed before glFrustum projection
编辑:
就我而言,要为用户定义三个平截头体(考虑到同一参考框架中所有显示器的用户和屏幕角),我执行了以下操作:
custCam1.project();
//draw scene here. eg: two walls at the far left and right screen
drawWalls();
popMatrices();
custCam2.project();
drawWalls();
popMatrices();
custCam3.project();
drawWalls();
popMatrices();
void drawWalls(){
//Left most corner screen wall
glBegin(GL_QUADS);
glVertex3f(-1.5*PHWIDTH, HEIGHT/2, 0); //where PHWIDTH, HEIGHT is the physical width/height of each screen
glVertex3f(-1.5*PHWIDTH, HEIGHT/2, -50);
glVertex3f(-1.5*PHWIDTH, -HEIGHT/2, -50);
glVertex3f(-1.5*PHWIDTH, -HEIGHT/2, 0);
glEnd();
//Right most corner screen wall
glBegin(GL_QUADS);
glVertex3f(1.5*PHWIDTH, HEIGHT/2, 0); //where PHWIDTH, HEIGHT is the physical width/height of each screen
glVertex3f(1.5*PHWIDTH, HEIGHT/2, -50);
glVertex3f(1.5*PHWIDTH, -HEIGHT/2, -50);
glVertex3f(1.5*PHWIDTH, -HEIGHT/2, 0);
glEnd();
}