Пример #1
0
        private static void updateTransform()
        {
            Point3 normalized = (camera.FocalPosition - camera.Position).Normalize();

            // Forward movement
            if (VirtualKey.VK_KEY_W.IsDown())
            {
                camera.Position      += (normalized * transformMod);
                camera.FocalPosition += (normalized * transformMod);
            }

            // Backwards movement
            if (VirtualKey.VK_KEY_S.IsDown())
            {
                camera.Position      -= (normalized * transformMod);
                camera.FocalPosition -= (normalized * transformMod);
            }

            // Sideways movements
            if (VirtualKey.VK_KEY_A.IsDown())
            {
                Point3 normalizedCopy = normalized.Clone();

                normalizedCopy.X = normalized.Z;
                normalizedCopy.Y = 0;
                normalizedCopy.Z = -normalized.X;
                normalizedCopy   = normalizedCopy.Normalize();

                camera.Position      += (normalizedCopy * transformMod);
                camera.FocalPosition += (normalizedCopy * transformMod);
            }

            if (VirtualKey.VK_KEY_D.IsDown())
            {
                Point3 normalizedCopy = normalized.Clone();

                normalizedCopy.X = -normalized.Z;
                normalizedCopy.Y = 0;
                normalizedCopy.Z = normalized.X;
                normalizedCopy   = normalizedCopy.Normalize();

                camera.Position      += (normalizedCopy * transformMod);
                camera.FocalPosition += (normalizedCopy * transformMod);
            }

            // Vertical movements
            if (VirtualKey.VK_KEY_R.IsDown())
            {
                camera.Position      += new Point3(0, 1, 0) * transformMod;
                camera.FocalPosition += new Point3(0, 1, 0) * transformMod;
            }

            if (VirtualKey.VK_KEY_F.IsDown())
            {
                camera.Position      -= new Point3(0, 1, 0) * transformMod;
                camera.FocalPosition -= new Point3(0, 1, 0) * transformMod;
            }
        }