Welcome to MSDN Blogs Sign in | Join | Help

Constraining camera movement

Just got a good question:  what if I want to prevent the camera from moving outside certain bounds, for example to restrict altitude?

Technically it may be best to implement your own CameraController, so that you can make sure the restrictions are done smoothly for all cases.  But for many cases a simple mechanism will do.  Here it is:

this.Host.CameraControllers.CameraChanged += new CameraControllerManager.CameraChangedEventHandler(CameraControllers_CameraChanged);

 

void CameraControllers_CameraChanged(Microsoft.MapPoint.Rendering3D.Cameras.PredictiveCamera camera)

{

   if (camera.Viewpoint.Position.Altitude > 10000)

   {

      camera.Viewpoint.Position.Altitude = 10000;

   }

}

Published Friday, August 07, 2009 6:54 PM by NikolaiF
Filed under:

Comments

No Comments

Anonymous comments are disabled
 
Page view tracker