private void tmrPaint_Tick(object sender, EventArgs e) { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); sistema.Camara.Update(moviendo); sistema.DrawScene(); Winapi.SwapBuffers(hdc); Gl.glFlush(); }
public void Update(int pressedButton) { #region Aim camera 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 < 384) { pitch -= rotationSpeed * difY; } else if (position.y > 384) { pitch += rotationSpeed * -difY; } if (position.x < 512) { yaw += rotationSpeed * -difX; } else if (position.x > 512) { yaw -= rotationSpeed * difX; } UpdateDirVector(); CenterMouse(); if (pressedButton == 1) // se apreto el boton izquierdo de mouse { eyex -= (float)i * forwardSpeed; eyey -= (float)j * forwardSpeed; eyez -= (float)k * forwardSpeed; } else if (pressedButton == -1) // se apreto el boton derecho del mouse { eyex += (float)i * forwardSpeed; eyey += (float)j * forwardSpeed; eyez += (float)k * forwardSpeed; } #endregion Look(); }
public static void CenterMouse() { Winapi.SetCursorPos(MainForm.FormPos.X + 512, MainForm.FormPos.Y + 384); }