/// <summary> /// Zoom the camera to a new level. /// </summary> /// <param name="zoomlevel">Z-index of the camera.</param> public void zoom(string zoomlevel) { Renderer.SceneTools.Entities.Camera camera = ServiceManager.Game.Renderer.ActiveScene.CurrentCamera; try { float zoom = float.Parse(zoomlevel); camera.Position = new Vector3(camera.Position.X, camera.Position.Y, zoom); printer("Camera zoom level set to {0}.", zoom); } catch (FormatException) { printer("The zoom level must be an integer."); } }
/// <summary> /// Creates and Initializes a new RendererScene with a camera named "Default" as the active camera. /// </summary> public Scene() { entityID = new LowestAvailableID(); defaultPosition = Vector3.Zero; updateToggle = false; layers = new List<SceneLayer>(); SceneLayer layer = new SceneLayer(); layers.Add(layer); entityList = new Dictionary<int, Entity>(); drawableEntities = new List<SceneLayer>(); transparentEntities = new List<SceneLayer>(); deleteQueue = new List<int>(); TransparentWalls = true; cameraDictionary = new Dictionary<string, Camera>(); CurrentCamera = new Camera(); cameraDictionary.Add("Default", CurrentCamera); currentFrustum = new BoundingFrustum(CurrentCamera.Projection); shadowRenderTarget = GfxComponent.CreateRenderTarget(GraphicOptions.graphics.GraphicsDevice, 1, SurfaceFormat.Single); shadowDepthBuffer = GfxComponent.CreateDepthStencil(shadowRenderTarget, DepthFormat.Depth24Stencil8Single); worldLight.Position = new Vector3(7000, 4000, 10000); worldLight.TargetPosition = Vector3.Zero; worldLight.View = Matrix.Identity; worldLight.Projection = Matrix.Identity; PercentOfDayComplete = 0.5f; }
/// <summary> /// Makes a new Camera object and adds it to the scene. /// </summary> /// <param name="position">The position that the camera is inserted at. </param> /// <param name="target">The position the camera is pointing at</param> /// <param name="projection">The projection matrix for the camera to use.</param> /// <param name="name">The identifying name of the camera.</param> /// <returns>The newly created Camera object.</returns> public Camera CreateCamera(Vector3 position, Vector3 target, Matrix projection, string name) { if (!cameraDictionary.ContainsKey(name)) { Camera newCamera = new Camera(position, target, projection); cameraDictionary.Add(name, newCamera); return newCamera; } else { return cameraDictionary[name]; } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { IsMouseVisible = true; //Manager.Initialize(); ServiceManager.CreateResourceManager(); ServiceManager.CreateAudioManager(); ServiceManager.CreateMP3Player(); ServiceManager.CreateStateManager(); ServiceManager.CreateLogger(); base.Initialize(); PresentationParameters pp = GraphicsDevice.PresentationParameters; const int borderPadding = 20; Console = new GameConsole(new Rectangle( borderPadding, borderPadding, GraphicsDeviceManager.PreferredBackBufferWidth - borderPadding, GraphicsDeviceManager.PreferredBackBufferHeight - borderPadding)); Options.VideoOptions video = Options.Video; // Set anti-aliasing options. string antialiasing = video.AntiAliasing.ToLower(); if (antialiasing == "off") { pp.MultiSampleQuality = 0; pp.MultiSampleType = MultiSampleType.None; GraphicsDeviceManager.PreferMultiSampling = false; } else { GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>( GraphicsDeviceManager_PreparingDeviceSettings); } GraphicsDeviceManager.DeviceReset += new System.EventHandler(GraphicsDeviceManager_DeviceReset); // TODO: Don't forget other options. GraphicsDeviceManager.ApplyChanges(); //ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize; Renderer = new EntityRenderer(GraphicsDeviceManager, Content); Renderer.SceneTools.Entities.Camera cam = Renderer.ActiveScene.CurrentCamera; Camera camera = Renderer.ActiveScene.CreateCamera( new Vector3(100, 100, 60), // Position Vector3.Backward * 20, // Target cam.Projection, // Projection DefaultCameraName /* Name */); camera.CameraUp = Vector3.UnitZ; camera.Updatable = false; lastTimeStamp = Network.Util.Clock.GetTimeMilliseconds(); screenshotTarget = new RenderTarget2D(GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, 1, GraphicsDevice.DisplayMode.Format); WeaponLoader.LoadFiles(); ServiceManager.StateManager.ChangeState <LoginScreenState>(); ServiceManager.Game.GraphicsDevice.RenderState.PointSizeMax = ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize; Console.DebugPrint("Max Point Size: " + ServiceManager.Game.GraphicsDevice.GraphicsDeviceCapabilities.MaxPointSize); if (ServiceManager.MP3Player != null) { MENU_PATH = Path.Combine( ServiceManager.MP3Player.AudioDirectory, @"official\menu.wav"); if (!ServiceManager.MP3Player.Play(MENU_PATH, true)) { Console.DebugPrint("[WARNING] Cannot play file official\\menu.wav (not found)."); } } }