I have a program in which I track the position of the user and set the truncation (setting the camera to the position of the user) to change the perspective of the scene in accordance with the position of the user. So far, I had all four corners of the display screen on the same z, and I was able to set an asymmetric truncation and change the scene in accordance with the user's perspective.
The current code looks something like this:
UserCam::begin(){ saveGlobalMatrices(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(_topLeftNear.x, _bottomRightNear.x, _bottomRightNear.y, _topLeftNear.y, _camZNear, _camZFar); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(_wcUserHead.x, _wcUserHead.y, _topLeftScreen.z, _wcUserHead.x, _wcUserHead.y, _topLeftScreen.z-1, 0, 1, 0); } UserCam::end(){ loadGlobalMatrices(); } UserCam::setupCam(){ this->_topLeftScreen = _wcTopLeftScreen - _wcUserHead; //wcTopLeftScreen, wcBottomRightScreen and wcUserHead are in the same frame of reference this->_bottomRightScreen = _wcBottomRightScreen - _wcUserHead; this->_topLeftNear = (_topLeftScreen/ _topLeftScreen.z) * _camZNear; this->_bottomRightNear = (_bottomRightScreen/_bottomRightScreen.z )) * _camZNear; }
However, I want to be able to do the same with a display that remains oblique to the user and / or does not have all of its vertices in the same Z
The above can be represented as a kind of inclined window, the vertices of which will have a truncation defined from the user's position. How is such a truncation possible when the display does not have all the vertices in the same Z ?
EDIT
There are three planes in the installation that I am considering. The middle ones give the correct asymmetric truncation, since all the vertices are on the same Z, while the left and right planes have two vertices, each of which has different Z. The vertices of them are as follows:
Plane1: TL : (-426.66, 0, 200), TR: (0, 0, 0), BL : (-426.66, 320.79, 200), BR : (0, 320.79, 0) Plane2: TL : (0, 0, 0), TR: (426.66, 0, 0), BL : (0, 320.79, 0), BR: (426.66, 320.79, 0) Plane3: TL: (426.66, 0, 0), TR: (853.32, 0, 200), BL : (426.66, 320.79, 0), BR : (853.32, 320.79, 200)