Re: [Plib-users] R: How to clip an area
Brought to you by:
sjbaker
From: swetha k. <swe...@gm...> - 2007-10-16 08:45:48
|
Hi, We are using flightgear-0.9.4 version. We are running this flightgear in three pcs and projecting this on big curved 135 deg screen using three projectors.FOV in three is 45 deg and viewoffset that is camera view in flightgear is 45 in left, 0 in center,-45 in right so that it will cover full 135 deg fov. But problem is when pitch up, terrain is not coming straight( Bow like imag= e is coming i.e, right and left terrain up and the center is down). To remove this problem we r planning to set 135 deg FOV in three and clip 9= 0 in three as shown below and render only 45 deg. 135=B0 -------->For left __________________ \45=B0 \ 45=B0 /45=B0 / \ \----/---/ \ \--/--/ \ \/-/ \/ 135=B0 --------->for Center __________________ \45=B0 \ 45=B0 /45=B0 / \--- \ /---/ \-- \ /--/ \--\/-/ \/ 135=B0 --------->for right __________________ \45=B0 \ 45=B0 /45=B0 / \--- \----/ / \-- \--/ / \--\/ / \/ In flightgear we can directly give FOV in option that will go to plib so there we need to change this.we r new to plib. please give solution to achive this. Thanku for giving quick response. regards, swetha. On 10/15/07, Paolo Leoncini <p.l...@ci...> wrote: > > Rather than reasoning in terms of clipping, it seems to me that you have > to > setup an off-axis projection > ( > http://www.opengl.org/resources/faq/technical/transformations.htm#tran008= 0 > ) > . > > 135=B0 > __________________ > \45=B0 \ 45=B0 /45=B0 / > \ \ / / > \ \ / / > \ \/ / > \/ > > The left- and right-most are off-axis projections (to be set up through > OpenGL's glFrustum or Plib's ssgSetFrustum), the center one is on-axis ( > i.e. > the classic one set up through OpenGL's gluProjection or Plib's > ssgSetFOV). > > So the sequence of operation would be the following: > > glViewport( 0, 0, w/3, h ); > ssgSetFrustum( <leftmost frustum params> ); > ssgCullAndDraw(...); > > glViewport( w/3, 0, w/3, h ); > ssgSetFrustum( <center frustum params> ); > ssgCullAndDraw(...); > > glViewport( 2*w/3, 0, w/3, h ); > ssgSetFrustum( <rightmost frustum params> ); > ssgCullAndDraw(...); > > In order to calculate proper arguments to ssgSetFrustum( left, right, > bottom, top, zNear, zFar) as the given FoV partitioning you could search > for > keywords glfrustum and off-axis projection, or tiled projection. > > If you prefer, just use to code below. You nave to find how to split you > 135=B0 FoV screen into 3x45=B0 screens (i.e. the four corners of each > projection > surface) in terms of (ul,ur,ll,lr) corner positions - and set eyepos as t= o > > comprise the 135=B0 screen. It's not important where the coordinate syste= m > origin is wrt screen corner and eyepos, nor the units, but, for > simplicity, > you could just put the coordinate system origin at the center of the > center > screen and find (ul,ur,ll,lr) and eyepos accordingly, or put it at eyepos > (eyepos (0,0,0)) and find (ul,ur,ll,lr) accordingly: > > ul ur > +---+------+---+ > | | | | > +...+......+...+ > |\ |\ /| /| > +--\+-\--/-+/--+ > ll lr\ \/ / > \/ > eyepos > > enum {SC_UL, SC_UR, SC_LL, SC_LR}; // enum for specifying screen corner > // (Ux: upper, Lx: lower, xL: left, xR= : > right) > > void calcOffAxisView( > // input args > sgVec3 screen[4], // the four screen corner positions (x,y,z), > // fill entries SC_UL, SC_UR, SC_LL, and SC_LR > sgVec3 eyepos, // eye position (x,y,z) > // screen and eyepos have to be in the same > coordinate system > // (x+ right, y+ up, z+ out of the screen) > float near_clip, float far_clip, // near and far clipping planes > // output args > float *left, float *right, float *bottom, float *top // first six > args to ssgSetFrustum, > // the last tw= o > are near_clip and far_clip > ) > { > sgVec3 eyeToScreen, xProj, yProj, zProj; > float width, height, dist; > sgVec3 eyePos; > > sgCopyVec3( eyePos, eyepos ); > // Calculate vector from eye to screen origin (lower left corner) > sgSubVec3(eyeToScreen, eyePos, screen[SC_LL]); > // Calculate vectors from bottom left corner of screen that form > // the screen coordinate frame > sgSubVec3(xProj, screen[SC_LR], screen[SC_LL]); > width =3D sgLengthVec3(xProj); > sgScaleVec3(xProj, SG_ONE / width); > sgSubVec3(yProj, screen[SC_UL], screen[SC_LL]); > height =3D sgLengthVec3(yProj); > sgScaleVec3(yProj, SG_ONE / height); > sgVectorProductVec3(zProj, xProj, yProj); > > // Now, specify an off-axis viewing frustum in order to define the > // viewing volume with respect to the user's eye position. > *left =3D sgScalarProductVec3(eyeToScreen, xProj); > *right =3D width - *left; > bottom =3D sgScalarProductVec3(eyeToScreen, yProj); > *top =3D height - *bottom; > dist =3D sgScalarProductVec3(eyeToScreen, zProj); > float nc_over_d =3D near_clip / dist; > *left *=3D -nc_over_d; > *right *=3D nc_over_d; > *bottom *=3D -nc_over_d; > *top *=3D nc_over_d; > } > > Note that the code above is only valid for the tiling case (i.e. there's > no > screen rotation) - for arbitrary positioned screens there's an additional > matrix multiplication to take into account either in the projection or in > the modelview matrix (in this case, its inverse). > > Greetings - > > Paolo Leoncini > > > ________________________________ > > Da: pli...@li... > [mailto: pli...@li...] Per conto di swetha > korada > Inviato: luned=EC 15 ottobre 2007 10.35 > A: pli...@li... > Oggetto: [Plib-users] How to clip an area > > > Hi all, > > I am using plib-1.8.2 version.In that, I have set the > horizonital > Field Of View(FOV) as 135 degrees.In that I have to render only first 45 > degrees area.So I need to clip next 90 degrees.How to achieve this? > > Hope any one will give reply as soon as possible. > > Thanks And Regards, > swetha. > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |