Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WPF app where different Model3Ds are arranged in a Model3DGroup and displayed in a Viewport3D. I may pan, zoom in / out the displayed models. Everything is handled programmatically in the .Net app.

The only Xaml code is to define a UserControl containing a Grid, Viewport and Canvas, which is then hosted in the main Winforms app.

I want to be able to rotate the Model3DGroup about an arbitrary point - for example the center of the Viewport3D - but NOT about the center of Model3DGroup. The center of rotation is not necessarily at the Viewport3D origin (0, 0, 0).

In practice, the desired center of rotation could be obtained from a mouse click.

VisualTreeHelper HitTest works if and only if there is something behind the desired point (i.e. the desired center of rotation) in the Viewport3D: then with a mouse click, I get a Point3D about which to rotate the display.

The problem is when there is nothing behind the center of rotation of the Viewport3D as can happen with some geometry combinations where there can be nothing to obtain a VisualTreeHelper.HitTest.

I have been hunting around for ideas, including 3DTools - but this seems to require a Visual as input whereas my app uses a Viewport3D for 3D components and a Canvas for 2D components within a Grid.

Anyone would have a suggestion ?

Thanks in advance - just in case ;-))

What I have tried:

Tried several of the functions in 3DTools, but a Visual is required which I cannot provide. Also tried VisualTreeHelper.HitTest, but as said above, it does not work if there is no model behind the point about which I want to rotate the Model3DGroup.
Posted
Updated 6-Jan-21 0:57am
v2
Comments
Member 14335464 6-Jan-21 15:00pm    
Good day Gerry - thank you for the reply. Could you expand on this a bit ? I am not sure I see where and how to use this transparent rectangle shape. Claude

Use a transparent rectangle; "shapes" can take event handlers; "panels" can't.

Place your other objects over the rectangle; you can still use the coordinates of any grid underneath the rectangle; it's just a matter of z-order.
 
Share this answer
 
Good day Gerry - thank you for the reply. Could you expand on this a bit ? I am not sure I see where and how to use this transparent rectangle shape. Claude
 
Share this answer
 
Comments
Richard Deeming 6-Jan-21 9:19am    
If you want to reply to a solution, click the "Have a Question or Comment?" button under the solution and post a comment. Do not post your comment as a new "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900