public override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F1)) { this.editorKeyPressed = true; } else if (Keyboard.GetState().IsKeyUp(Microsoft.Xna.Framework.Input.Keys.F1)) { if (this.editorKeyPressed) { this.editorKeyPressed = false; if (this.mainForm.Visible) { this.mainForm.Hide(); InputMgr.Instance.CaptureMouse = true; GraphicsMgr gm = GraphicsMgr.Instance; gm.Device.RenderState.FillMode = Microsoft.Xna.Framework.Graphics.FillMode.Solid; //restore previous camera gm.Camera = this.oldCamera; } else { GraphicsMgr gm = GraphicsMgr.Instance; //retrieve current camera this.oldCamera = gm.Camera; //set editor camera to position and orientation of current camera this.camera.xform = this.oldCamera.worldXForm; gm.Camera = this.camera; gm.Device.RenderState.FillMode = Microsoft.Xna.Framework.Graphics.FillMode.WireFrame; FillTreeView(); this.mainForm.Show(); InputMgr.Instance.CaptureMouse = false; } } } base.Update(gameTime); }
protected override void Initialize() { this.Window.Title = "SharpEngine v0.1 [F1 for Editor]"; this.Window.AllowUserResizing = true; this.IsFixedTimeStep = false; this.IsMouseVisible = false; //create and register components this.Components.Add(InputMgr.Create(this)); this.Components.Add(EntityMgr.Create(this)); this.Components.Add(GraphicsMgr.Create(this)); this.Components.Add(ResourceMgr.Create(this)); this.Components.Add(Editor.Create(this)); base.Initialize(); //HACK create our main free camera FreeCamera freecam = new FreeCamera(); freecam.Name = "MainCamera"; EntityMgr entityMgr = EntityMgr.Instance; entityMgr.AddEntity(freecam); GraphicsMgr.Instance.Camera = freecam; Light light = new LightPoint(); light.Name = "Light0"; light.ID = 1; entityMgr.AddEntity(light); light = new LightPoint(); light.Name = "Light1"; light.ID = 2; entityMgr.AddEntity(light); light = new LightPoint(); light.Name = "Light2"; light.ID = 3; entityMgr.AddEntity(light); light = new LightDirectionnal(); light.Name = "Light3"; light.ID = 4; entityMgr.AddEntity(light); }
public static GraphicsMgr Create(Game game) { sInstance = new GraphicsMgr(game); return(sInstance); }