private void OnShowSimplifiedShadowCheckBoxCheckedChanged(object sender, RoutedEventArgs e) { if (!this.IsLoaded) { return; } if (ShowSimplifiedShadowCheckBox.IsChecked ?? false) { if (MainDXViewportView.DXScene != null) { if (_simplifiedShadowObjectsRenderingQueue == null) { // Create a custom RenderingQueue that will contain our simplified Model3D. // The objects in this RenderingQueue will not be rendered with standard rendering (IsRenderedWithCustomRenderingStep = true) // but will be only rendered when shadow objects are rendered (setting _planarShadowRenderingProvider.FilterRenderingQueuesFunction) _simplifiedShadowObjectsRenderingQueue = new RenderingQueue("SimplifiedShadowObjectsRenderingQueue") { IsRenderedWithCustomRenderingStep = true // prevent rendering objects in this queue with standard rendering }; MainDXViewportView.DXScene.AddRenderingQueueBefore(_simplifiedShadowObjectsRenderingQueue, MainDXViewportView.DXScene.BackgroundRenderingQueue); } _planarShadowRenderingProvider.FilterRenderingQueuesFunction = delegate(RenderingQueue queue) { return(ReferenceEquals(queue, _simplifiedShadowObjectsRenderingQueue)); }; } if (_simplifiedVisual3D == null) { var simplifiedModel3D = CreateSimplifiedModel3D(_loadedModel3D); _simplifiedVisual3D = simplifiedModel3D.CreateModelVisual3D(); // This object will be put into our custom rendering queue _simplifiedVisual3D.SetDXAttribute(DXAttributeType.CustomRenderingQueue, _simplifiedShadowObjectsRenderingQueue); } MainViewport.Children.Add(_simplifiedVisual3D); } else { if (_simplifiedVisual3D != null) { MainViewport.Children.Remove(_simplifiedVisual3D); } if (_planarShadowRenderingProvider != null) { _planarShadowRenderingProvider.FilterRenderingQueuesFunction = null; // Reset the filter method - this will render all standard rendering queues again } } }
private void AddOverlayObject(ModelVisual3D modelVisual3D) { modelVisual3D.SetDXAttribute(DXAttributeType.CustomRenderingQueue, MainDXViewportView.DXScene.OverlayRenderingQueue); MainViewport.Children.Add(modelVisual3D); }