Пример #1
0
        public OutlinesSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            CreateSceneObjects();

            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                if (MainDXViewportView.DXScene == null) // When using WPF 3D rendering
                {
                    return;
                }

                SetupOutlineRenderingStep();
            };

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();

                DisposeOutlineBackBuffers();
            };
        }
Пример #2
0
        public OptimizedTubePathSample()
        {
            InitializeComponent();


            _disposables = new DisposeList();

            MainDXViewportView.DXSceneDeviceCreated += delegate(object sender, EventArgs args)
            {
                _solidColorEffect = MainDXViewportView.DXScene.DXDevice.EffectsManager.GetEffect <SolidColorEffect>();
                _disposables.Add(_solidColorEffect);

                _stopwatch = new Stopwatch();
                _stopwatch.Start();

                AddSpirals_MeshObjectNode(10, 10, 5000, useMultiThreading: true);

                // Uncomment to see how the tubes are created in a standard Ab3d.PowerToys way.
                //AddSpirals_TubePathVisual3D(10, 10, 5000);

                // To see how to use instancing to draw tube paths, uncomment the following line.
                // Note: In this case is instancing slower then rendering a fixed geometry because the task for the GPU is much more complicated in case of instancing.
                //AddInstancedSpirals(10, 10, 5000);
            };

            // Subscribe to get event when the first frame is rendered
            MainDXViewportView.SceneRendered += MainDXViewportViewOnSceneRendered;

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();
            };
        }
Пример #3
0
        public ScreenSpaceLineNodeSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            var linePositions = CreateLinePositions(xOffset: 0, zOffset: -50);

            _screenSpaceLineNode1 = CreateLinesWithPositions(linePositions, isLineStrip: false, isPolyLine: false, isLineClosed: false, lineColor: Colors.Blue, xOffset: -90);
            AddTextBlockVisual3D(xOffset: -90, isLineStrip: false, isPolyLine: false);

            _screenSpaceLineNode2 = CreateLinesWithPositions(linePositions, isLineStrip: true, isPolyLine: false, isLineClosed: false, lineColor: Colors.Green, xOffset: -30);
            AddTextBlockVisual3D(xOffset: -30, isLineStrip: true, isPolyLine: false);

            _screenSpaceLineNode3 = CreateLinesWithPositions(linePositions, isLineStrip: true, isPolyLine: true, isLineClosed: false, lineColor: Colors.Red, xOffset: 30);
            AddTextBlockVisual3D(xOffset: 30, isLineStrip: true, isPolyLine: true);

            _screenSpaceLineNode4 = CreateLinesWithLineMesh(linePositions, isLineStrip: false, isLineClosed: false, isPolyLine: false, lineColor: Colors.Orange, xOffset: 90, screenSpaceLineMesh: out _screenSpaceLineMesh);
            AddTextBlockVisual3D(xOffset: 90, "using\r\nScreenSpaceLineMesh");

            Unloaded += delegate
            {
                Dispose();
            };
        }
