Example usage for com.badlogic.gdx.math Vector3 rotate

List of usage examples for com.badlogic.gdx.math Vector3 rotate

Introduction

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

Prototype

public Vector3 rotate(final Vector3 axis, float degrees) 

Source Link

Document

Rotates this vector by the given angle in degrees around the given axis.

Usage

From source file:com.mygdx.game.scene.GameScene.java

License:Apache License

private void spawnLight(BlenderLight bLight) {
    Vector3 direction = new Vector3(V3_DOWN);
    direction.rotate(Vector3.X, bLight.rotation.x);
    direction.rotate(Vector3.Z, bLight.rotation.z);
    direction.rotate(Vector3.Y, bLight.rotation.y);

    // TODO: Don't know how to map lamp intensity in blender to libgdx correctly
    float intensity = bLight.lamp_energy;
    float cutoffAngle = bLight.lamp_falloff;
    float exponent = 1;

    if (bLight.type.equals("PointLamp")) {
        BaseLight<?> light = new PointLight().set(bLight.lamp_color.r, bLight.lamp_color.g, bLight.lamp_color.b,
                bLight.position, bLight.lamp_energy);
        lights.add(light);/*from  w  ww  .j  a va2s  .  c  o m*/

    } else if (bLight.type.equals("SpotLamp")) {
        BaseLight<?> light = new SpotLight().set(bLight.lamp_color, bLight.position, direction, intensity,
                cutoffAngle, exponent);
        lights.add(light);

    } else if (bLight.type.equals("SunLamp")) {
        BaseLight<?> light = new DirectionalLight().set(bLight.lamp_color.r, bLight.lamp_color.g,
                bLight.lamp_color.b, direction.x, direction.y, direction.z);
        lights.add(light);
        shadowCameraDirection.set(direction);
    }
}

From source file:com.mygdx.game.scene.GameScene.java

License:Apache License

public void setToSceneCamera(GhostCamera camera) {
    Vector3 direction = new Vector3(V3_DOWN);
    direction.rotate(Vector3.X, sceneCamera.rotation.x);
    direction.rotate(Vector3.Z, sceneCamera.rotation.z);
    direction.rotate(Vector3.Y, sceneCamera.rotation.y);
    direction.nor();//  w  w  w.ja  v a  2s  . c  om

    camera.fieldOfView = sceneCamera.fov;
    camera.targetPosition.set(sceneCamera.position);
    camera.targetDirection.set(direction);
    camera.targetUp.set(Vector3.Y);
    camera.snapToTarget();
    camera.update();
}