Esempio n. 1
0
            public static void MakeBeat(double secs)
            {
                Beat1?.Invoke(secs);
                Beat2?.Invoke();
                var trans = MyLib.Transform(CameraProperties.BaseTransform);

                trans = trans.TranslatePrepend(CameraProperties.position - new Point3D());
                var cross = Vector3D.CrossProduct(Kernel.Camera.LookDirection, CameraProperties.lookDirection);

                if (cross.Length != 0)
                {
                    var dot   = Vector3D.DotProduct(Kernel.Camera.LookDirection, CameraProperties.lookDirection);
                    var angle = Math.Acos(dot / Kernel.Camera.LookDirection.Length / CameraProperties.lookDirection.Length);
                    trans = trans.RotatePrepend(cross, angle);
                }
                //if (Keyboard.IsDown(System.Windows.Input.Key.Z)) System.Diagnostics.Trace.WriteLine(CameraProperties.position-new Point3D());
                Kernel.Camera.Transform = trans.Value;
            }
Esempio n. 2
0
 void MonitorKeys()
 {
     MyLib.MyTrans trans = null;
     Kernel.Heart.Beat1 += (secs) =>
     {
         trans = MyLib.Transform(Kernel.CameraProperties.BaseTransform);
         {
             const double disDelta = 0.1, angleDelta = 2 * Math.PI / 180;
             Vector3D
                 z = -MyLib.Norm(Kernel.Camera.LookDirection),
                 x = MyLib.Norm(Vector3D.CrossProduct(Kernel.Camera.LookDirection, Kernel.Camera.UpDirection)),
                 y = MyLib.Norm(Vector3D.CrossProduct(z, x));
             //Camera.UpDirection = z;
             //Camera.LookDirection = x;
             if (Keyboard.IsDown(Key.Up))
             {
                 trans.RotatePrepend(x, angleDelta);
             }
             if (Keyboard.IsDown(Key.Down))
             {
                 trans.RotatePrepend(x, -angleDelta);
             }
             if (Keyboard.IsDown(Key.Left))
             {
                 trans.RotatePrepend(y, angleDelta);
             }
             if (Keyboard.IsDown(Key.Right))
             {
                 trans.RotatePrepend(y, -angleDelta);
             }
             if (Keyboard.IsDown(Key.OemOpenBrackets))
             {
                 trans.RotatePrepend(z, -angleDelta);
             }
             if (Keyboard.IsDown(Key.OemCloseBrackets))
             {
                 trans.RotatePrepend(z, angleDelta);
             }
             if (Keyboard.IsDown(Key.F))
             {
                 trans.TranslatePrepend(-x * disDelta);
             }
             if (Keyboard.IsDown(Key.H))
             {
                 trans.TranslatePrepend(x * disDelta);
             }
             if (Keyboard.IsDown(Key.T))
             {
                 trans.TranslatePrepend(y * disDelta);
             }
             if (Keyboard.IsDown(Key.G))
             {
                 trans.TranslatePrepend(-y * disDelta);
             }
             if (Keyboard.IsDown(Key.R))
             {
                 trans.TranslatePrepend(-z * disDelta);
             }
             if (Keyboard.IsDown(Key.Y))
             {
                 trans.TranslatePrepend(z * disDelta);
             }
         }
     };
     Kernel.Heart.Beat2 += () =>
     {
         Kernel.CameraProperties.BaseTransform = trans.Value;
     };
 }