Re: FOV Bugs?

New Message Reply Date view Thread view Subject view Author view

John Rohlf (jrohlf++at++tubes)
Wed, 5 Jul 95 10:41:25 PDT


        This one stumped me for a while. It turns out that this is not
a Performer bug. If the FOVs are unequal, the near plane distances
must also be unequal for the viewplanes to match at channel boundaries.
The side channel near plane distances must be

        t = cos(side horiz FOV/2) / cos(middle horiz FOV/2)
        side near = middle near * t

This matches the vertical edges of the viewplanes but then screws up
the horizontal edge matching. Consequently, the vertical FOVs of the
the side channels must be tweaked

        side vert FOV = 2 * atan(tan(middle vert FOV / 2) / t)

>
> Following on from the pf...Frustrum problems I uncovered a few weeks
> back, would anyone like to comment about this problem. It's possible I'm
> being an idiot, but I don't think so (!).
>
> s/w below sets up 3 views on one monitor. Initial settings are 35 deg
> (left + right), 90 deg (centre). Vertical FOV is 60 deg for all. This
> should provide a continuous horiz FOV of 160 deg.
>
> I realise that the gradient of displayed polygons (in XY screen
> space) will be discontinuous across the viewport boundaries, but I
> believe the actual height (screen Y) of polygon's should be the same on
> both sides of viewport boundaries, because the vertical FOV is identical.
>
> ... but it isn't. Why?
>
> If the viewport horizontal FOV's are all the same (commented out line)
> then there is no problem.
>
> Is this another Performer bug?
>
> ----------------------------------
> model file: tmp.sv
> ----------------------------------
> material 1 1.0 1.0 1.0 1.0 1.0 1.0 0.0 0.0 0.0 1 0 0 0
> texture 1 Texture/plain_wood.rgb
> texture 2 Texture/presentation.rgb
>
> material 1
> texture 1
>
> backface off
> tmeshn 4
> 0 -2 1 0 0 1
> 0 2 1 0 0 1
> 0 -2 1.5 0 0 1
> 0 2 1.5 0 0 1
>
> backface off
> tmeshn 4
> 0 -2 1.6 0 0 1
> 0 2 1.6 0 0 1
> 0 -2 2.0 0 0 1
> 0 2 2.0 0 0 1
>
> backface off
> tmeshn 4
> 0 -2 2.1 0 0 1
> 0 2 2.1 0 0 1
> 0 -2 2.5 0 0 1
> 0 2 2.5 0 0 1
>
> -------------------------------------
> C++ code: Just one file. move mouse to rotate view left + right
> -------------------------------------
> #include <iostream.h>
> #include <stdlib.h>
> #include <string.h>
> #include <math.h>
> #include <ctype.h>
>
> #include <gl/gl.h>
> #include <gl/device.h>
>
> #include <Performer/pf.h>
> #include <Performer/pr.h>
> #include </usr/src/Performer/include/pfutil.h>
> #include </usr/src/Performer/include/pfsgi.h>
>
> static void OpenPipeline (pfPipe *p);
> static void DrawChannel (pfChannel *channel, void *data);
>
> static pfLightSource *ls1, *ls2, *ls3;
>
> int main()
> {
> pfInit();
> pfConfig();
>
> pfScene *scene;
>
> scene = pfNewScene();
>
> pfNode *node = LoadFile( "tmp.sv", NULL );
>
> pfAddChild( scene, node );
>
> pfPipe *pipe;
>
> pipe = pfGetPipe(0);
> pfInitPipe(pipe, OpenPipeline);
>
> float near, far, v_fov;
> near = 0.1; far = 8000.0; v_fov =0.0;
>
> //
> // l/r/m channels
> //
> float hfov1 = 90.0f, hfov2 = 35.0f;
> //
> // Set both hfov1 and hfov2 to be equal and everything works OK
> //
> //hfov1 = hfov2 = 55.0;
> v_fov = 60.0f;
>
> pfChannel *left = pfNewChan(pfGetPipe(0));
>
> float t = pfTan( v_fov*0.5f );
>
> float vpl = 0.15, vpr = 0.85, vpb = 0.0f, vpt = 1.0f;
> const float GAP = 0.000f;
>
> pfChanViewport( left, 0.0f, vpl-GAP, vpb, vpt );
> pfChanFOV( left, hfov2, v_fov );
>
> float gh, gv;
> pfGetChanFOV( left, &gh, &gv );
> cout << gh << " " << gv << endl;
>
> pfChannel *middle = pfNewChan(pfGetPipe(0));
> pfChanViewport( middle, vpl, vpr, vpb, vpt );
> pfChanFOV( middle, hfov1, v_fov );
> pfGetChanFOV( middle, &gh, &gv );
> cout << gh << " " << gv << endl;
>
> pfChannel *right = pfNewChan(pfGetPipe(0));
> pfChanViewport( right, vpr+GAP, 1.0f, vpb, vpt );
> pfChanFOV( right, hfov2, v_fov );
>
> pfChanScene( middle, scene );
> pfChanScene( left, scene );
> pfChanScene( right, scene );
>
> ls1 = pfNewLSource();
> pfLightColor( ls1, 1.0f, 1.0f, 1.0f );
> pfLightPos( ls1, 0.0f, 0.0f, -1.0f, 0.0f );
> pfAddChild(scene, ls1 );
>
> ls2 = pfNewLSource();
> pfLightColor( ls2, 0.6f, 0.6f, 0.6f );
> pfLightPos( ls2, -2.0f, -1.0f, 0.1f, 0.0f );
> pfAddChild(scene, ls2 );
> pfLightOn( ls2 );
>
> ls3 = pfNewLSource();
> pfLightColor( ls3, 0.3f, 0.3f, 0.3f );
> //pfLightPos( ls3, 2.0f, 1.0f, 0.1f, 0.0f );
> //pfLightPos( ls3, 1.0f, 2.0f, 0.1f, 0.0f );
> pfLightPos( ls3, 1.0f, 1.5f, 0.1f, 0.0f );
> pfAddChild(scene, ls3 );
> pfLightOn( ls3 );
>
> pfInitClock(0.0f);
>
> pfCullFace( PFCF_BACK );
>
> int exit_flag = 0;
> pfVec3 xyz = {2.0f, 0.0f, 1.5f};
> pfVec3 hpr = {90.0f, 0.0f, 0.0f};
>
> while( exit_flag < 1000 ) {
> exit_flag++;
>
> pfSync();
> float xx = (float( getvaluator(MOUSEX) ) - 1280.0*0.5) / (1280.0*0.5);
>
> pfSetVec3( hpr, 90.0 - xx*hfov1, 0.0f, 0.0f );
> pfChanView( middle, xyz, hpr );
>
> pfSetVec3( hpr, 90.0 - xx*hfov1 + 0.5*(hfov1 + hfov2), 0.0f, 0.0f );
> pfChanView( left, xyz, hpr );
>
> pfSetVec3( hpr, 90.0 - xx*hfov1 - 0.5*(hfov1 + hfov2), 0.0f, 0.0f );
> pfChanView( right, xyz, hpr );
>
> pfFrame();
> }
> pfExit();
>
> return 0;
> }
>
>
> static void
> OpenPipeline (pfPipe *p)
> {
> foreground();
>
> prefposition(0, 1280, 0, 1024);
> noborder();
> winopen("IRIS Performer");
>
> pfInitGfx(p);
>
> pfApplyMtl(pfNewMtl( NULL ));
>
> pfEnable( PFEN_LIGHTING );
> pfLightModel *lmodel = pfNewLModel( NULL );
> pfLModelAmbient( lmodel, 0.4f, 0.4f, 0.4f );
> pfApplyLModel( lmodel );
>
> pfTexEnv *tev = pfNewTEnv( 0 );
> pfTEnvMode( tev, PFTE_MODULATE );
> pfApplyTEnv( tev );
>
> }
>
> static void DrawChannel (pfChannel *channel, void *data)
> {
> pfClearChan(channel);
>
> pfDraw();
> }
>
>
>
> ------------------------------------------------------------------------
> Roy Ruddle, Principal Researcher | School of Psychology
> Tel: 01222 874523 (direct) | University of Wales College of Cardiff
> 01222 874007 (messages) | PO Box 901
> Fax: 01222 874858 | Cardiff CF1 3YG
> Email: Ruddle++at++CARDIFF.AC.UK | UK
>
>
>


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:39 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.