Пример #4
0
        public BackgroundAndOverlayRendering()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                if (MainDXViewportView.DXScene == null)
                {
                    return; // Probably WPF 3D rendering
                }
                AddStandardRenderedObjects();

                PrepareAlwaysOnTopRendering();
                AddCustomRenderedObjects();

                AddCustomRenderedLines();
            };


            // IMPORTANT:
            // It is very important to call Dispose method on DXSceneView after the control is not used any more (see help file for more info)
            this.Unloaded += delegate
            {
                if (_disposables != null)
                {
                    _disposables.Dispose();
                    _disposables = null;
                }

                MainDXViewportView.Dispose();
            };
        }
        public PBRRobotModel()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            AssimpLoader.LoadAssimpNativeLibrary();

            _dxMaterials   = new Dictionary <AssimpMaterial, PhysicallyBasedMaterial>();
            _texturesCache = new Dictionary <string, ShaderResourceView>();

            _textureFiles = new Dictionary <TextureMapTypes, string>();

            // Load scene when we have the DXDevice ready
            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                if (MainDXViewportView.DXScene == null) // Probably WPF 3D rendering
                {
                    return;
                }

                _rootFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"Resources\RobotModel\");

                LoadRobotPart(RobotParts.Main);
                LoadRobotPart(RobotParts.Claw);
            };



            UpdateLights();

            this.Unloaded += delegate(object sender, RoutedEventArgs args) { Dispose(); };
        }
        public PixelRenderingSample()
        {
            InitializeComponent();

            PixelSizeComboBox.ItemsSource   = new float[] { 0.1f, 0.5f, 1, 2, 4, 8 };
            PixelSizeComboBox.SelectedIndex = 3;

            _disposables = new DisposeList();

            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                CreateScene();
            };

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();

                if (_pixelEffect != null)
                {
                    _pixelEffect.Dispose();
                    _pixelEffect = null;
                }

                MainDXViewportView.Dispose();
            };
        }
Пример #7
0
        public PBRPropertiesSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            _modelsFolder   = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Models\");
            _texturesFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\BricksMaps\");

            // Load scene when we have the DXDevice ready
            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                if (MainDXViewportView.DXScene == null) // Probably WPF 3D rendering
                {
                    return;
                }

                CreateSampleScene();

                UpdateEnvironmentMap();
                UpdateLights();
            };

            this.Unloaded += delegate(object sender, RoutedEventArgs args) { Dispose(); };
        }
        // Creates a ScreenSpaceLineNode with multiple positions and with different colors for positions.
        public static ScreenSpaceLineNode CreateColoredLineNode(Vector3[] positions,
                                                                Color4[] lineColors,
                                                                float lineThickness,
                                                                DisposeList disposables,
                                                                bool isPolyLine = true) // when false we create a multi-line line (each individual line is defined by 2 position)
        {
            var lineMaterial = new PositionColoredLineMaterial()
            {
                LineColor      = Color4.White, // When PositionColors are used, then LineColor is used as a mask - each color is multiplied by LineColor - use White to preserve PositionColors
                LineThickness  = lineThickness,
                PositionColors = lineColors,
                IsPolyLine     = isPolyLine
            };

            // NOTE: When rendering multi-lines we need to set isLineStrip to false
            var screenSpaceLineNode = new ScreenSpaceLineNode(positions, isLineClosed: false, isLineStrip: isPolyLine, lineMaterial: lineMaterial);

            if (disposables != null)
            {
                disposables.Add(screenSpaceLineNode);
                disposables.Add(lineMaterial);
            }

            return(screenSpaceLineNode);
        }
        public ObjectIdRendering()
        {
            InitializeComponent();

            var boxMesh      = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 0, 0), new Size3D(1, 1, 1), 1, 1, 1).Geometry;
            int modelsXCount = 20;
            int modelsYCount = 1;
            int modelsZCount = 20;

            var model3DGroup = CreateModel3DGroup(boxMesh, new Point3D(0, 5, 0), new Size3D(500, modelsYCount * 10, 500), 10, modelsXCount, modelsYCount, modelsZCount);

            MainViewport.Children.Add(model3DGroup.CreateModelVisual3D());


            _disposables = new DisposeList();

            MainDXViewportView.DXSceneDeviceCreated += MainDxViewportViewOnDxSceneDeviceCreated;

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                if (_disposables != null)
                {
                    _disposables.Dispose();
                    _disposables = null;
                }

                MainDXViewportView.Dispose();
            };
        }
        private void Dispose()
        {
            _textureFiles.Clear();
            _texturesCache.Clear();
            _dxMaterials.Clear();

            _disposables.Dispose();
            _disposables = new DisposeList();
        }
        public MouseControllerForPointCloud()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            // Wait until DXScene is initialized and then create the data
            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                Mouse.OverrideCursor = Cursors.Wait;

                try
                {
                    Vector3[] positions;
                    var       positionsBounds = new BoundingBox(new Vector3(-100, 0, -100), new Vector3(100, 20, 100));

                    GenerateSinusPointCloudData(xCount: 300, yCount: 300,
                                                bounds: positionsBounds,
                                                positions: out positions);


                    var linearGradientBrush = CreateDataGradientBrush();
                    var gradientColorsArray = CreateGradientColorsArray(linearGradientBrush);

                    // Setup offsets and factors so that each position will be converted
                    // into a value from 0 to 1 based on the y position.
                    // This value will be used to define the color from the gradientColorsArray.

                    float minValue = positionsBounds.Minimum.Y;
                    float maxValue = positionsBounds.Maximum.Y;

                    var      offsets        = new Vector3(0, -minValue, 0);
                    var      factors        = new Vector3(0, 1.0f / (maxValue - minValue), 0);
                    Color4[] positionColors = CreatePositionColorsArray(positions, offsets, factors, gradientColorsArray);


                    InitializePointCloud(positions, positionsBounds, positionColors);


                    // Set DXScene and OptimizedPointMesh to PointCloudMouseCameraController1
                    PointCloudMouseCameraController1.DXScene            = MainDXViewportView.DXScene;
                    PointCloudMouseCameraController1.OptimizedPointMesh = _optimizedPointMesh;

                    PointCloudMouseCameraController1.MaxDistanceToAnyPosition = 1.0f;
                }
                finally
                {
                    Mouse.OverrideCursor = null;
                }
            };

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();
                MainDXViewportView.Dispose();
            };
        }
