public RenderWindow() { InitializeComponent(); PanelHandle = xnaPanel1.Handle; engine = ResourceCollectorXNA.Engine.GameEngine.Instance; ; Engine.GameEngine.renderController = new RCViewControllers.RenderWindowVC(this); capturer = new mosecapturer(); Instance = this; _hotkeys = new List<HotKey>(); _hotkeys.Add(new HotKey(new Microsoft.Xna.Framework.Input.Keys[] { Microsoft.Xna.Framework.Input.Keys.A }, ToggleAngular)); _hotkeys.Add(new HotKey(new Microsoft.Xna.Framework.Input.Keys[] { Microsoft.Xna.Framework.Input.Keys.E }, HotRotate)); _hotkeys.Add(new HotKey(new Microsoft.Xna.Framework.Input.Keys[] { Microsoft.Xna.Framework.Input.Keys.W }, HotMove)); _hotkeys.Add(new HotKey(new Microsoft.Xna.Framework.Input.Keys[] { Microsoft.Xna.Framework.Input.Keys.Q }, HotSelect)); KeyboardManager.Manager.AddKeyboardUser(this); }
public Camera(GameEngine engine, Vector3? cameraposition = null, Vector3? cameratarget = null) { if(cameratarget == null) cameratarget = new Vector3(0, 0, 0); if(cameraposition == null) cameraposition = new Vector3(20, 20, 10); _engine = engine; float katet = -(cameratarget.Value.Y - cameraposition.Value.Y); float gipotenuza = (cameraposition.Value - cameratarget.Value).Length(); _cameraPitch = -MathHelper.PiOver2 + Convert.ToSingle(Math.Acos(Convert.ToDouble(katet / gipotenuza))); float determ = (cameratarget.Value.Z - cameraposition.Value.Z); if(determ == 0) determ = 0.001f; _cameraYaw = Convert.ToSingle(Math.Atan(Convert.ToSingle((cameratarget.Value.X - cameraposition.Value.X) / determ))); View = Matrix.CreateLookAt(cameraposition.Value, cameratarget.Value, new Vector3(0, 1, 0)); Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GameEngine.Device.Viewport.AspectRatio, 1, 250.0f); cameraFrustum.Matrix = View * Projection; }