PixelsPerUnitAt() 공개 메소드

public PixelsPerUnitAt ( Vector3 &absolutePosition ) : float
absolutePosition Vector3
리턴 float
예제 #1
0
        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);

        }
예제 #2
0
        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;
                    }
                }
            }
        }