Пример #12
0
        private void CreateScene()
        {
            if (MainDXViewportView.DXScene == null)
            {
                return; // Not yet initialized or using WPF 3D
            }
            Mouse.OverrideCursor = Cursors.Wait;

            MainViewport.Children.Clear();
            _modelDisposables.Dispose();           // Dispose previously used resources

            _modelDisposables = new DisposeList(); // Start with a fresh DisposeList


            // Parse number of positions to render
            var regex    = new Regex(@".+\((?<width>\d+)\s?x\s?(?<length>[0-9,]+)\)");
            var sizeText = (string)SceneTypeComboBox.SelectedItem;

            var match = regex.Match(sizeText);

            int widthCount, lengthCount;

            if (match.Success)
            {
                string widthText  = match.Groups["width"].Value;
                string lengthText = match.Groups["length"].Value;

                widthText  = widthText.Replace(",", "");
                lengthText = lengthText.Replace(",", "");

                widthCount  = Int32.Parse(widthText);
                lengthCount = Int32.Parse(lengthText);
            }
            else
            {
                widthCount  = 100;
                lengthCount = 10000;
            }


            float widthStep  = widthCount <= 100 ? 0.1f : 0.01f;
            float lengthStep = lengthCount <= 10000 ? 0.1f : 0.01f;


            float pixelSize = (float)PixelSizeComboBox.SelectedItem;


            var positionsArray = CreatePositionsArray(new Point3D(0, 0, 0), widthCount, lengthCount, widthStep, lengthStep);

            ShowPositionsArray(positionsArray, pixelSize, Colors.Red.ToColor4(), Bounds.Empty);

            Mouse.OverrideCursor = null;
        }
