Translate, rotate and scale
#2
ModelMoverVisual3D, ModelScalarVisual3D and ModelRotatorVisual3D internally use UIElement3D objects that can get mouse events. But this is not possible when those objects are rendered by DXEngine - in this case the Viewport3D is not actually visible from the WPF's perspective and therefore the UIElement3D objects do not receive any mouse events.

When you put ModelMoverVisual3D, ModelScalarVisual3D and ModelRotatorVisual3D into an overlay Viewport3D (Viewport3D objects that is rendered on top of DXViewportView - is defined after DXViewportView and take the same space in the window), then you do not need to change anything because the UIElement3D objects will get mouse events because they are rendered by WPF's Viewport3D.

But when ModelMoverVisual3D, ModelScalarVisual3D and ModelRotatorVisual3D are rendered in the same 3D scene as other objects and are therefore rendered by DXEngine, then they will not get any mouse events.

As described in the comments for "Other Ab3d.PowerToys samples / ModelMover inside object" and "Other Ab3d.PowerToys samples / ModelRotatorSample" sample in Ab3d.DXEngine samples project, you need to do the following to add support for those objects in DXEngine (coped text from the comments):

When ModelMoverVisual3D is used inside DXEngine, the mouse events on UIElement3D objects that are used inside ModelMoverVisual3D will not work. Therefore ModelMoverVisual3D also supports using Ab3d.Utilities.EventManager3D that can process mouse events when inside Ab3d.DXEngine.

To make ModelMoverVisual3D work inside DXEngine, the following code changes need to be done:
1) EventManager3D needs to be created and its CustomEventsSourceElement must be set the DXViewportView
   or a parent Border or some other parent element that has Background property set (see line 69)

2) When ModelMoverVisual3D is created, we need to call the SubscribeWithEventManager3D method 
   on the created ModelMoverVisual3D and pass the EventManager3D as a parameter (see line 84)

3) To allow the user to click on arrows that are inside the selected model, we need to exclude the selected
   model from being processed by EventManager3D. This can be done by calling RegisterExcludedVisual3D on EventManager3D (see line 226)

4) Because we called RegisterExcludedVisual3D, we need to call RemoveExcludedVisual3D after the mouse moving is completed (see line 207)


Another option is to create an overlay Viewport3D and move the ModelMoverVisual3D, ModelScalarVisual3D and ModelRotatorVisual3D to it.
Andrej Benedik
  


Messages In This Thread
Translate, rotate and scale - by GraPhiX - 04-22-2021, 06:31 PM
RE: Translate, rotate and scale - by abenedik - 04-23-2021, 08:16 AM
RE: Translate, rotate and scale - by GraPhiX - 04-23-2021, 11:48 AM
RE: Translate, rotate and scale - by GraPhiX - 04-23-2021, 11:55 AM
RE: Translate, rotate and scale - by GraPhiX - 04-23-2021, 12:06 PM
RE: Translate, rotate and scale - by abenedik - 04-26-2021, 11:44 AM
RE: Translate, rotate and scale - by GraPhiX - 04-26-2021, 12:13 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)