How to limit rotation
ejleigh wrote at 2012-06-12 03:28:
I have a terrain model with objects on top and I'm trying to find a good way to prevent the user from rotaing the scene such that he can look underneath the terrrain model. It seemed like the best way would be to derive a new class from CameraController and override the OnManipulationDelta method, but unfortunately you cannot set the camera contoller in the HelixViewPort3D. At the moment I'm setting the RotationSensitivity to a low value when the camera Up vector approaches level, but that only kindof works. It's not ideal. Is there a better way?
objo wrote at 2012-06-15 06:38:
The CameraController is created in the control template of the HelixViewport3D, so you have to override the control template. http://wpftutorial.net/templates.html
Or, use the Camera's Position and LookDirection coerce value callbacks, and enforce the Z values to to be positive and negative, respectively.
http://msdn.microsoft.com/en-us/library/ms754209.aspx
http://msdn.microsoft.com/en-us/library/system.windows.coercevaluecallback.aspx
I have not tried this, but I think it should work.
lightxx wrote at 2013-02-26 10:11:
thank you very much!
objo wrote at 2013-03-13 07:12:
Customer support service by UserEcho
By overriding coerce value callbacks the limitation would be applied on the camera not for rotation only. In real life scenarios, I might prevent my users from doing such things but I don't want to limit myself. The correct way of doing this would be to open the mouse handlers to be extended, or create a callback or handler that could modify the rotation delta before application.
I don't really understand why these handlers are completely hidden from the developers.
Right, if you still want to set camera properties outside the 'valid' range, the coercing solution may not be good.
I think we need some real life examples/demos to solve this issue. I see a lot of possible requirements to what should be restricted (camera position, direction, field of view etc) and it would be great if we could cover them all...