Example usage for com.badlogic.gdx.math Quaternion Quaternion

List of usage examples for com.badlogic.gdx.math Quaternion Quaternion

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Quaternion Quaternion.

Prototype

public Quaternion(Vector3 axis, float angle) 

Source Link

Document

Constructor, sets the quaternion from the given axis vector and the angle around that axis in degrees.

Usage

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;
}