public void OnDragging(ViewControl vc, Point scrPt) { m_hasHoverPt = HitTest(out m_hoverPt, scrPt, vc); if (!m_hasHoverPt) { return; } var nativeVC = vc as GUILayer.IViewContext; if (nativeVC == null) { return; } var game = vc.As <DesignViewControl>().DesignView.Context.As <IGame>(); if (game == null) { return; } if (ManipulatorContext.Objects.Count == 0) { return; } GUILayer.EditorInterfaceUtils.ScatterPlaceOperation op; var sceneManager = nativeVC.SceneManager; using (var editor = sceneManager.GetPlacementsEditor()) { using (var scene = sceneManager.GetIntersectionScene()) { op = GUILayer.EditorInterfaceUtils.CalculateScatterOperation( editor, scene, ManipulatorContext.Objects.Select(C => _assetService.AsAssetName(new Uri(C.Model))), XLEBridgeUtils.Utils.AsVector3(m_hoverPt), ManipulatorContext.Radius, ManipulatorContext.Density); } } foreach (var d in op._toBeDeleted) { var adapter = m_nativeIdMapping.GetAdapter(d.Item1, d.Item2).As <DomNodeAdapter>(); if (adapter != null) { adapter.DomNode.RemoveFromParent(); } } var resourceResolvers = Globals.MEFContainer.GetExportedValues <IResourceResolver>(); var resourceConverter = Globals.MEFContainer.GetExportedValue <ResourceConverterService>(); foreach (var s in op._creationPositions) { // select a random entry from the list of objects var o = ManipulatorContext.SelectRandomObject(m_rng); IResource resource = null; foreach (var d in resourceResolvers) { resource = d.Resolve(new Uri( new Uri(System.Environment.CurrentDirectory + "\\"), o.Model + "<model")); if (resource != null) { break; } } if (resource != null) { var resGob = resourceConverter.Convert(resource); if (resGob != null) { resGob.As <DomNode>().InitializeExtensions(); var hierarchical = game.AsAll <IHierarchical>(); foreach (var h in hierarchical) { if (h.AddChild(resGob)) { break; } } var transform = resGob.As <LevelEditorCore.ITransformable>(); transform.Translation = XLEBridgeUtils.Utils.AsVec3F(s); transform.Rotation = new Sce.Atf.VectorMath.Vec3F(0.0f, 0.0f, (float)(m_rng.NextDouble()) * 2.0f * 3.14159f); // set the material name (if we can) var p = resGob.As <Placements.XLEPlacementObject>(); if (p != null) { p.Material = new Uri(o.Material); p.Supplements = o.Supplements; } } } } }