Esempio n. 1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 87)             // press W
            {
                //rotate_y += 0.2;
                cam.upRotate();
            }
            else if (e.KeyValue == 83)             // press S
            {
                //rotate_y -= 0.2;
                cam.downRotate();
            }
            else if (e.KeyValue == 68)             // press D
            {
                if (cam.getU_Y() == -1)
                {
                    cam.rightRotate();
                }
                else
                {
                    cam.leftRotate();
                }
            }
            else if (e.KeyValue == 65)             // press A
            {
                if (cam.getU_Y() == -1)
                {
                    cam.leftRotate();
                }
                else
                {
                    cam.rightRotate();
                }
            }
            else if (e.KeyValue == 90) // press Z
            {
                cam.further();
            }
            else if (e.KeyValue == 88 && cam.getDist() >= 1) // press X
            {
                cam.nearer();
            }

            // Cat nhat thong tin cho camera
            textBox_Cam_PosX.Text = Math.Round(cam.getX(), 3).ToString();
            textBox_Cam_PosY.Text = Math.Round(cam.getY(), 3).ToString();
            textBox_Cam_PosZ.Text = Math.Round(cam.getZ(), 3).ToString();

            textBox_VpX.Text = cam.getV_X().ToString();
            textBox_VpY.Text = cam.getV_Y().ToString();
            textBox_VpZ.Text = cam.getV_Z().ToString();

            textBox_View.Text = cam.getAngle().ToString();

            isDrawing = true;             // Cap nhat de ve
        }