Пример #13
0
        void CreateColoredPolyLine(int count, int layer)
        {
            Vector3 preV    = new Vector3(0, layer, 0);
            Color4  preC    = Color4.White;
            var     points  = new List <Point3D>();
            var     vectors = new List <Vector3>();
            var     colors  = new List <SharpDX.Color4>();

            for (int i = 0; i < count; i++)
            {
                float   max = 1f;
                Vector3 v   = new Vector3(1, layer, 0);
                v.X += preV.X;
                //Console.WriteLine("{0} : {1} {2} {3}", i, v.X, v.Y, v.Z);
                colors.Add(preC);
                points.Add(new Point3D((double)v.X, (double)v.Y, (double)v.Z));
                vectors.Add(v);
                preV = v;
            }

            DisposeList disposables   = new DisposeList();
            float       lineThickness = 5;
            bool        isPolyLine    = false;
            var         lineMaterial  = new PositionColoredLineMaterial()
            {
                LineColor      = Color4.White, // When PositionColors are used, then LineColor is used as a mask - each color is multiplied by LineColor - use White to preserve PositionColors
                LineThickness  = lineThickness,
                PositionColors = colors.ToArray(),
                IsPolyLine     = isPolyLine
            };

            // NOTE: When rendering multi-lines we need to set isLineStrip to false
            var screenSpaceLineNode = new ScreenSpaceLineNode(vectors.ToArray(), isLineClosed: false, isLineStrip: true, lineMaterial: lineMaterial);

            if (disposables != null)
            {
                disposables.Add(screenSpaceLineNode);
                disposables.Add(lineMaterial);
            }

            var sceneNodeVisual = new SceneNodeVisual3D(screenSpaceLineNode);

            MainViewport.Children.Add(sceneNodeVisual);
            bool isVisualConnected;
            var  lineSelectorData = new LineSelectorData(points, true);

            lineSelectorData.PositionsTransform3D = Ab3d.Utilities.TransformationsHelper.GetVisual3DTotalTransform(sceneNodeVisual, true, out isVisualConnected);
            _lineSelectorData.Add(lineSelectorData);
            var _data = new WLineRenderData(screenSpaceLineNode, lineSelectorData, lineMaterial, colors);

            lrData.Add(_data);
        }
        // Creates a ScreenSpaceLineNode with different colors for start and end position
        public static ScreenSpaceLineNode CreateColoredLineNode(Vector3 startPosition,
                                                                Vector3 endPosition,
                                                                Color4 startLineColor,
                                                                Color4 endLineColor,
                                                                float lineThickness,
                                                                DisposeList disposables)
        {
            // Convert positions to array
            var linePositions = new Vector3[] { startPosition, endPosition };
            var lineColors    = new Color4[]  { startLineColor, endLineColor };

            return(CreateColoredLineNode(linePositions, lineColors, lineThickness, disposables, isPolyLine: false));
        }
        public PBRModelViewer()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            AssimpLoader.LoadAssimpNativeLibrary();

            _dxMaterials   = new Dictionary <AssimpMaterial, PhysicallyBasedMaterial>();
            _texturesCache = new Dictionary <string, ShaderResourceView>();
            _textureFiles  = new Dictionary <TextureMapTypes, string>();

            // Support dragging .obj files to load the 3D models from obj file
            var dragAndDropHelper = new DragAndDropHelper(ViewportBorder, ".*");

            dragAndDropHelper.FileDroped += delegate(object sender, FileDropedEventArgs e)
            {
                FileNameTextBox.Text   = e.FileName;
                FolderPathTextBox.Text = System.IO.Path.GetDirectoryName(e.FileName);

                LoadFile(e.FileName, null);
            };

            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                if (MainDXViewportView.DXScene == null) // Probably WPF 3D rendering
                {
                    return;
                }

                string rootFolder     = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"Resources\RobotModel\");
                string fileName       = rootFolder + @"Robot_Claw.FBX";
                string texturesFolder = rootFolder + @"Robot_Claw_Maps\";

                FileNameTextBox.Text   = fileName;
                FolderPathTextBox.Text = texturesFolder;

                LoadFile(fileName, texturesFolder);
                UpdateEnvironmentMap();
            };

            this.Loaded += delegate(object sender, RoutedEventArgs args)
            {
                UpdateLights();
            };

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                Dispose();
            };
        }
