Exemple #1
0
        static void Main(string[] args)
        {
            Engine.LoadDependencies();

            engine = new Engine();

            engine.Run();

            Console.WriteLine("Loading model...");
            Entity sponza = engine.CreateEntity(@"models\sponza.obj", "ent.phys");
            Console.WriteLine("Done!");

            engine.Input.CursorLocked = true;
            engine.Input.CursorHidden = true;
            engine.Camera = new Camera(0.0, 0.0, 0.0);
            engine.Camera.Position = new Vector3(500, 500, 0);

            engine.Input.BindKeyHold(Key.W, () => { engine.Camera.Position += engine.Camera.GetRotationMatrix * Vector3.Forwards * 10.0; });
            engine.Input.BindKeyHold(Key.S, () => { engine.Camera.Position += engine.Camera.GetRotationMatrix * Vector3.Backwards * 10.0; });
            engine.Input.BindKeyHold(Key.A, () => { engine.Camera.Position += engine.Camera.GetRotationMatrix * Vector3.Left * 10.0; });
            engine.Input.BindKeyHold(Key.D, () => { engine.Camera.Position += engine.Camera.GetRotationMatrix * Vector3.Right * 10.0; });
            engine.Input.BindKeyHold(Key.Space, () => { engine.Camera.Position += Vector3.Up * 10.0; });
            engine.Input.BindKeyHold(Key.LeftShift, () => { engine.Camera.Position += Vector3.Down * 10.0; });

            engine.Input.BindKeyHold(Key.Q, () => { engine.Camera.Yaw += 0.03; if (engine.Camera.Yaw < 0) engine.Camera.Yaw += Math.PI * 2; });
            engine.Input.BindKeyHold(Key.E, () => { engine.Camera.Yaw -= 0.03; if (engine.Camera.Yaw >= Math.PI * 2) engine.Camera.Yaw -= Math.PI * 2; });
            engine.Input.BindKeyHold(Key.R, () => { engine.Camera.Pitch += 0.03; if (engine.Camera.Pitch > Math.PI / 2) engine.Camera.Pitch = Math.PI / 2; });
            engine.Input.BindKeyHold(Key.F, () => { engine.Camera.Pitch -= 0.03; if (engine.Camera.Pitch < -Math.PI / 2) engine.Camera.Pitch = -Math.PI / 2; });

            engine.Input.BindKeyHold(Key.Escape, () => { engine.Stop(); });
            engine.Input.BindMouseEvent(MouseEvent.Move, (MouseEventArguments e) =>
            {
                engine.Camera.Yaw -= e.DeltaX * 0.005;
                if (engine.Camera.Yaw < 0) engine.Camera.Yaw += Math.PI * 2;
                if (engine.Camera.Yaw >= Math.PI * 2) engine.Camera.Yaw -= Math.PI * 2;

                engine.Camera.Pitch -= e.DeltaY * 0.005;
                if (engine.Camera.Pitch > Math.PI / 2) engine.Camera.Pitch = Math.PI / 2;
                if (engine.Camera.Pitch < -Math.PI / 2) engine.Camera.Pitch = -Math.PI / 2;
            });
            engine.Input.BindMouseEvent(MouseEvent.WheelMove, (MouseEventArguments e) => { Console.WriteLine(e.WheelPosition); });

            Stopwatch timer = new Stopwatch();
            double d = 0;

            while (engine.IsRunning)
            {
                timer.Restart();
                d += 0.00501;

                while (timer.Elapsed.TotalMilliseconds < 1) ;
            }
        }
Exemple #2
0
 internal GraphicsEngine(Engine parent)
 {
     Parent = parent;
 }
Exemple #3
0
 public Window(Engine parent)
     : base(1440, 900, new GraphicsMode(32, 24, 8, 0), "Lux", GameWindowFlags.Default)
 {
     Parent = parent;
 }
Exemple #4
0
 internal PhysicsEngine(Engine parent)
 {
     ForceGeneratorRegistry = new List<Tuple<IForceGenerator, Entity>>();
     GlobalForces = new List<IForceGenerator>();
     Parent = parent;
 }
Exemple #5
0
        internal InputEngine(Engine parent)
        {
            Parent = parent;
            KeyHeld = new Dictionary<Key, bool>();
            KeyBinds = new Dictionary<Key, Tuple<Action, Action, Action>>();
            CursorLocked = false;

            foreach (Key k in Enum.GetValues(typeof(Key)))
            {
                if (!KeyBinds.ContainsKey(k))
                {
                    KeyBinds.Add(k, new Tuple<Action, Action, Action>(() => { }, () => { }, () => { }));
                    KeyHeld.Add(k, false);
                }
            }

            MouseBinds = new Dictionary<MouseEvent, Action<MouseEventArguments>>();
            foreach (MouseEvent m in Enum.GetValues(typeof(MouseEvent)))
            {
                if (!MouseBinds.ContainsKey(m))
                {
                    MouseBinds.Add(m, (MouseEventArguments e) => { });
                }
            }
        }