Exemple #1
0
        /// <summary>
        /// Creates a refraction of a <see cref="View"/> and adds it to <see cref="View.ChildViews"/>
        /// </summary>
        /// <param name="baseView">The <see cref="View"/> the refraction is based on</param>
        /// <param name="refractPlane">A plane alongside which the view shall be refracted</param>
        /// <param name="clipTolerance">How much to shift the clip plane away from the refract plane</param>
        /// <returns>The <see cref="WaterView"/> representing the refraction</returns>
        public static WaterView CreateRefraction(View baseView, DoublePlane refractPlane, float clipTolerance)
        {
            #region Sanity checks
            if (baseView == null)
            {
                throw new ArgumentNullException(nameof(baseView));
            }
            if (refractPlane == default(DoublePlane))
            {
                throw new ArgumentNullException(nameof(refractPlane));
            }
            #endregion

            // Clone and modify the camera
            var newCamera = new CloneCamera(baseView.Camera)
            {
                Name      = baseView.Camera.Name + " Refraction",
                ClipPlane = new DoublePlane(refractPlane.Point - refractPlane.Normal * clipTolerance, refractPlane.Normal)
            };

            // Create the new view, make sure the camera stays in sync, copy default properties
            var newView = new WaterView(baseView, newCamera, reflection: false)
            {
                Name            = baseView.Name + " Refraction",
                BackgroundColor = baseView.BackgroundColor
            };

            baseView.ChildViews.Add(newView);
            return(newView);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new view for rendering <see cref="Water"/> refractions or reflections
 /// </summary>
 /// <param name="baseView">The <see cref="View"/> to base this support-view on</param>
 /// <param name="camera">The <see cref="CloneCamera"/> to look at the <see cref="Scene"/> with</param>
 /// <param name="reflection">True if this is a <see cref="WaterViewSource.ReflectedView"/>, <c>false</c> if this is a <see cref="WaterViewSource.RefractedView"/></param>
 private WaterView(View baseView, CloneCamera camera, bool reflection) :
     base(baseView, camera)
 {
     _cloneCamera = camera;
     Reflection   = reflection;
 }