コード例 #1
0
ファイル: Camera.java プロジェクト: iamcsharper/OpenGLEngine
  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));
    }
  }
コード例 #2
0
ファイル: Matrix2f.java プロジェクト: kevinwang/minecarft
  /**
   * Transform a Vector by a matrix and return the result in a destination vector.
   *
   * @param left The left matrix
   * @param right The right vector
   * @param dest The destination vector, or null if a new one is to be created
   * @return the destination vector
   */
  public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) {
    if (dest == null) dest = new Vector2f();

    float x = left.m00 * right.x + left.m10 * right.y;
    float y = left.m01 * right.x + left.m11 * right.y;

    dest.x = x;
    dest.y = y;

    return dest;
  }
コード例 #3
0
 @Override
 public TbtQuad clone() {
   TbtQuad result = (TbtQuad) super.deepClone();
   result.size = size.clone();
   result.imageSize = imageSize.clone();
   result.horzFolds = horzFolds.clone();
   result.vertFolds = vertFolds.clone();
   result.horzTexCoords = horzTexCoords.clone();
   result.vertTexCoords = vertTexCoords.clone();
   return result;
 }
コード例 #4
0
ファイル: Cameor2D.java プロジェクト: snlove/GirdDemo
 public Cameor2D(GLGraphics glGraphics, float frumHeigh, float frumWidth) {
   this.FrumHeigh = frumHeigh;
   this.FrumWidth = frumWidth;
   glGraphics = this.glGraphics;
   postion.setVector2f(frumWidth / 2, frumHeigh / 2);
   this.zoom = 1;
 }
コード例 #5
0
  public void updateSize(float width, float height) {
    if (size.x == width && size.y == height) return;

    // Put back the size adjustment we made in the first place
    horzFolds[1] -= size.x - imageSize.x;
    vertFolds[1] -= size.y - imageSize.y;

    size.set(width, height);

    // Adjust the middle fold for the new size
    horzFolds[1] += size.x - imageSize.x;
    vertFolds[1] += size.y - imageSize.y;
    refreshGeometry();
  }
コード例 #6
0
ファイル: Vector2f.java プロジェクト: wenhao-zhang/Engine
 public Vector2f div(Vector2f v) {
   return new Vector2f(this.x / v.getX(), this.y / v.getY());
 }
コード例 #7
0
ファイル: Vector2f.java プロジェクト: wenhao-zhang/Engine
 public Vector2f mult(Vector2f v) {
   return new Vector2f(this.x * v.getX(), this.y * v.getY());
 }
コード例 #8
0
ファイル: Vector2f.java プロジェクト: wenhao-zhang/Engine
 public Vector2f sub(Vector2f v) {
   return new Vector2f(this.x - v.getX(), this.y - v.getY());
 }
コード例 #9
0
ファイル: Vector2f.java プロジェクト: wenhao-zhang/Engine
 public Vector2f add(Vector2f v) {
   return new Vector2f(this.x + v.getX(), this.y + v.getY());
 }
コード例 #10
0
ファイル: Vector2f.java プロジェクト: wenhao-zhang/Engine
 public float dot(Vector2f v) {
   return (v.getX() * this.x + v.getY() * this.x);
 }
コード例 #11
0
ファイル: Matrix2f.java プロジェクト: kanelbulle/oglmathj
  /**
   * Multiplies this matrix with the vector and returns the resulting vector.
   *
   * @param v The vector to multiply this matrix with from the right hand side.
   * @return The result of the multiplication.
   */
  public Vector2f multiply(Vector2f v) {
    float x = m00 * v.x() + m01 * v.y();
    float y = m10 * v.x() + m11 * v.y();

    return new Vector2f(x, y);
  }
コード例 #12
0
ファイル: Vector2f.java プロジェクト: princefbi/javatest
 public Vector2f add(Vector2f r) {
   return new Vector2f(x + r.getX(), y + r.getY());
 }
コード例 #13
0
ファイル: Matrix4f.java プロジェクト: Time14/APIe-Engine
 /**
  * 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));
 }
コード例 #14
0
ファイル: Matrix4f.java プロジェクト: Time14/APIe-Engine
 /**
  * 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;
 }
コード例 #15
0
ファイル: Vector2f.java プロジェクト: princefbi/javatest
 public Vector2f div(Vector2f r) {
   return new Vector2f(x / r.getX(), y / r.getY());
 }
コード例 #16
0
ファイル: Vector2f.java プロジェクト: princefbi/javatest
 public Vector2f mul(Vector2f r) {
   return new Vector2f(x * r.getX(), y * r.getY());
 }
コード例 #17
0
ファイル: Vector2f.java プロジェクト: princefbi/javatest
 public Vector2f sub(Vector2f r) {
   return new Vector2f(x - r.getX(), y - r.getY());
 }
コード例 #18
0
ファイル: Input.java プロジェクト: ponjoh90/Pontus
 public static void setMousePosition(Vector2f pos) {
   Mouse.setCursorPosition((int) pos.getX(), (int) pos.getY());
 }
コード例 #19
0
ファイル: Cameor2D.java プロジェクト: snlove/GirdDemo
 /**
  * 将触摸屏幕的点转换为当前视图下的坐标
  *
  * @param touch
  */
 public void touchToWorld(Vector2f touch) {
   touch.x = (touch.x / glGraphics.getWidth()) * FrumWidth * zoom;
   touch.y = (touch.y / glGraphics.getHeight()) * FrumHeigh * zoom;
   // 在当前坐标系下的坐标
   touch.add(postion).sub(FrumWidth * zoom / 2, FrumHeigh * zoom / 2);
 }
コード例 #20
0
ファイル: Vector2f.java プロジェクト: princefbi/javatest
 public float dot(Vector2f r) {
   return x * r.getX() + y * r.getY();
 }