예제 #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);
        }
예제 #2
0
 /// <summary>
 /// Creates a new reflect camera
 /// </summary>
 /// <param name="parentCamera">The parent camera to track</param>
 /// <param name="reflectPlane">The plane along which to reflect the world</param>
 public ReflectCamera(Camera parentCamera, DoublePlane reflectPlane) : base(parentCamera)
 {
     ReflectPlane = reflectPlane;
 }