Beispiel #1
0
        private Matrix createFarseerView()
        {
            // All vectors here are in farseer coordinates.

            Vector2 center;
            float   horizontalBound;
            float   verticalBound;

            if (ragdollManager.CameraShouldTrack)
            {
                center          = ragdollManager.getRagdollCenter();
                horizontalBound = 10;
                verticalBound   = 10;
            }
            else
            {
                center          = ProjectionHelper.PixelToFarseer(inputManager.inputHelper.MousePosition);
                horizontalBound = 25;
                verticalBound   = 15;
            }

            float top    = -farseerView.Translation.Y + verticalBound;
            float bottom = -farseerView.Translation.Y - verticalBound;
            float left   = -farseerView.Translation.X - horizontalBound;
            float right  = -farseerView.Translation.X + horizontalBound;

            Vector3 translate = new Vector3();

            if (center.X < left)
            {
                translate.X = center.X - left;
            }
            else if (center.X > right)
            {
                translate.X = center.X - right;
            }

            if (center.Y > top)
            {
                translate.Y = center.Y - top;
            }
            else if (center.Y < bottom)
            {
                translate.Y = center.Y - bottom;
            }


            translate.X = CurveFunc(translate.X, 20);
            translate.Y = CurveFunc(translate.Y, 20);

            Matrix m = Matrix.CreateTranslation(farseerView.Translation.X - translate.X, farseerView.Translation.Y - translate.Y, 0);

            return(m);
        }