Java 类com.badlogic.gdx.graphics.g3d.environment.PointLight 实例源码

项目:BotLogic    文件:LedEntity.java   
public LedEntity(Model model) {
  super(model);

  light = new PointLight();
  light.set(new Color(1f,1f, 1f, 1f), Vector3.Zero, 2f);

  for (Material material : instance.materials) {

    if (material.id.contains("Led")) {
      this.colorAttr = (ColorAttribute)material.get(ColorAttribute.Diffuse);
      colorAttr.color.set(Color.WHITE);

      this.blendingAttribute = (BlendingAttribute)material.get(BlendingAttribute.Type);
      blendingAttribute.opacity = 1.0f;
      blendingAttribute.sourceFunction = GL20.GL_ONE;
      blendingAttribute.destFunction = GL20.GL_SRC_ALPHA;

    }
  }
}
项目:Skyland    文件:WorldGenerator.java   
public static Environment generateBaseEnvironment(Vector3 sun) {
    Environment environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    environment.set(new ColorAttribute(ColorAttribute.Fog, .3f, .55f, 1, 1));
    environment.add(new DirectionalLight().set(.3f, .3f, .3f, -.2f, 0.6f, .8f));
    environment.add(new DirectionalLight().set(1f, 1f, 1f, .2f, -0.6f, -.8f));
    environment.add(new PointLight().set(1, 1, 1, sun, 200));
    return environment;
}
项目:libgdxcn    文件:DefaultShader.java   
@Override
public void begin (final Camera camera, final RenderContext context) {
    super.begin(camera, context);

    for (final DirectionalLight dirLight : directionalLights)
        dirLight.set(0, 0, 0, 0, -1, 0);
    for (final PointLight pointLight : pointLights)
        pointLight.set(0, 0, 0, 0, 0, 0, 0);
    lightsSet = false;

    if (has(u_time)) set(u_time, time += Gdx.graphics.getDeltaTime());
}
项目:libgdxcn    文件:Environment.java   
public Environment add (BaseLight light) {
    if (light instanceof DirectionalLight)
        directionalLights.add((DirectionalLight)light);
    else if (light instanceof PointLight)
        pointLights.add((PointLight)light);
    else
        throw new GdxRuntimeException("Unknown light type");
    return this;
}
项目:libgdxcn    文件:Environment.java   
public Environment remove (BaseLight light) {
    if (light instanceof DirectionalLight)
        directionalLights.removeValue((DirectionalLight)light, false);
    else if (light instanceof PointLight)
        pointLights.removeValue((PointLight)light, false);
    else
        throw new GdxRuntimeException("Unknown light type");
    return this;
}
项目:libgdxcn    文件:LightsTest.java   
@Override
public void create () {
    super.create();
    environment.clear();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.2f, 0.2f, 0.2f, 1.0f));
    environment.add(dirLight = new DirectionalLight().set(0.8f, 0.2f, 0.2f, -1f, -2f, -0.5f));
    environment.add(pointLight = new PointLight().set(0.2f, 0.8f, 0.2f, 0f, 0f, 0f, 100f));

    ModelBuilder mb = new ModelBuilder();
    lightModel = mb.createSphere(1, 1, 1, 10, 10, new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position);
    lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable());
}
项目:bladecoder-adventure-engine    文件:Sprite3DRenderer.java   
private void createEnvirontment() {
    environment = new Environment();

    // environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.8f,
    // 0.8f, 0.8f, 1f));

    // environment.add(new DirectionalLight().set(1f, 1f, 1f, 1f, -1f,
    // -1f));

    if (celLight == null) {
        Node n = null;

        if (currentSource != null)
            n = ((ModelCacheEntry)currentSource).modelInstance.getNode(celLightName);

        if (n != null) {
            celLight = new PointLight().set(1f, 1f, 1f, n.translation, 1f);
        } else {
            celLight = new PointLight().set(1f, 1f, 1f, 0.5f, 1f, 1f, 1f);
        }
    }

    environment.add(celLight);

    if (renderShadow) {
        shadowEnvironment = new Environment();
        shadowEnvironment.add(shadowLight);
        shadowEnvironment.shadowMap = shadowLight;
    }
}
项目:amatsukaze    文件:LightsTest.java   
@Override
public void create () {
    super.create();
    environment.clear();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.2f, 0.2f, 0.2f, 1.0f));
    environment.add(dirLight = new DirectionalLight().set(0.8f, 0.2f, 0.2f, -1f, -2f, -0.5f));
    environment.add(pointLight = new PointLight().set(0.2f, 0.8f, 0.2f, 0f, 0f, 0f, 100f));

    ModelBuilder mb = new ModelBuilder();
    lightModel = mb.createSphere(1, 1, 1, 10, 10, new Material(ColorAttribute.createDiffuse(1, 1, 1, 1)), Usage.Position);
    lightModel.nodes.get(0).parts.get(0).setRenderable(pLight = new Renderable());
}
项目:nhglib    文件:ShaderUtils.java   
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;
}
项目:Argent    文件:DecalRenderer.java   
public void setLight() {
    PointLightWrapper l = new PointLightWrapper(new PointLight());
    l.light.position.set(10, 10, 10);
    l.light.intensity = 10;
    l.applyToShader(shaderProgram);
}
项目:Argent    文件:DepthRenderer.java   
public DepthRenderer(WorldRenderer<T> renderer) {
    super(renderer);
    this.lights = new ArrayList<>();
    addLight(new PointLightWrapper(new PointLight().set(Color.WHITE, new Vector3(-300, 300, -300), 500)));
}
项目:Argent    文件:PointLightWrapper.java   
public PointLightWrapper(PointLight light) {
    super(light);
}
项目:libgdxcn    文件:DefaultShader.java   
public DefaultShader (final Renderable renderable, final Config config, final ShaderProgram shaderProgram) {
    this.config = config;
    this.program = shaderProgram;
    this.lighting = renderable.environment != null;
    this.environmentCubemap = renderable.material.has(CubemapAttribute.EnvironmentMap)
        || (lighting && renderable.environment.has(CubemapAttribute.EnvironmentMap));
    this.shadowMap = lighting && renderable.environment.shadowMap != null;
    this.fog = lighting && renderable.environment.has(ColorAttribute.Fog);
    this.renderable = renderable;
    materialMask = renderable.material.getMask() | optionalAttributes;
    vertexMask = renderable.mesh.getVertexAttributes().getMask();

    this.directionalLights = new DirectionalLight[lighting && config.numDirectionalLights > 0 ? config.numDirectionalLights : 0];
    for (int i = 0; i < directionalLights.length; i++)
        directionalLights[i] = new DirectionalLight();
    this.pointLights = new PointLight[lighting && config.numPointLights > 0 ? config.numPointLights : 0];
    for (int i = 0; i < pointLights.length; i++)
        pointLights[i] = new PointLight();

    if (!config.ignoreUnimplemented && (implementedFlags & materialMask) != materialMask)
        throw new GdxRuntimeException("Some attributes not implemented yet (" + materialMask + ")");

    // Global uniforms
    u_projTrans = register(Inputs.projTrans, Setters.projTrans);
    u_viewTrans = register(Inputs.viewTrans, Setters.viewTrans);
    u_projViewTrans = register(Inputs.projViewTrans, Setters.projViewTrans);
    u_cameraPosition = register(Inputs.cameraPosition, Setters.cameraPosition);
    u_cameraDirection = register(Inputs.cameraDirection, Setters.cameraDirection);
    u_cameraUp = register(Inputs.cameraUp, Setters.cameraUp);
    u_time = register(new Uniform("u_time"));
    // Object uniforms
    u_worldTrans = register(Inputs.worldTrans, Setters.worldTrans);
    u_viewWorldTrans = register(Inputs.viewWorldTrans, Setters.viewWorldTrans);
    u_projViewWorldTrans = register(Inputs.projViewWorldTrans, Setters.projViewWorldTrans);
    u_normalMatrix = register(Inputs.normalMatrix, Setters.normalMatrix);
    u_bones = (renderable.bones != null && config.numBones > 0) ? register(Inputs.bones, new Setters.Bones(config.numBones))
        : -1;

    u_shininess = register(Inputs.shininess, Setters.shininess);
    u_opacity = register(Inputs.opacity);
    u_diffuseColor = register(Inputs.diffuseColor, Setters.diffuseColor);
    u_diffuseTexture = register(Inputs.diffuseTexture, Setters.diffuseTexture);
    u_diffuseUVTransform = register(Inputs.diffuseUVTransform, Setters.diffuseUVTransform);
    u_specularColor = register(Inputs.specularColor, Setters.specularColor);
    u_specularTexture = register(Inputs.specularTexture, Setters.specularTexture);
    u_specularUVTransform = register(Inputs.specularUVTransform, Setters.specularUVTransform);
    u_emissiveColor = register(Inputs.emissiveColor, Setters.emissiveColor);
    u_emissiveTexture = register(Inputs.emissiveTexture, Setters.emissiveTexture);
    u_emissiveUVTransform = register(Inputs.emissiveUVTransform, Setters.emissiveUVTransform);
    u_reflectionColor = register(Inputs.reflectionColor, Setters.reflectionColor);
    u_reflectionTexture = register(Inputs.reflectionTexture, Setters.reflectionTexture);
    u_reflectionUVTransform = register(Inputs.reflectionUVTransform, Setters.reflectionUVTransform);
    u_normalTexture = register(Inputs.normalTexture, Setters.normalTexture);
    u_normalUVTransform = register(Inputs.normalUVTransform, Setters.normalUVTransform);
    u_ambientTexture = register(Inputs.ambientTexture, Setters.ambientTexture);
    u_ambientUVTransform = register(Inputs.ambientUVTransform, Setters.ambientUVTransform);
    u_alphaTest = register(Inputs.alphaTest);

    u_ambientCubemap = lighting ? register(Inputs.ambientCube, new Setters.ACubemap(config.numDirectionalLights,
        config.numPointLights)) : -1;
    u_environmentCubemap = environmentCubemap ? register(Inputs.environmentCubemap, Setters.environmentCubemap) : -1;
}
项目:gdx-proto    文件:View.java   
public View() {
    ModelManager modelManager = new ModelManager();
    modelManager.init();
    storeSize();
    inst = this;
    gl = Gdx.graphics.getGL20();
    float fov = 67f;
    camera = new PerspectiveCamera(fov, width(), height());
    // camera.far affects frustrum culling, so a shorter distance can boost performance
    camera.far = 60f;
    camera.near = 0.01f;
    resetCamera();

    initShaders();
    modelBatch = new ModelBatch(shaderProvider);

    environ = new Environment();
    basicEnviron = new Environment();
    camLight = new PointLight();
    float intensity = 100f;
    camLight.set(new Color(0.2f, 0.2f, 0.2f, 1f), 0f, 0f, 0f, intensity);
    ColorAttribute ambientLight = ColorAttribute.createAmbient(new Color(0.1f, 0.1f, 0.1f, 1f));
    environ.set(ambientLight);
    ColorAttribute fog = new ColorAttribute(ColorAttribute.Fog);
    fog.color.set(fogColor);
    environ.set(fog);
    environ.add(camLight);
    dirLight = new DirectionalLight();
    dirLight.set(new Color(0.3f, 0.3f, 0.35f, 1f), -0.25f, -0.75f, 0.25f);
    environ.add(dirLight);

    basicEnviron.set(ColorAttribute.createAmbient(0.3f, 0.3f, 0.3f, 1f));

    if (Toggleable.profileGL()) {
        Profiler.enable();
    }

    hud = new HUD();

    Sky.createSkyBox(
        Assets.manager.get("textures/skybox/xpos.png", Texture.class),
        Assets.manager.get("textures/skybox/xneg.png", Texture.class),
        Assets.manager.get("textures/skybox/ypos.png", Texture.class),
        Assets.manager.get("textures/skybox/yneg.png", Texture.class),
        Assets.manager.get("textures/skybox/zpos.png", Texture.class),
        Assets.manager.get("textures/skybox/zneg.png", Texture.class)
    );
}