Exemple #1
0
        public static bool SetupFrustum(ViewportInfo vp, ClippingInfo clipping)
        {
            double n0 = vp.FrustumNear;
            double f0 = vp.FrustumFar;

            // Because picking relies heavily on the projection, we first set the
            // viewport frustum here, capture and save it, then let the conduits
            // do what ever they want with it...eventually the viewport will be put
            // back to the captured state before leaving the pipeline...
            ClippingInfo m_SavedClipping = clipping;

            vp.SetFrustumNearFar(clipping.bbox_near, clipping.bbox_far,
                                 clipping.min_near_dist, clipping.min_near_over_far,
                                 clipping.target_dist
                                 );

            vp.GetFrustum(out m_SavedClipping.left,
                          out m_SavedClipping.right,
                          out m_SavedClipping.bottom,
                          out m_SavedClipping.top,
                          out m_SavedClipping.bbox_near,
                          out m_SavedClipping.bbox_far);

            // Next, set the values that the pipeline will actually use...
            if (!(AdjustFrustum(vp, clipping)))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        private static bool CalcClippingPlanesInternal(ViewportInfo vp, ClippingInfo clipping)
        {
            bool isPerspective = vp.IsPerspectiveProjection;

            // iCalcBoundingBox() has set clipping.bbox and it cannot
            // be changed or ignored.
            GetBoundingBoxNearFarHelper(
                clipping.bbox,
                isPerspective,
                vp.CameraLocation,
                vp.CameraZ,
                clipping.bbox_near,
                clipping.bbox_far
                );

            // Do sanity checks and update ON_Viewport frustum if it uses
            // parallel projection and near <= 0.0
            CalcClippingPlanesHelper(clipping.bbox_near, clipping.bbox_far, vp);

            // Set target_dist
            clipping.target_dist = (vp.CameraLocation - vp.TargetPoint) * vp.CameraZ;
            if (double.IsNaN(clipping.target_dist))
            {
                clipping.target_dist = 0.5 * (clipping.bbox_near + clipping.bbox_far);
            }

            return(true);
        }
Exemple #3
0
        public static bool CalcClippingPlanes(ViewportInfo vp, ClippingInfo m_Clipping)
        {
            // Initialize m_Clipping frustum info.
            // (left,right,top,bottom are not used but should be initialized).
            //const ON::view_projection projection = vp.Projection();

            vp.GetFrustum(out m_Clipping.left,
                          out m_Clipping.right,
                          out m_Clipping.bottom,
                          out m_Clipping.top,
                          out m_Clipping.bbox_near,
                          out m_Clipping.bbox_far);

            m_Clipping.min_near_dist     = 0.000100;
            m_Clipping.min_near_over_far = 0.000100;
            m_Clipping.target_dist       = (vp.CameraLocation - vp.TargetPoint) * vp.CameraZ;

            // Call virtual function that looks at m_Clipping.bbox and sets
            // m_Clipping.bbox_near and m_Clipping.bbox_far
            if (!CalcClippingPlanesInternal(vp, m_Clipping))
            {
                return(false);
            }

            if (double.IsNaN(m_Clipping.bbox_far) ||
                double.IsNaN(m_Clipping.bbox_near) ||
                m_Clipping.bbox_far <= m_Clipping.bbox_near ||
                (vp.IsPerspectiveProjection && m_Clipping.bbox_near <= 1.0e-12) ||
                (vp.IsPerspectiveProjection && m_Clipping.bbox_far > 1.0e16 * m_Clipping.bbox_near) ||
                m_Clipping.bbox_near > 1.0e30 ||
                m_Clipping.bbox_far > 1.0e30
                )
            {
                // Restore settings to something more sane
                vp.GetFrustum(out m_Clipping.left,
                              out m_Clipping.right,
                              out m_Clipping.bottom,
                              out m_Clipping.top,
                              out m_Clipping.bbox_near,
                              out m_Clipping.bbox_far);

                m_Clipping.min_near_dist     = 0.000100;
                m_Clipping.min_near_over_far = 0.000100;
                m_Clipping.target_dist       = (vp.CameraLocation - vp.TargetPoint) * vp.CameraZ;
            }

            return(true);
        }
        public static bool CalcClippingPlanes(ViewportInfo vp, ClippingInfo m_Clipping)
        {
            // Initialize m_Clipping frustum info.
            // (left,right,top,bottom are not used but should be initialized).
            //const ON::view_projection projection = vp.Projection();

            vp.GetFrustum(out m_Clipping.left,
                          out m_Clipping.right,
                          out m_Clipping.bottom,
                          out m_Clipping.top,
                          out m_Clipping.bbox_near,
                          out m_Clipping.bbox_far);

            m_Clipping.min_near_dist     = 0.000100;
            m_Clipping.min_near_over_far = 0.000100;
            m_Clipping.target_dist = (vp.CameraLocation - vp.TargetPoint)*vp.CameraZ;

            // Call virtual function that looks at m_Clipping.bbox and sets
            // m_Clipping.bbox_near and m_Clipping.bbox_far
            if ( !CalcClippingPlanesInternal( vp, m_Clipping ) )
                return false;

            if ( double.IsNaN(m_Clipping.bbox_far)
                || double.IsNaN(m_Clipping.bbox_near)
                || m_Clipping.bbox_far <= m_Clipping.bbox_near
                || (vp.IsPerspectiveProjection && m_Clipping.bbox_near <= 1.0e-12)
                || (vp.IsPerspectiveProjection  && m_Clipping.bbox_far > 1.0e16*m_Clipping.bbox_near)
                || m_Clipping.bbox_near > 1.0e30
                || m_Clipping.bbox_far  > 1.0e30
                )
            {

                // Restore settings to something more sane
                vp.GetFrustum(out m_Clipping.left,
                              out m_Clipping.right,
                              out m_Clipping.bottom,
                              out m_Clipping.top,
                              out m_Clipping.bbox_near,
                              out m_Clipping.bbox_far);

                m_Clipping.min_near_dist     =  0.000100;
                m_Clipping.min_near_over_far =  0.000100;
                m_Clipping.target_dist = (vp.CameraLocation - vp.TargetPoint)*vp.CameraZ;
            }

            return true;
        }
Exemple #5
0
 private static bool AdjustFrustum(ViewportInfo vp, ClippingInfo clipping)
 {
     vp.SetFrustumNearFar(vp.FrustumNear * 0.1, vp.FrustumFar * 10);
     return(true);
 }
        private static bool CalcClippingPlanesInternal(ViewportInfo vp, ClippingInfo clipping)
        {
            bool isPerspective = vp.IsPerspectiveProjection;

            // iCalcBoundingBox() has set clipping.bbox and it cannot
            // be changed or ignored.
            GetBoundingBoxNearFarHelper (
                clipping.bbox,
                isPerspective,
                vp.CameraLocation,
                vp.CameraZ,
                clipping.bbox_near,
                clipping.bbox_far
            );

            // Do sanity checks and update ON_Viewport frustum if it uses
            // parallel projection and near <= 0.0
            CalcClippingPlanesHelper(clipping.bbox_near, clipping.bbox_far, vp);

            // Set target_dist
            clipping.target_dist = (vp.CameraLocation - vp.TargetPoint)* vp.CameraZ;
            if ( double.IsNaN(clipping.target_dist) )
                clipping.target_dist = 0.5*(clipping.bbox_near + clipping.bbox_far);

            return true;
        }
 private static bool AdjustFrustum(ViewportInfo vp, ClippingInfo clipping)
 {
     vp.SetFrustumNearFar (vp.FrustumNear * 0.1, vp.FrustumFar * 10);
     return true;
 }
        public static bool SetupFrustum(ViewportInfo vp, ClippingInfo clipping)
        {
            double    n0 = vp.FrustumNear;
            double    f0 = vp.FrustumFar;

            // Because picking relies heavily on the projection, we first set the
            // viewport frustum here, capture and save it, then let the conduits
            // do what ever they want with it...eventually the viewport will be put
            // back to the captured state before leaving the pipeline...
            ClippingInfo m_SavedClipping = clipping;
            vp.SetFrustumNearFar(clipping.bbox_near, clipping.bbox_far,
                                 clipping.min_near_dist, clipping.min_near_over_far,
                                 clipping.target_dist
                                 );

            vp.GetFrustum(out m_SavedClipping.left,
                          out m_SavedClipping.right,
                          out m_SavedClipping.bottom,
                          out m_SavedClipping.top,
                          out m_SavedClipping.bbox_near,
                          out m_SavedClipping.bbox_far);

            // Next, set the values that the pipeline will actually use...
            if (!(AdjustFrustum(vp, clipping)))
                return false;

            return true;
        }