Example usage for com.badlogic.gdx.graphics.g3d.attributes SpotLightsAttribute Type

List of usage examples for com.badlogic.gdx.graphics.g3d.attributes SpotLightsAttribute Type

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.attributes SpotLightsAttribute Type.

Prototype

long Type

To view the source code for com.badlogic.gdx.graphics.g3d.attributes SpotLightsAttribute Type.

Click Source Link

Usage

From source file:com.badlogic.gdx.tests.g3d.shadows.system.realistic.MainShader.java

License:Apache License

public void bindSpotShadows(final Attributes attributes) {
    final SpotLightsAttribute sla = attributes.get(SpotLightsAttribute.class, SpotLightsAttribute.Type);
    final Array<SpotLight> spots = sla == null ? null : sla.lights;

    if (spotLightsLoc >= 0) {
        for (int i = 0; i < spotLights.length; i++) {
            if (spots == null || spots.size <= i) {
                continue;
            }/* ww  w.j  a v  a 2 s  . c o m*/

            int idx = spotShadowsLoc + i * spotShadowsSize;

            // Shadow
            ObjectMap<SpotLight, LightProperties> spotCameras = shadowSystem.getSpotCameras();

            SpotLight sl = spots.get(i);
            if (shadowSystem.hasLight(sl)) {
                // UVTransform
                final TextureRegion tr = spotCameras.get(sl).region;
                Camera cam = spotCameras.get(sl).camera;

                if (cam != null) {
                    program.setUniformf(idx + spotShadowsUvTransformOffset, tr.getU(), tr.getV(),
                            tr.getU2() - tr.getU(), tr.getV2() - tr.getV());

                    // ProjViewTrans
                    idx = spotShadowMapProjViewTransLoc + i * spotShadowMapProjViewTransSize;
                    program.setUniformMatrix(idx, spotCameras.get(sl).camera.combined);
                }
            }

            if (spotLightsSize <= 0)
                break;
        }
    }
}