示例#1
0
        /* Set the perspective matrix of the pgraphics
         *  of the _pownerview so that something like _proportionofworldtoshow much of the world
         *  shows (0.1 would be a tenth of the world, 1.0 would be all of it,
         *  2.0 would mean show space aroudn the world so it takes up half the
         *  view.  Not const as stereo viewer flips position temporarily. */

        /*This tries to set _znear and _zfar
         *  so that each of the eight corners of the worldbox is between
         *  the planes cutting the attitudeTangent() direction at distances of _znear and _zfar from the
         *  position().  We don't take into account the corners that are behind the viewer.  If
         *  any point is behind or almost behind the viewer pos relative to the
         *  viewedirection we set _znear to cCritterViewer::MINZNEAR, which is typically 0.1. */

        public bool isVisible(cVector3 testpos)
        {
            /* _foveaproportion lies between 0.0 and 1.0. We say something is visible if it
             * appears on the inner foveaproportion central box of the viewer's image screen,
             * which is what you see in the view window. */
            if (!_perspective)
            {
                cRealBox2 fovea;
                fovea = OrthoViewRect;
                fovea = fovea.innerBox((1.0f - _foveaproportion) * fovea.MinSize);
                return(fovea.inside(new cVector2(testpos) - new cVector2(_position)));
            }
            else
            {
                cVector3 totestpos = (testpos - Position).normalize();
                return(Math.Abs(totestpos.angleBetween(AttitudeTangent)) <
                       _foveaproportion * 0.5f * _fieldofviewangle);
            }
        }