Asymmetric frustum for VR CAVE

Software: Away3D 4.x

Avatar
SharpEdge, Member
Posted: 27 May 2013 12:53 PM   Total Posts: 94

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:Numberright:Numbertop:Numberbottom: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)= (_near) / (right left);
   
raw[uint(5)= (_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)= -(_far _near) / (_far _near);   
   
   
_matrix.copyRawDataFrom(raw); 
   

Avatar
theMightyAtom, Sr. Member
Posted: 27 May 2013 05:05 PM   Total Posts: 669   [ # 1 ]

I don’t have an answer, at least not to making an Asymmetric Frustum.
I am however very curious about the set-up and maybe there is a workaround.
For example, if you wanted to move the center of the frustum, you could make the 3D window larger than the stage and move it side to side/up down, and possibly the camera at the same time.
Also, can’t help thinking back to johnny lee’s wii experiments. Is this perhaps the effect you are going for?
https://www.youtube.com/watch?v=Jd3-eiid-Uw

What’s the shape of the cave? I’m imagining flat screens on 3 sides, though in which case you would need more than just a frustum shift, you would need multiple camera views.
If you feel like divulging a few more details, I’m sure there some solution.

Cheers!

   

Avatar
SharpEdge, Member
Posted: 27 May 2013 05:41 PM   Total Posts: 94   [ # 2 ]

Yes the cave will be made of 3 walls at 90°, for each one i’ve set up a different view3D pointing to the same scene.

I’ve looked at Lee project, is source of inspiration for me, but it’s complex to port the code to away3d.
I’ve obtained something but i’m not still happy with the result.

here the code updated that sets the lens and shift the camera:

lens.xCenter xOff;
   
lens.yCenter = -yOff
   
   
_camera.position = new Vector3D(xOff dist, -yOff dist, -dist); 

And here the PerspectiveOffAxisLens updated:

override protected function updateMatrix() : void
  {
   
var raw Vector.<Number> = Matrix3DUtils.RAW_DATA_CONTAINER;
   
   var 
left:Numberright:Numbertop:Numberbottom: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)= (_near) / (right left);
   
raw[uint(5)= (_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)= -(_far _near) / (_far _near);   
   
   
_matrix.copyRawDataFrom(raw);

   
/*var yMaxFar : Number = _far*_focalLengthInv;
   var xMaxFar : Number = yMaxFar*_aspectRatio;

   _frustumCorners[0] = _frustumCorners[9] = left * _xCenter;
   _frustumCorners[3] = _frustumCorners[6] = right * (1 - _xCenter);
   _frustumCorners[1] = _frustumCorners[4] = top * _yCenter;
   _frustumCorners[7] = _frustumCorners[10] = bottom * (1 - _yCenter);

   _frustumCorners[12] = _frustumCorners[21] = -xMaxFar;
   _frustumCorners[15] = _frustumCorners[18] = xMaxFar;
   _frustumCorners[13] = _frustumCorners[16] = -yMaxFar;
   _frustumCorners[19] = _frustumCorners[22] = yMaxFar;

   _frustumCorners[2] = _frustumCorners[5] = _frustumCorners[8] = _frustumCorners[11] = _near;
   _frustumCorners[14] = _frustumCorners[17] = _frustumCorners[20] = _frustumCorners[23] = _far;*/

   
_matrixInvalid false;
  

P.S.:during my research i’ve found that _frustumCorners is useless, i’m right?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X