Exemple #1
0
  public void input() {
    float sensitivity = 0.5f;
    float movAmt = (float) (10 * Time.getDelta());
    //		float rotAmt = (float)(100 * Time.getDelta());

    if (Input.getKey(GLFW.GLFW_KEY_ESCAPE)) {
      Input.showCursor(true);
      mouseLocked = false;
    }
    if (Input.getMouseDown(0)) {
      Input.setMousePosition(Window.getCenterPoint());
      Input.showCursor(false);
      mouseLocked = true;
    }

    if (Input.getKey(GLFW.GLFW_KEY_W)) move(getForward(), movAmt);
    if (Input.getKey(GLFW.GLFW_KEY_S)) move(getForward(), -movAmt);
    if (Input.getKey(GLFW.GLFW_KEY_A)) move(getLeft(), movAmt);
    if (Input.getKey(GLFW.GLFW_KEY_D)) move(getRight(), movAmt);

    if (mouseLocked) {
      Vector2f deltaPos = Input.getMousePosition().sub(Window.getCenterPoint());

      boolean rotY = deltaPos.getX() != 0;
      boolean rotX = deltaPos.getY() != 0;

      if (rotY) rotateY(deltaPos.getX() * sensitivity);
      if (rotX) rotateX(-deltaPos.getY() * sensitivity);

      if (rotY || rotX)
        Input.setMousePosition(new Vector2f(Window.getWidth() / 2, Window.getHeight() / 2));
    }
  }
Exemple #2
0
 public Vector2f div(Vector2f v) {
   return new Vector2f(this.x / v.getX(), this.y / v.getY());
 }
Exemple #3
0
 public Vector2f mult(Vector2f v) {
   return new Vector2f(this.x * v.getX(), this.y * v.getY());
 }
Exemple #4
0
 public Vector2f sub(Vector2f v) {
   return new Vector2f(this.x - v.getX(), this.y - v.getY());
 }
Exemple #5
0
 public Vector2f add(Vector2f v) {
   return new Vector2f(this.x + v.getX(), this.y + v.getY());
 }
Exemple #6
0
 public float dot(Vector2f v) {
   return (v.getX() * this.x + v.getY() * this.x);
 }
Exemple #7
0
 public static void setMousePosition(Vector2f pos) {
   Mouse.setCursorPosition((int) pos.getX(), (int) pos.getY());
 }
Exemple #8
0
 /**
  * Scales this matrix with the specified vector.
  *
  * @param scale - the vector to scale with
  * @return this matrix instance
  */
 public Matrix4f scale(Vector2f scale) {
   matrix[0 + 0 * 4] *= scale.getX();
   matrix[1 + 1 * 4] *= scale.getY();
   return this;
 }
Exemple #9
0
 /**
  * Translates this matrix with the specified vector.
  *
  * @param vec2 - the vector to translate with
  * @return this matrix instance
  */
 public Matrix4f translate(Vector2f vec2) {
   return translate(new Vector3f(vec2.getX(), vec2.getY(), 0));
 }
Exemple #10
0
 public Vector2f div(Vector2f r) {
   return new Vector2f(x / r.getX(), y / r.getY());
 }
Exemple #11
0
 public Vector2f mul(Vector2f r) {
   return new Vector2f(x * r.getX(), y * r.getY());
 }
Exemple #12
0
 public Vector2f sub(Vector2f r) {
   return new Vector2f(x - r.getX(), y - r.getY());
 }
Exemple #13
0
 public Vector2f add(Vector2f r) {
   return new Vector2f(x + r.getX(), y + r.getY());
 }
Exemple #14
0
 public float dot(Vector2f r) {
   return x * r.getX() + y * r.getY();
 }