コード例 #1
0
        /// <summary>
        /// creates two cameras and viewports for split-screen.
        /// </summary>
        public void InitCamera()
        {
            //  Make two mutiple cameras
            ViewCamera followViewCamera = new ViewCamera();

            FollowCamera[] followCamera = new FollowCamera[2]
            {
                new FollowCamera(),
                new FollowCamera(),
            };

            int playerCount = GameLevel.PlayerCountInLevel;

            for (int i = 0; i < playerCount; i++)
            {
                GamePlayer player = GameLevel.GetPlayerInLevel(i);

                followCamera[i].SetPespective(
                    MathHelper.ToRadians(this.GameLevel.Info.FOV),
                    (float)FrameworkCore.ViewWidth,
                    (float)FrameworkCore.ViewHeight / playerCount,
                    1.0f, 1000.0f);

                // Follow camera offset position setting
                followCamera[i].TargetOffset =
                    player.SpecData.CameraTargetOffset;

                followCamera[i].PositionOffset =
                    player.SpecData.CameraPositionOffset;

                int splitX      = 0;
                int splitY      = 0;
                int splitWidth  = 0;
                int splitHeight = 0;

                //  1P viewport area
                if (i == 0)
                {
                    splitX = 0;
                    splitY = 0;
                }
                //  2P viewport area
                else if (i == 1)
                {
                    splitX = 0;
                    splitY = FrameworkCore.ViewHeight / playerCount;
                }

                splitWidth  = FrameworkCore.ViewWidth;
                splitHeight = FrameworkCore.ViewHeight / playerCount;

                followViewCamera.Add(followCamera[i],
                                     new Rectangle(splitX, splitY, splitWidth, splitHeight));
            }

            Viewer.AddCamera("Follow", followViewCamera);
            Viewer.SetCurrentCamera("Follow");
        }
コード例 #2
0
        /// <summary>
        /// initializes the 3rd person view camera which follows player.
        /// </summary>
        public void InitCamera()
        {
            //  Follow Camera
            FollowCamera followCamera = new FollowCamera();

            followCamera.SetPespective(MathHelper.ToRadians(this.GameLevel.Info.FOV),
                                       (float)FrameworkCore.ViewWidth,
                                       (float)FrameworkCore.ViewHeight,
                                       1.0f, 1000.0f);

            // Follow camera offset position setting
            followCamera.TargetOffset =
                GameLevel.SinglePlayer.SpecData.CameraTargetOffset;

            followCamera.PositionOffset =
                GameLevel.SinglePlayer.SpecData.CameraPositionOffset;

            ViewCamera followViewCamera = new ViewCamera(followCamera,
                                                         new Rectangle(0, 0, FrameworkCore.ViewWidth, FrameworkCore.ViewHeight));

            Viewer.AddCamera("Follow", followViewCamera);
            Viewer.SetCurrentCamera("Follow");
        }