Ejemplo n.º 1
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.F10: this.Close(); break;

            //case Key.W: m_world.RotationX -= 5.0f; break;
            //case Key.S: m_world.RotationX += 5.0f; break;
            //case Key.A: m_world.RotationY -= 5.0f; break;
            //case Key.D: m_world.RotationY += 5.0f; break;
            case Key.F4: this.Close(); break;

            case Key.I: if (m_world.RotationX > -85)
                {
                    m_world.RotationX -= 5.0f;
                }
                break;

            case Key.K: if (m_world.RotationX < 85)
                {
                    m_world.RotationX += 5.0f;
                }
                Console.WriteLine(m_world.RotationX); break;

            case Key.J: if (m_world.RotationY > -85)
                {
                    m_world.RotationY -= 5.0f;
                }
                Console.WriteLine(m_world.RotationY); break;

            case Key.L: if (m_world.RotationY < 85)
                {
                    m_world.RotationY += 5.0f;
                }
                Console.WriteLine(m_world.RotationY); break;

            case Key.U: m_world.RotationZ -= 5.0f; break;

            case Key.O: m_world.RotationZ += 5.0f; break;

            case Key.V: m_world.SetTimer(); break;

            case Key.Add: m_world.SceneDistance -= 700.0f; break;

            case Key.Subtract: m_world.SceneDistance += 700.0f; break;

            case Key.F2:
                OpenFileDialog opfModel = new OpenFileDialog();
                bool           result   = (bool)opfModel.ShowDialog();
                if (result)
                {
                    try
                    {
                        World newWorld = new World(Directory.GetParent(opfModel.FileName).ToString(), Path.GetFileName(opfModel.FileName), Path.GetFileName(opfModel.FileName), (int)openGLControl.Width, (int)openGLControl.Height, openGLControl.OpenGL);
                        m_world.Dispose();
                        m_world = newWorld;
                        m_world.Initialize(openGLControl.OpenGL);
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Neuspesno kreirana instanca OpenGL sveta:\n" + exp.Message, "GRESKA", MessageBoxButton.OK);
                    }
                }
                break;
            }
        }