Example usage for com.badlogic.gdx.graphics.g3d.environment SpotLight SpotLight

List of usage examples for com.badlogic.gdx.graphics.g3d.environment SpotLight SpotLight

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.environment SpotLight SpotLight.

Prototype

SpotLight

Source Link

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);// w w  w  . j a v  a2 s  .  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);
    }
}