Creating a stitched scene with glFrustum

I have a program in which I can render a scene on the screen in accordance with the position of the user. When the user changes position, the truncation changes to give off-axis projection. I want to use the technique to work on three different screens stitching together a large scene with something like the following:

enter image description here Imagine a big real world scene appeared on three screens. Three screens should show the scene how it will look with a changed perspective on each display in accordance with the user's position. I can do this with a single display to render the scene according to the user's position, but I can't think about how this method works on three screens.

The off-axis projection of the class that I created basically does the following:

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 there glTranslatef(0, 0, uPos.z); } 

How to subside three truncations in such a way that the scene looks continuous, as in the real world? Currently, the class user draws the scene as follows:

 cstCam.project(); //draw something here popMatriceS(); //which were pushed before glFrustum projection 

EDIT: In my case, to define three truncations for the user (taking into account the user and screen angles for all displays in the same coordinate system), I did the following:

 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(); } 
+6
source share
1 answer

It is not as difficult as it may seem. Consider the following image (three screens looked at the top at the znear level)

Screens from above

I assumed that each screen spans 2 units in the x direction at the znear distance. You may need to scale this value depending on your scene.

The range for the y-coordinate does not change for the three screens, since they are in the same vertical position.

So, for screens you need three projection matrices. Determining the offset is pretty simple. You just need the differences from the camera point:

 left screen => [-3 - camera.x, -1 - camera.x] center screen => [-1 - camera.x, 1 - camera.x] right screen => [1 - camera.x, 3 - camera.x] 

Of course, you need the camera position in the screen space, as in the figure.

The presentation matrix can be arbitrary, but must be the same for all three screens. This time swipe the camera in the scene space to gluLookAt .

+1
source

Source: https://habr.com/ru/post/947331/


All Articles