private void SelectObject(Ab3d.UIElements.BoxUIElement3D selectedBox) { // Deselect currently selected model if (_selectedBoxModel != null) { // Set material back to normal _selectedBoxModel.Material = _normalMaterial; _selectedBoxModel.BackMaterial = null; // Allow hit testing again - so user can select that object again _selectedBoxModel.IsHitTestVisible = true; // IMPORTANT !!! // When ModelMoverVisual3D is used with EventManager3D // we also need to remove the _selectedBoxModel from hit-testing. // This way user will be able to click on the movable arrows that lie inside the _selectedBoxModel (otherwise the _selectedBoxModel will receive the clicks) _eventManager.RemoveExcludedVisual3D(_selectedBoxModel); _selectedBoxModel = null; } _selectedBoxModel = selectedBox; if (_selectedBoxModel == null) { return; } // Prevent hit-testing in selected model // This will allow clicking on the parts of move arrows that are inside the selected model // Note that IsHitTestVisible is available only on models derived from UIElement3D (if you need that on GeometryModel3D or ModelVisual3D, then use ModelUIElement3D as parent of your model) _selectedBoxModel.IsHitTestVisible = false; // IMPORTANT !!! // When ModelMoverVisual3D is used with EventManager3D // we also need to remove the _selectedBoxModel from hit-testing. // This way user will be able to click on the movable arrows that lie inside the _selectedBoxModel (otherwise the _selectedBoxModel will receive the clicks) _eventManager.RegisterExcludedVisual3D(_selectedBoxModel); // Change material to semi-transparent Silver _selectedBoxModel.Material = _selectedMaterial; _selectedBoxModel.BackMaterial = _selectedMaterial; // We also set BackMaterial so the inner side of boxes will be visible // To render the transpant object correctly, we need to sort the objects so that the transparent objects are rendered after other objects // We can use the TransparencySorter from Ab3d.PowerToys // Note that it is also possible to use TransparencySorter with many advanced features - see the Model3DTransparencySortingSample for more info TransparencySorter.SimpleSort(SceneObjectsContainer.Children); // In our simple case (we have only one transparent object), we could also manually "sort" the objects with moving the transparent object to the back of the Children collection: //SceneObjectsContainer.Children.Remove(_selectedBoxVisual3D); //SceneObjectsContainer.Children.Add(_selectedBoxVisual3D); if (_modelMover == null) { SetupModelMover(); } #if !USE_GENERIC_MODEL3D _modelMover.Position = _selectedBoxModel.CenterPosition; #else _startMovePosition = GetSelectedModelCenter(); _modelMover.Position = _startMovePosition; #endif // Tell ModelDecoratorVisual3D which Model3D to show SelectedModelDecorator.TargetModel3D = _selectedBoxModel.Model; // NOTE: // When the 3D models are organized into hierarchy of models with using different ModelVisual3D or Model3DGroup objects, // you also need to so specify the SelectedModelDecorator.RootModelVisual3D in order to get the correct position of the TargetModel3D }