Re: [Plib-users] R: How to clip an area
Brought to you by:
sjbaker
|
From: swetha k. <swe...@gm...> - 2007-10-17 04:57:11
|
Hi,
The concept you have sent is what we are expecting to implement.
135=B0
__________________
\45=B0 \ 45=B0 /45=B0/
\ \ / /
\ \ / /
\ \/ /
\/
We r very new to plib, and we r using plib as a standerad lib for
flightgear.
In my code glviewport is in reshape funtion of flightgear. i.e.,
glutReshapeFunc( fgReshape );
void fgReshape( int width, int height )
{
int view_h;
if ( (!fgGetBool("/sim/virtual-cockpit"))&& fgPanelVisible() &&
idle_state =3D=3D 1000 )
{
view_h =3D (int)(height *
(globals->get_current_panel()->getViewHeight() -
globals->get_current_panel()->getYOffset()) =
/
768.0);
}
else
{
view_h =3D height;
}
glViewport( 0, (GLint)(height - view_h), (GLint)(width), (GLint)(view_h=
)
);
fgSetInt("/sim/startup/xsize", width);
fgSetInt("/sim/startup/ysize", height);
guiInitMouse(width, height);
// for all views
FGViewMgr *viewmgr =3D globals->get_viewmgr();
if (viewmgr)
{
for ( int i =3D 0; i < viewmgr->size(); ++i )
{
viewmgr->get_view(i)->set_aspect_ratio((float)view_h /
(float)width);
}
ssgSetFOV(
viewmgr->get_current_view()->get_h_fov(),viewmgr->get_current_view()->get_v=
_fov()
);
#ifdef FG_USE_CLOUDS_3D
sgClouds3d->Resize( viewmgr->get_current_view()->get_h_fov(),
viewmgr->get_current_view()->get_v_fov() );
#endif
}
fgHUDReshape();
}
and ssgCullAndDraw(.....) is calling in fgrender function which is
infinitely calling. Now we are
confused to where put the code which you have sent( below ). only in reshap=
e
function we are calling
glviewport.
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(...);
And Calculation of
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
sixargs to ssgSetFrustum,
// the last
twoare near_clip and far_clip
)
we are put in ssgContext.cxx.
Now the problem is where to call this function and what are the value of
sgVec3 screen[4] and
sgVec3 eyepos how to find this.
we are expecting your reply.
Thankyou very much.
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 hav=
e
> > to
> > setup an off-axis projection
> > (http://www.opengl.org/resources/faq/technical/transformations.htm#tran=
0080
> > )
> > .
> >
> > 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 searc=
h
> > 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 yo=
u
> > 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
> > to
> > comprise the 135=B0 screen. It's not important where the coordinate sys=
tem
> > 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 corne=
r
> > // (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 plane=
s
> >
> > // output args
> > float *left, float *right, float *bottom, float *top // first
> > six
> > args to ssgSetFrustum,
> > // the last
> > two
> > 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 4=
5
> >
> > 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
> >
>
>
|