public PixelsPerUnitAt ( Vector3 &absolutePosition ) : float | ||
absolutePosition | Vector3 | |
return | float |
public void UpdateScale(Camera camera) { float scale = (float)mCrossHair[0].RelativePoint1.X; float desiredScale = 5 / camera.PixelsPerUnitAt(this.Z); mCrossHair[0].ScaleBy(desiredScale / scale); mCrossHair[1].ScaleBy(desiredScale / scale); }
public static void MouseCameraControl(Camera camera) { Cursor cursor = GuiManager.Cursor; if (cursor.WindowOver == null && GuiManager.DominantWindowActive == false && !cursor.MiddlePush #if SUPPORTS_FRB_DRAWN_GUI && cursor.WindowMiddleButtonPushed == null #endif #if! FRB_MDX && FlatRedBallServices.Game.IsActive #endif ) { float pixelSize = 1/camera.PixelsPerUnitAt(0); // middle-click drag moves the camera if (InputManager.Mouse.ButtonDown(FlatRedBall.Input.Mouse.MouseButtons.MiddleButton)) { camera.X += -InputManager.Mouse.XChange * pixelSize; camera.Y += InputManager.Mouse.YChange * pixelSize; } // double-click the middle-mouse button to center on the mouse's position if (InputManager.Mouse.ButtonDoubleClicked(FlatRedBall.Input.Mouse.MouseButtons.MiddleButton)) { cursor.GetCursorPosition(camera, 0); } // mouse-wheel scrolling zooms in and out if (InputManager.Mouse.ScrollWheelChange != 0) { if (camera.Orthogonal == false) camera.Z *= 1 + System.Math.Sign(InputManager.Mouse.ScrollWheelChange) * -.1f; else { camera.OrthogonalHeight *= 1 + System.Math.Sign(InputManager.Mouse.ScrollWheelChange) * -.1f; camera.OrthogonalWidth *= 1 + System.Math.Sign(InputManager.Mouse.ScrollWheelChange) * -.1f; } } } }