Hi, after 3 days of googling i’m here asking for your help, i’m trying to build a CAVE system and i need to have asymmetric frustum to adapt the projection based on the user position.
From what i’ve understood i need to have a custom projection matrix so i’ve made a custom lens and ported the code from OpenGL but obviously it doesn’t work.
here my PerspectiveOffAxisLens
xCenter and yCenter are the coordinates of the head between -0.5 and 0.5
var raw : Vector.<Number> = Matrix3DUtils.RAW_DATA_CONTAINER;
//_yMax = _near*_focalLengthInv;
//_xMax = _yMax*_aspectRatio;
var left:Number, right:Number, top:Number, bottom:Number;
// assume unscissored frustum
top = near*(_focalLengthInv + _yCenter);
bottom = near*(-_focalLengthInv + _yCenter);
left = near*(-_focalLengthInv * _aspectRatio + _xCenter);
right = near*(_focalLengthInv * _aspectRatio + _xCenter);
//trace(top, bottom, left, right);
raw[uint(0)] = (2 * _near) / (right - left);
raw[uint(5)] = (2 * _near) / (top - bottom);
raw[uint(8)] = (right + left) / (right - left);
raw[uint(9)] = (top + bottom) / (top - bottom);
raw[uint(10)] = -(_far + _near) / (_far - _near);
raw[uint(11)] = 1; //-1
raw[uint(1)] = raw[uint(2)] = raw[uint(3)] = raw[uint(4)] =
raw[uint(6)] = raw[uint(7)] = raw[uint(12)] = raw[uint(13)] = raw[uint(15)] = 0;
raw[uint(14)] = -(2 * _far * _near) / (_far - _near);
_matrix.copyRawDataFrom(raw);