Package com.badlogic.gdx.graphics.g3d

Examples of com.badlogic.gdx.graphics.g3d.Environment


    context.setDepthMask(depthMask);
  }

  private final Vector3 tmpV1 = new Vector3();
  protected final void bindLights(final Renderable renderable) {
    final Environment lights = renderable.environment;
    final Array<DirectionalLight> dirs = lights.directionalLights;
    final Array<PointLight> points = lights.pointLights;
   
    if (dirLightsLoc >= 0) {
      for (int i = 0; i < directionalLights.length; i++) {
        if (dirs == null || i >= dirs.size) {
          if (lightsSet && directionalLights[i].color.r == 0f && directionalLights[i].color.g == 0f && directionalLights[i].color.b == 0f)
            continue;
          directionalLights[i].color.set(0,0,0,1);
        } else if (lightsSet && directionalLights[i].equals(dirs.get(i)))
          continue;
        else
          directionalLights[i].set(dirs.get(i));
       
        int idx = dirLightsLoc + i * dirLightsSize;
        program.setUniformf(idx+dirLightsColorOffset, directionalLights[i].color.r, directionalLights[i].color.g, directionalLights[i].color.b);
        program.setUniformf(idx+dirLightsDirectionOffset, directionalLights[i].direction);
        if (dirLightsSize <= 0)
          break;
      }
    }
   
    if (pointLightsLoc >= 0) {
      for (int i = 0; i < pointLights.length; i++) {
        if (points == null || i >= points.size) {
          if (lightsSet && pointLights[i].intensity == 0f)
            continue;
          pointLights[i].intensity = 0f;
        } else if (lightsSet && pointLights[i].equals(points.get(i)))
          continue;
        else
          pointLights[i].set(points.get(i));

        int idx = pointLightsLoc + i * pointLightsSize;
        program.setUniformf(idx+pointLightsColorOffset, pointLights[i].color.r, pointLights[i].color.g, pointLights[i].color.b);
        program.setUniformf(idx+pointLightsPositionOffset, pointLights[i].position);
        if (pointLightsIntensityOffset >= 0)
          program.setUniformf(idx+pointLightsIntensityOffset, pointLights[i].intensity);
        if (pointLightsSize <= 0)
          break;
      }
    }

    if (lights.has(ColorAttribute.Fog)) {
      set(u_fogColor, ((ColorAttribute)lights.get(ColorAttribute.Fog)).color);
    }
   
    if (lights.shadowMap != null) {
      set(u_shadowMapProjViewTrans, lights.shadowMap.getProjViewTrans());
      set(u_shadowTexture, lights.shadowMap.getDepthMap());
View Full Code Here


   
    public void create () {
      if (ui != null) return;
      int w = Gdx.graphics.getWidth(), h = Gdx.graphics.getHeight();
      modelBatch = new ModelBatch();
      environment = new Environment();
      environment.add(new DirectionalLight().set(Color.WHITE, 0,0,-1));
     
      worldCamera = new PerspectiveCamera(67, w, h);
      worldCamera.position.set(10, 10, 10);
      worldCamera.lookAt(0,0,0);
View Full Code Here

  }

  private final Vector3 tmpV1 = new Vector3();

  protected void bindLights (final Renderable renderable) {
    final Environment lights = renderable.environment;
    final Array<DirectionalLight> dirs = lights.directionalLights;
    final Array<PointLight> points = lights.pointLights;

    if (dirLightsLoc >= 0) {
      for (int i = 0; i < directionalLights.length; i++) {
        if (dirs == null || i >= dirs.size) {
          if (lightsSet && directionalLights[i].color.r == 0f && directionalLights[i].color.g == 0f
            && directionalLights[i].color.b == 0f) continue;
          directionalLights[i].color.set(0, 0, 0, 1);
        } else if (lightsSet && directionalLights[i].equals(dirs.get(i)))
          continue;
        else
          directionalLights[i].set(dirs.get(i));

        int idx = dirLightsLoc + i * dirLightsSize;
        program.setUniformf(idx + dirLightsColorOffset, directionalLights[i].color.r, directionalLights[i].color.g,
          directionalLights[i].color.b);
        program.setUniformf(idx + dirLightsDirectionOffset, directionalLights[i].direction);
        if (dirLightsSize <= 0) break;
      }
    }

    if (pointLightsLoc >= 0) {
      for (int i = 0; i < pointLights.length; i++) {
        if (points == null || i >= points.size) {
          if (lightsSet && pointLights[i].intensity == 0f) continue;
          pointLights[i].intensity = 0f;
        } else if (lightsSet && pointLights[i].equals(points.get(i)))
          continue;
        else
          pointLights[i].set(points.get(i));

        int idx = pointLightsLoc + i * pointLightsSize;
        program.setUniformf(idx + pointLightsColorOffset, pointLights[i].color.r * pointLights[i].intensity,
          pointLights[i].color.g * pointLights[i].intensity, pointLights[i].color.b * pointLights[i].intensity);
        program.setUniformf(idx + pointLightsPositionOffset, pointLights[i].position);
        if (pointLightsSize <= 0) break;
      }
    }

    if (lights.has(ColorAttribute.Fog)) {
      set(u_fogColor, ((ColorAttribute)lights.get(ColorAttribute.Fog)).color);
    }

    if (lights.shadowMap != null) {
      set(u_shadowMapProjViewTrans, lights.shadowMap.getProjViewTrans());
      set(u_shadowTexture, lights.shadowMap.getDepthMap());
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.g3d.Environment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.