Пример #16
0
        protected IDisposable ReadFileAndWriteWithoutClose(string path, string contents)
        {
            string virtualFile = Path.Combine(this.Enlistment.RepoRoot, path);
            string controlFile = Path.Combine(this.ControlGitRepo.RootPath, path);

            this.FileSystem.ReadAllText(virtualFile);
            this.FileSystem.ReadAllText(controlFile);

            DisposeList list = new DisposeList();

            list.Items.Add(this.FileSystem.OpenFileAndWrite(virtualFile, contents));
            list.Items.Add(this.FileSystem.OpenFileAndWrite(controlFile, contents));
            return(list);
        }
        public NormalMappingSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            MainDXViewportView.DXSceneDeviceCreated += OnDXSceneDeviceCreated;

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();
                MainDXViewportView.Dispose();
            };
        }
Пример #18
0
        public PixelRenderingOptionsSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            CreateScene();

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();
                MainDXViewportView.Dispose();
            };
        }
Пример #19
0
        private void Dispose()
        {
            if (_disposables != null)
            {
                _disposables.Dispose();
                _disposables = null;
            }

            if (_mainDXViewportView != null)
            {
                _mainDXViewportView.Dispose();
                _mainDXViewportView = null;
            }
        }
Пример #20
0
 private void Dispose(bool disposing)
 {
     Container.Clear();
     DisposeList?.ForEach(i => i.TryDispose());
     DisposeList?.Clear();
     if (disposing)
     {
         GC.SuppressFinalize(this);
     }
     if (DoLogging)
     {
         Logging.DebugMessage("context.Dispose({0})", disposing);
     }
 }
Пример #21
0
        public ObjectSelectionWithSubMeshes()
        {
            InitializeComponent();

            _disposables = new DisposeList();
            CreateScene();

            SetupHitTesting();

            this.Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                _disposables.Dispose();
                MainDXViewportView.Dispose();
            };
        }
Пример #22
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // Dispose managed resources here.
                    DisposeList.Dispose();
                    Disposing();
                }

                // Clear unmanaged resources here

                disposed = true;
            }
        }
Пример #23
0
        public OptimizedPointCloud()
        {
            InitializeComponent();

            PixelSizeComboBox.ItemsSource   = new float[] { 0.1f, 0.5f, 1, 2, 4, 8 };
            PixelSizeComboBox.SelectedIndex = 3;

            SceneTypeComboBox.ItemsSource = new string[]
            {
                "100,000 pixels (100 x 1,000)",
                "1 million pixels (100 x 10,000)",
                "10 million pixels (100 x 100,000)",
                "25 million pixels (1000 x 25,000)",
                "100 million pixels (1000 x 100,000)",
                "150 million pixels (1000 x 150,000)"
                // Bigger values would exceed max .Net array size in CreatePositionsArray method
            };
            SceneTypeComboBox.SelectedIndex = 1;

            _modelDisposables = new DisposeList();


            DXDiagnostics.IsCollectingStatistics = true; // Collect rendering statistics

            MainDXViewportView.DXSceneInitialized += delegate(object sender, EventArgs args)
            {
                CreateScene();
            };

            MainDXViewportView.SceneRendered += delegate(object sender, EventArgs args)
            {
                UpdateStatistics();
            };

            // Setup keyboard support
            this.Focusable       = true;             // by default Page is not focusable and therefore does not receive keyDown event
            this.PreviewKeyDown += OnPreviewKeyDown; // Use PreviewKeyDown to get arrow keys also (KeyDown event does not get them)
            this.Focus();

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _modelDisposables.Dispose();
                MainDXViewportView.Dispose();
            };
        }
        public void TestNonDisposeList()
        {
            Semaphore s = new Semaphore(0, 100);
            // Create object
            DisposeList disp = FileSystem.OS
                               .AddDisposeAction(d => s.Release(), s);

            //
            Assert.IsFalse(s.WaitOne(1000));
            Assert.IsFalse(disp.IsDisposeCalled);
            Assert.IsFalse(disp.IsDisposing);
            Assert.IsFalse(disp.IsDisposed);
            disp.Dispose();
            Assert.IsTrue(s.WaitOne(1000));
            Assert.IsFalse(disp.IsDisposeCalled);
            Assert.IsFalse(disp.IsDisposing);
            Assert.IsFalse(disp.IsDisposed);
        }
        public SubMeshesSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            CreateScene();

            StartAnimation();


            this.Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                CompositionRenderingHelper.Instance.Unsubscribe(this);

                _disposables.Dispose();

                MainDXViewportView.Dispose();
            };
        }
        public ScreenSpaceLineNodeSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            var linePositions = CreateLinePositions(0, 0);

            _screenSpaceLineNode1 = CreateLinesWithPositions(linePositions, isLineStrip: false, isLineClosed: false, lineColor: Colors.Blue, xOffset: -100);

            // To create poly-lines we need to set isLineStrip to true
            _screenSpaceLineNode2 = CreateLinesWithPositions(linePositions, isLineStrip: true, isLineClosed: false, lineColor: Colors.Green, xOffset: 0);

            _screenSpaceLineNode3 = CreateLinesWithLineMesh(linePositions, isLineStrip: false, isLineClosed: false, lineColor: Colors.Red, xOffset: 100, screenSpaceLineMesh: out _screenSpaceLineMesh);

            Unloaded += delegate
            {
                Dispose();
            };
        }
