List of usage examples for com.badlogic.gdx.math Quaternion Quaternion
public Quaternion(Vector3 axis, float angle)
From source file:airfoil.etc.Controller.java
License:Open Source License
public Controller(Viewport viewport) { super();/*from www. j a va2 s. c o m*/ this.width = (int) viewport.width; this.height = (int) viewport.height; this.orientation = new Matrix4(new Quaternion(XA, 180)); }
From source file:airfoil.etc.Controller.java
License:Open Source License
@Override public boolean touchDragged(int x, int y, int pointer) { final Vector3 delta; if (this.button) { delta = new Vector3(x, y, 0).sub(this.last).mul(0.5f); this.last.set(x, y, 0); } else {/* w w w . ja v a2 s.c om*/ delta = new Vector3(0, x, y).sub(this.last).mul(0.5f); this.last.set(0, x, y); } final Quaternion rotation; if (this.button) { rotation = new Quaternion(YA, -delta.x).mul(new Quaternion(YA, delta.y)); } else { rotation = new Quaternion(ZA, delta.z).mul(new Quaternion(ZA, -delta.y)); } this.rotation.mul(new Matrix4(rotation)); this.reinit(); return true; }