コード例 #1
0
 private void tmrPaint_Tick(object sender, EventArgs e)
 {
     Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
     controladora.Camara.Update(moviendo);
     controladora.DrawScene();
     Winapi.SwapBuffers(hdc);
     Gl.glFlush();
 }
コード例 #2
0
        public void Update(int pressedButton)
        {
            #region Camara de apuntar

            Pointer position = new Pointer();
            Winapi.GetCursorPos(ref position);

            int difX = MainForm.FormPos.X + 512 - position.x;
            int difY = MainForm.FormPos.Y + 384 - position.y;

            if (position.y < MainForm.FormPos.Y + 384)
            {
                pitch -= rotationSpeed * difY;
            }
            else
            if (position.y > MainForm.FormPos.Y + 384)
            {
                pitch += rotationSpeed * -difY;
            }
            if (position.x < MainForm.FormPos.X + 512)
            {
                yaw += rotationSpeed * -difX;
            }
            else
            if (position.x > MainForm.FormPos.X + 512)
            {
                yaw -= rotationSpeed * difX;
            }
            UpdateDirVector();
            CenterMouse();


            if (pressedButton == 1)     // left click pressed
            {
                if (!Collision.CheckCollision(new Vector3(eyex - (float)i * forwardSpeed, eyez - (float)k * forwardSpeed, 0)))
                {
                    eyex -= (float)i * forwardSpeed;
                    eyez -= (float)k * forwardSpeed;
                }
            }
            if (pressedButton == -1)     // right click pressed
            {
                if (!Collision.CheckCollision(new Vector3(eyex + (float)i * forwardSpeed, eyez + (float)k * forwardSpeed, 0)))
                {
                    eyex += (float)i * forwardSpeed;
                    eyez += (float)k * forwardSpeed;
                }
            }

            #endregion

            Look();
        }
コード例 #3
0
 public static void CenterMouse()
 {
     Winapi.SetCursorPos(MainForm.FormPos.X + 512, MainForm.FormPos.Y + 384);
 }