/// <summary> /// Updates the clipping object. /// </summary> private void UpdateClipping() { var vp = Visual3DHelper.GetViewport3D(this); if (vp == null) { return; } this.Clipping = new CohenSutherlandClipping(10, vp.ActualWidth - 20, 10, vp.ActualHeight - 20); }
/// <summary> /// Zooms to fit the extents of the specified viewport. /// </summary> /// <param name="actualCamera"> /// The actual camera. /// </param> /// <param name="viewport"> /// The viewport. /// </param> /// <param name="animationTime"> /// The animation time. /// </param> public static void ZoomExtents(PerspectiveCamera actualCamera, Viewport3D viewport, double animationTime) { var bounds = Visual3DHelper.FindBounds(viewport.Children); var diagonal = new Vector3D(bounds.SizeX, bounds.SizeY, bounds.SizeZ); if (bounds.IsEmpty || diagonal.LengthSquared == 0) { return; } ZoomExtents(actualCamera, viewport, bounds, animationTime); }
/// <summary> /// The composition target_ rendering. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The event arguments. /// </param> protected void OnCompositionTargetRendering(object sender, EventArgs e) { if (!Visual3DHelper.IsAttachedToViewport3D(this)) { return; } if (this.UpdateTransforms()) { this.UpdateClipping(); this.UpdateGeometry(); } }
/// <summary> /// Updates the transforms. /// </summary> /// <returns> /// True if the transform was changed. /// </returns> public bool UpdateTransforms() { var newTransform = Visual3DHelper.GetViewportTransform(this.visual); if (double.IsNaN(newTransform.M11)) { return(false); } if (!newTransform.HasInverse) { return(false); } if (newTransform == this.visualToScreen) { return(false); } this.visualToScreen = this.screenToVisual = newTransform; this.screenToVisual.Invert(); return(true); }