Example usage for com.badlogic.gdx.math Matrix4 getRotation

List of usage examples for com.badlogic.gdx.math Matrix4 getRotation

Introduction

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

Prototype

public Quaternion getRotation(Quaternion rotation) 

Source Link

Document

Gets the rotation of this matrix.

Usage

From source file:br.com.raphaelbruno.game.zombieinvaders.vr.model.GameObject.java

License:Apache License

public void lookAt(Vector3 point) {
    Vector3 from = transform.getTranslation(new Vector3()).cpy();
    Vector3 to = point.cpy();/*from  ww w  . j  a va 2  s . c  om*/
    Vector3 direction = to.sub(from).nor();
    direction.set(-direction.x, -direction.y, -direction.z);

    Quaternion quaternion = new Quaternion();
    Matrix4 instanceRotation = transform.cpy().mul(transform);

    instanceRotation.setToLookAt(direction, new Vector3(0, -1, 0));
    instanceRotation.rotate(0, 0, 1, 180);
    instanceRotation.getRotation(quaternion);

    transform.set(from, quaternion);
}