[Plib-cvs] plib/src/sg sg.h,1.47,1.48 sg.cxx,1.37,1.38
Brought to you by:
sjbaker
From: M?rten Str?m. <str...@us...> - 2002-09-09 09:07:06
|
Update of /cvsroot/plib/plib/src/sg In directory usw-pr-cvs1:/tmp/cvs-serv4601 Modified Files: sg.h sg.cxx Log Message: Added orthographic support to 'sgFrustum'. Index: sg.h =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sg.h,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- sg.h 2 Sep 2002 06:05:46 -0000 1.47 +++ sg.h 9 Sep 2002 09:07:02 -0000 1.48 @@ -1026,22 +1026,26 @@ class sgFrustum { - /* The parameters for a glFrustum or pfMakePerspFrust */ + /* Is the projection orthographic (or perspective)? */ + int ortho ; + + /* The parameters for glFrustum/glOrtho */ - SGfloat left, right, top, bot, nnear, ffar ; + SGfloat left, right, bot, top, nnear, ffar ; [...99 lines suppressed...] + void setOrtho ( const SGfloat w, const SGfloat h ) + { + ortho = TRUE ; + hfov = ( w <= 0 ) ? ( h * SG_THREE / SG_TWO ) : w ; + vfov = ( h <= 0 ) ? ( w * SG_THREE / SG_TWO ) : h ; + update () ; + } + void getNearFar ( SGfloat *n, SGfloat *f ) const { if ( n != (SGfloat *) 0 ) *n = nnear ; @@ -1104,6 +1144,8 @@ ffar = f ; update () ; } + + int isOrtho (void) const { return ortho ; } int contains ( const sgVec3 p ) const ; int contains ( const sgSphere *s ) const ; Index: sg.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sg.cxx,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- sg.cxx 2 Sep 2002 06:05:46 -0000 1.37 +++ sg.cxx 9 Sep 2002 09:07:03 -0000 1.38 @@ -565,97 +565,138 @@ { if ( fabs ( hfov ) < 0.1 || fabs ( vfov ) < 0.1 ) { - ulSetError ( UL_WARNING, "sgFrustum: Can't support fields of view narrower than 0.1 degrees."); + ulSetError ( UL_WARNING, ortho ? + "sgFrustum: Can't support width or height <0.1 units." : + "sgFrustum: Can't support fields of view narrower than 0.1 degrees." ) ; return ; } - /* Corners of screen relative to eye... */ [...265 lines suppressed...] + */ + + + if ( -sp1 > radius || -sp2 > radius || -sp3 > radius || -sp4 > radius ) return SG_OUTSIDE ; /* @@ -736,10 +819,8 @@ and we can save time elsewhere if we know that for sure. */ - if ( -s->getCenter() [ 2 ] - s->getRadius() > nnear && - -s->getCenter() [ 2 ] + s->getRadius() < ffar && - sp1 >= s->getRadius() && sp2 >= s->getRadius() && - sp3 >= s->getRadius() && sp4 >= s->getRadius() ) + if ( sp1 >= radius && sp2 >= radius && sp3 >= radius && sp4 >= radius + && -center[2] - radius >= nnear && -center[2] + radius <= ffar ) return SG_INSIDE ; return SG_STRADDLE ; |