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 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); }