Ejemplo n.º 1
0
        void renderTargetUserControl1_Tick(RenderTargetUserControl sender, float delta)
        {
            RenderTargetUserControl control = sender;

            //moving free camera by keys
            if (Map.Instance != null && freeCameraEnabled)
            {
                float cameraVelocity = 20;

                Vec3      pos = freeCameraPosition;
                SphereDir dir = freeCameraDirection;

                float step = cameraVelocity * delta;

                if (control.IsKeyPressed(Keys.W) ||
                    control.IsKeyPressed(Keys.Up))
                {
                    pos += dir.GetVector() * step;
                }
                if (control.IsKeyPressed(Keys.S) ||
                    control.IsKeyPressed(Keys.Down))
                {
                    pos -= dir.GetVector() * step;
                }
                if (control.IsKeyPressed(Keys.A) ||
                    control.IsKeyPressed(Keys.Left))
                {
                    pos += new SphereDir(
                        dir.Horizontal + MathFunctions.PI / 2, 0).GetVector() * step;
                }
                if (control.IsKeyPressed(Keys.D) ||
                    control.IsKeyPressed(Keys.Right))
                {
                    pos += new SphereDir(
                        dir.Horizontal - MathFunctions.PI / 2, 0).GetVector() * step;
                }
                if (control.IsKeyPressed(Keys.Q))
                {
                    pos += new Vec3(0, 0, step);
                }
                if (control.IsKeyPressed(Keys.E))
                {
                    pos += new Vec3(0, 0, -step);
                }

                freeCameraPosition = pos;
            }
        }