RotateFreeSurfaceCamera() public method

public RotateFreeSurfaceCamera ( System.Vector2 relativeMouseOffset ) : void
relativeMouseOffset System.Vector2
return void
Esempio n. 1
0
	    public override void Initialize()
	    {
			constBuffer = new ConstantBuffer(Game.GraphicsDevice, typeof(ConstData));

			#region Test input region
			Camera		= new GlobeCamera(Game);

			Camera.Viewport = new Viewport(0, 0, Game.GraphicsDevice.DisplayBounds.Width, Game.GraphicsDevice.DisplayBounds.Height);
			Camera.GoToPlace(GlobeCamera.Places.SaintPetersburg_VO);

		    //Game.GraphicsDevice.DisplayBoundsChanged +=
			//    (sender, args) =>
			//	    Camera.Viewport =
			//		    new Viewport(0, 0, Game.GraphicsDevice.DisplayBounds.Width,
			//			    Game.GraphicsDevice.DisplayBounds.Height);


			// Input bindings
		    Game.Mouse.Scroll += (sender, args) => {
				if(args.WheelDelta > 0)
					Camera.CameraZoom(-0.05f);
				else if(args.WheelDelta < 0)
					Camera.CameraZoom(0.05f);
		    };

		    Game.Mouse.Move += (sender, args) =>
		    {
				if (Game.InputDevice.IsKeyDown(Keys.LeftButton)) {
					DVector2 before, after;
					var beforeHit	= Camera.ScreenToSpherical(previousMousePosition.X, previousMousePosition.Y, out before);
					var afterHit	= Camera.ScreenToSpherical(args.Position.X, args.Position.Y, out after);

					if (beforeHit && afterHit) {
						Camera.Yaw		-= after.X - before.X;
						Camera.Pitch	+= after.Y - before.Y;
					}
				}
				if(Game.InputDevice.IsKeyDown(Keys.MiddleButton) && Camera.CameraState == GlobeCamera.CameraStates.ViewToPoint) {
					Camera.RotateViewToPointCamera(Game.InputDevice.RelativeMouseOffset);
			    }
				if(Game.InputDevice.IsKeyDown(Keys.RightButton) && Camera.CameraState == GlobeCamera.CameraStates.FreeSurface) {
					Camera.RotateFreeSurfaceCamera(Game.InputDevice.RelativeMouseOffset);
			    }
				previousMousePosition = new Vector2(args.Position.X, args.Position.Y);
		    };
			#endregion

			//Points = new PointsGisBatch(Game, 100)
		    //{
		    //	ImageSizeInAtlas	= new Vector2(36, 36),
		    //	TextureAtlas		= Game.Content.Load<Texture2D>("circles.tga")
		    //};
		    //
		    //var r = new Random();
		    //
		    //for (int i = 0; i < Points.PointsCpu.Length; i++) {
		    //    Points.PointsCpu[i] = new GeoPoint {
		    //		Lon		= DMathUtil.DegreesToRadians(30.301419 + 0.125 * r.NextDouble()),
		    //		Lat		= DMathUtil.DegreesToRadians(59.942562 + 0.125 * r.NextDouble()),
		    //		Color	= Color.White,
		    //		Tex0	= new Vector4(r.Next(0, 10), 0, 0.5f, 3.14f)
		    //    };
		    //}
		    //Points.UpdatePointsBuffer();


			//lines = new LinesGisBatch(Game, 2, true);
			//
			//lines.PointsCpu[0] = new GeoPoint
			//{
			//	Lon		= DMathUtil.DegreesToRadians(29),
			//	Lat		= DMathUtil.DegreesToRadians(59),
			//	Color	= Color.White,
			//	Tex0	= new Vector4(1, 1, 1, 1)
			//};
			//lines.PointsCpu[1] = new GeoPoint
			//{
			//	Lon		= DMathUtil.DegreesToRadians(30),
			//	Lat		= DMathUtil.DegreesToRadians(60),
			//	Color	= Color.White,
			//	Tex0	= new Vector4(1, 1, 1, 1)
			//};
			//lines.UpdatePointsBuffer();

			//heatMap = PolyGisBatch.GenerateRegularGrid(30.165024, 30.332521, 59.965494, 59.911272, 10, 64, 64, Globe.CurrentMapSource.Projection);
		    //heatMap.MaxHeatMapLevel = 1.0f;
		    //heatMap.InterpFactor	= 1.0f;
			//
			//heatMap.ClearData();
		    //for (int i = 0; i < 100; i++) {
			//	heatMap.AddValue(r.NextDouble(heatMap.Left, heatMap.Right), r.NextDouble(heatMap.Bottom, heatMap.Top), 10.0f);			    
		    //}
			//
			//heatMap.UpdateHeatMap();
	    }