Search in sources :

Example 6 with SpotLight

use of com.badlogic.gdx.graphics.g3d.environment.SpotLight in project nhglib by VoidZombie.

the class ShaderUtils method createPrefix.

public static String createPrefix(Renderable renderable, boolean skinned) {
    String prefix = "";
    final int n = renderable.meshPart.mesh.getVertexAttributes().size();
    for (int i = 0; i < n; i++) {
        final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i);
        if (attr.usage == VertexAttributes.Usage.BoneWeight) {
            prefix += "#define boneWeight" + attr.unit + "Flag\n";
        }
    }
    if (skinned) {
        prefix += "#define skinningFlag\n";
    }
    Environment environment = renderable.environment;
    // Ambient lighting
    ColorAttribute ambientLightAttribute = (ColorAttribute) environment.get(ColorAttribute.AmbientLight);
    if (ambientLightAttribute != null) {
        prefix += "#define ambientLighting\n";
    }
    // Directional lighting
    DirectionalLightsAttribute directionalLightsAttribute = (DirectionalLightsAttribute) environment.get(DirectionalLightsAttribute.Type);
    if (directionalLightsAttribute != null) {
        Array<DirectionalLight> directionalLights = directionalLightsAttribute.lights;
        if (directionalLights.size > 0) {
            prefix += "#define numDirectionalLights " + directionalLights.size + "\n";
        }
    }
    // Point lighting
    PointLightsAttribute pointLightsAttribute = (PointLightsAttribute) environment.get(PointLightsAttribute.Type);
    if (pointLightsAttribute != null) {
        Array<PointLight> pointLights = pointLightsAttribute.lights;
        if (pointLights.size > 0) {
            prefix += "#define numPointLights " + pointLights.size + "\n";
        }
    }
    // Spot lighting
    SpotLightsAttribute spotLightsAttribute = (SpotLightsAttribute) environment.get(SpotLightsAttribute.Type);
    if (spotLightsAttribute != null) {
        Array<SpotLight> spotLights = spotLightsAttribute.lights;
        if (spotLights.size > 0) {
            prefix += "#define numSpotLights " + spotLights.size + "\n";
        }
    }
    return prefix;
}
Also used : SpotLight(com.badlogic.gdx.graphics.g3d.environment.SpotLight) VertexAttribute(com.badlogic.gdx.graphics.VertexAttribute) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) Environment(com.badlogic.gdx.graphics.g3d.Environment) PointLight(com.badlogic.gdx.graphics.g3d.environment.PointLight)

Aggregations

SpotLight (com.badlogic.gdx.graphics.g3d.environment.SpotLight)6 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)5 PointLight (com.badlogic.gdx.graphics.g3d.environment.PointLight)5 SpotLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.SpotLightsAttribute)3 Environment (com.badlogic.gdx.graphics.g3d.Environment)2 DirectionalLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.DirectionalLightsAttribute)2 PointLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.PointLightsAttribute)2 Camera (com.badlogic.gdx.graphics.Camera)1 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 LightProperties (com.badlogic.gdx.tests.g3d.shadows.system.BaseShadowSystem.LightProperties)1 Vector3f (javax.vecmath.Vector3f)1