How to limit rotation

Jun 12, 2012 at 2:28 AM

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?

 

Coordinator
Jun 15, 2012 at 5:38 AM

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.

Feb 26, 2013 at 10:11 AM
objo, could you please provide a simple example on how to do this? I guess limiting the rotation is quite a frequent requirement.
thank you very much!
Coordinator
Mar 13, 2013 at 7:12 AM