/// <summary>
        /// Saves the <see cref="Viewport3D"/> to left/right bitmap files.
        /// </summary>
        /// <param name="view">The viewport.</param>
        /// <param name="fileName">Name of the file. "_L" and "_R" will be appended to the file name.</param>
        /// <param name="stereoBase">The stereo base.</param>
        /// <param name="background">The background brush.</param>
        /// <param name="m">The oversampling multiplier.</param>
        public static void SaveStereoBitmap(this Viewport3D view, string fileName, double stereoBase, Brush background = null, int m = 1)
        {
            var extension     = System.IO.Path.GetExtension(fileName);
            var directory     = System.IO.Path.GetDirectoryName(fileName) ?? string.Empty;
            var name          = System.IO.Path.GetFileNameWithoutExtension(fileName) ?? string.Empty;
            var leftFileName  = System.IO.Path.Combine(directory, name) + "_L" + extension;
            var rightFileName = System.IO.Path.Combine(directory, name) + "_R" + extension;

            var centerCamera = view.Camera as PerspectiveCamera;
            var leftCamera   = new PerspectiveCamera();
            var rightCamera  = new PerspectiveCamera();

            StereoHelper.UpdateStereoCameras(centerCamera, leftCamera, rightCamera, stereoBase);

            // save the left image
            using (var stream = File.Create(leftFileName))
            {
                view.Camera = leftCamera;
                view.SaveBitmap(stream, background, m);
            }

            // save the right image
            using (var stream = File.Create(rightFileName))
            {
                view.Camera = rightCamera;
                view.SaveBitmap(stream, background, m);
            }

            // restore original camera
            view.Camera = centerCamera;
        }
Beispiel #2
0
 /// <summary>
 /// Updates the cameras.
 /// </summary>
 public void UpdateCameras()
 {
     StereoHelper.UpdateStereoCameras(
         this.Camera,
         this.LeftCamera,
         this.RightCamera,
         this.StereoBase,
         this.CrossViewing,
         this.CopyUpVector,
         this.CopyDirectionVector);
 }
Beispiel #3
0
        /// <summary>
        /// Synchronizes the stereo model.
        /// </summary>
        public void SynchronizeStereoModel()
        {
            this.LeftViewport.Children.Clear();
            if (this.RightViewport != null)
            {
                this.RightViewport.Children.Clear();
            }

            foreach (var v in this.Children)
            {
                this.LeftViewport.Children.Add(v);
                if (this.RightViewport != null)
                {
                    Visual3D clone = StereoHelper.CreateClone(v);
                    if (clone != null)
                    {
                        this.RightViewport.Children.Add(clone);
                    }
                }
            }
        }