Search in sources :

Example 6 with PointLight

use of com.badlogic.gdx.graphics.g3d.environment.PointLight in project bdx by GoranM.

the class Light method on.

public void on(boolean on) {
    this.on = on;
    if (type == Type.POINT) {
        PointLightsAttribute la = (PointLightsAttribute) scene.environment.get(PointLightsAttribute.Type);
        PointLight pl = (PointLight) lightData;
        if (on && !la.lights.contains(pl, true))
            la.lights.add(pl);
        else if (!on && la.lights.contains(pl, true))
            la.lights.removeValue(pl, true);
    } else if (type == Type.SUN) {
        DirectionalLightsAttribute la = (DirectionalLightsAttribute) scene.environment.get(DirectionalLightsAttribute.Type);
        DirectionalLight dl = (DirectionalLight) lightData;
        if (on && !la.lights.contains(dl, true))
            la.lights.add(dl);
        else if (!on && la.lights.contains(dl, true))
            la.lights.removeValue(dl, true);
    } else if (type == Type.SPOT) {
        SpotLightsAttribute la = (SpotLightsAttribute) scene.environment.get(SpotLightsAttribute.Type);
        SpotLight sl = (SpotLight) lightData;
        if (on && !la.lights.contains(sl, true))
            la.lights.add(sl);
        else if (!on && la.lights.contains(sl, true))
            la.lights.removeValue(sl, true);
    }
}
Also used : DirectionalLightsAttribute(com.badlogic.gdx.graphics.g3d.attributes.DirectionalLightsAttribute) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) PointLightsAttribute(com.badlogic.gdx.graphics.g3d.attributes.PointLightsAttribute) SpotLightsAttribute(com.badlogic.gdx.graphics.g3d.attributes.SpotLightsAttribute) PointLight(com.badlogic.gdx.graphics.g3d.environment.PointLight) SpotLight(com.badlogic.gdx.graphics.g3d.environment.SpotLight)

Example 7 with PointLight

use of com.badlogic.gdx.graphics.g3d.environment.PointLight 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

DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)7 PointLight (com.badlogic.gdx.graphics.g3d.environment.PointLight)7 SpotLight (com.badlogic.gdx.graphics.g3d.environment.SpotLight)5 Environment (com.badlogic.gdx.graphics.g3d.Environment)3 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)2 DirectionalLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.DirectionalLightsAttribute)2 PointLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.PointLightsAttribute)2 SpotLightsAttribute (com.badlogic.gdx.graphics.g3d.attributes.SpotLightsAttribute)2 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)1 Material (com.badlogic.gdx.graphics.g3d.Material)1 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)1 Renderable (com.badlogic.gdx.graphics.g3d.Renderable)1 DefaultShader (com.badlogic.gdx.graphics.g3d.shaders.DefaultShader)1 Config (com.badlogic.gdx.graphics.g3d.shaders.DefaultShader.Config)1 DefaultShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider)1 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)1 Vector3f (javax.vecmath.Vector3f)1