Exemplo n.º 1
0
        private static void MainGetInput()
        {
            //Console.TreatControlCAsInput = true;

            while (true)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                if (keyInfo.Key == ConsoleKey.Escape)
                {
                    Environment.Exit(0);
                    return;
                }

                switch (keyInfo.Key)
                {
                case ConsoleKey.Spacebar:
                    renderState.changeState();
                    break;

                case ConsoleKey.W:
                    ActiveMesh.Translate(0, 0, 0.1f);
                    break;

                case ConsoleKey.A:
                    ActiveMesh.Translate(-10.0f, 0, 0);
                    break;

                case ConsoleKey.S:
                    ActiveMesh.Translate(0, 0, -0.1f);
                    break;

                case ConsoleKey.D:
                    ActiveMesh.Translate(10.0f, 0, 0);
                    break;

                case ConsoleKey.R:
                    ActiveMesh.Rotate(0.01, 0);
                    break;

                case ConsoleKey.T:
                    ActiveMesh.Rotate(0.01, 1);
                    break;

                case ConsoleKey.Y:
                    ActiveMesh.Rotate(0.01, 2);
                    break;

                case ConsoleKey.Q:
                    ActiveMesh.Translate(0, -10.0f, 0);
                    break;

                case ConsoleKey.E:
                    ActiveMesh.Translate(0, 10.0f, 0);
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public void applyVelocity()
 {
     if (Math.Abs(MassCenter.X + Math.Sign(velocity.X) * radius) >= floor)
     {
         velocity.X        *= -1;
         angularVelocity.X += velocity.X / 100;
     }
     if (Math.Abs(MassCenter.Y + Math.Sign(velocity.Y) * radius) >= floor)
     {
         velocity.Y        *= -1;
         angularVelocity.Y += velocity.Y / 100;
     }
     if (Math.Abs(MassCenter.Z + Math.Sign(velocity.Z) * radius) + 600.0f >= floor)
     {
         velocity.Z        *= -1;
         angularVelocity.Z += velocity.Z / 100;
     }
     mesh.Translate(velocity);
     mesh.Rotate(angularVelocity);
 }