private void CreateCamera() { var scene = Engine.Scene; //Compute the render target aspect ratio float aspect = (float)Engine.Graphics.BackBuffer.Width / (float)Engine.Graphics.BackBuffer.Height; //Create a First-Person camera controller. The controller will responds to user inputs and move the camera var controller = new FpController() { MoveScale = 10.0f, RotationScale = 0.5f, BreakingTime = 0.2f, //The callback that is called during a frame update ,if it returns true the camera respond to the user input UpdateCallback = c => Engine.Mouse.IsButtonPresed(Igneel.Input.MouseButton.Middle) || (Engine.Mouse.IsButtonPresed(Igneel.Input.MouseButton.Left) && Engine.KeyBoard.IsKeyPressed(Keys.Lalt)), //Create the camera and the camera node Node = scene.Create("cameraNode", Camera.FromOrientation("camera", zn: 0.05f, zf: 1000f).SetPerspective(Numerics.ToRadians(60), aspect), localPosition: new Vector3(0, 200, -500), localRotation: new Euler(0, Numerics.ToRadians(30), 0).ToMatrix()) }; scene.Dynamics.Add(new Dynamic(x => controller.Update(x))); }
public static Frame CreateCamera(Scene scene) { var linearAceleration = 1000f; var linearVelocity = 100f; var angularAceleration = Numerics.ToRadians(1000); var angularVelocity = Numerics.ToRadians(90); var breakingFactor = 0.0f; var localRadius = 1.5f; var zn = 0.5f; var zf = 3000f; var offset = 100; var fov = Numerics.PIover3; Vector3 pos = new Vector3(0, offset, -offset); float aspect = (float)GraphicDeviceFactory.Device.BackBuffer.Width / (float)GraphicDeviceFactory.Device.BackBuffer.Height; var controller = new FpController() { MoveScale = 10.0f, RotationScale = 0.5f, BreakingTime = 0.2f, UpdateCallback = c => Engine.Mouse.IsButtonPresed(MouseButton.Middle) || (Engine.Mouse.IsButtonPresed(MouseButton.Left) && Engine.KeyBoard.IsKeyPressed(Keys.Lalt)) }; var camera = Engine.Scene.Create("camera1", Camera.FromOrientation("camera1", zn: zn, zf: zf).SetPerspective(fov, aspect), localPosition: pos, localRotation: new Euler(0, Numerics.ToRadians(30), 0).ToMatrix()); //camera.LocalRadius = localRadius; camera.CommitChanges(); controller.Node = camera; scene.Dynamics.Add(new Dynamic(x => controller.Update(x))); return(camera); }