Пример #27
0
        private void DisposePointDataObjects()
        {
            if (_pointCloudDisposables != null)
            {
                _pointCloudDisposables.Dispose();
                _pointCloudDisposables = null;
            }

            if (_indexBuffers != null)
            {
                for (var i = 0; i < _indexBuffers.Length; i++)
                {
                    _indexBuffers[i].Dispose();
                }

                _indexBuffers = null;
            }

            _optimizedPointMeshes = null;
        }
Пример #28
0
        private void ClearAllScenes()
        {
            RootGrid.BeginInit();

            for (var i = RootGrid.Children.Count - 1; i >= 0; i--)
            {
                var oneChild = RootGrid.Children[i];

                if (!ReferenceEquals(oneChild, SettingsBorder) && !ReferenceEquals(oneChild, TitleTextBlock))
                {
                    RootGrid.Children.Remove(oneChild);
                }
            }

            RootGrid.EndInit();


            _disposables.Dispose();
            _disposables = new DisposeList();
        }
Пример #29
0
        public OptimizedMeshMorphing()
        {
            InitializeComponent();

            _meshMorphTimes      = new List <double>();
            _meshUpdateTimes     = new List <double>();
            _dxEngineUpdateTimes = new List <double>();

            DXDiagnostics.IsCollectingStatistics = true;

            CreateScene();
            CreateMorphedMesh();

            MainDXViewportView.SceneRendered += delegate
            {
                if (_dxEngineUpdateTimes == null)
                {
                    _dxEngineUpdateTimes = new List <double>();
                }

                if (MainDXViewportView.DXScene != null && MainDXViewportView.DXScene.Statistics != null)
                {
                    _dxEngineUpdateTimes.Add(MainDXViewportView.DXScene.Statistics.UpdateTimeMs);
                }
            };

            CompositionTarget.Rendering += CompositionTargetOnRendering;

            this.Unloaded += delegate(object sender, RoutedEventArgs e)
            {
                CompositionTarget.Rendering -= CompositionTargetOnRendering;

                if (_disposables != null)
                {
                    _disposables.Dispose();
                    _disposables = null;
                }

                MainDXViewportView.Dispose();
            };
        }
        public HitTestingSample()
        {
            InitializeComponent();

            _disposables = new DisposeList();

            _hitLinesModelVisual3D = new ModelVisual3D();
            MainViewport3D.Children.Add(_hitLinesModelVisual3D);


            CreateTestModels();

            MainDXViewportView.SceneRendered += MainDXViewportViewOnSceneRendered;

            this.Unloaded += delegate(object sender, RoutedEventArgs args)
            {
                _disposables.Dispose();

                MainDXViewportView.Dispose();
            };
        }