示例#1
0
        public void SetDefaultWorldCamera(Vector3 target)
        {
            // Do a little trigonometry, we want to look at our target from a distance of 1500 units at an angle of 70deg
            var distance     = 2000;
            var angle        = MathHelper.DegreesToRadians(60);
            var location     = target + new Vector3(0, -distance * (float)Math.Cos(angle), distance * (float)Math.Sin(angle));
            var cameraMatrix = Matrix4.CreateRotationY(angle) * Matrix4.CreateRotationZ(MathHelper.PiOver2) * Matrix4.CreateTranslation(location);

            // Set camera
            ActiveCamera = new Camera(cameraMatrix, "worldspawn");
        }