@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()); }
protected void randomizeLights () { int pointLights = MathUtils.random(5); int directionalLights = MathUtils.random(5); DefaultShader.Config config = new Config(); config.numDirectionalLights = directionalLights; config.numPointLights = pointLights; config.numSpotLights = 0; modelBatch.dispose(); modelBatch = new ModelBatch(new DefaultShaderProvider(config)); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); for (int i = 0; i < pointLights; i++) { environment.add(new PointLight().set(randomColor(), randomPosition(), MathUtils.random(10f))); } for (int i = 0; i < directionalLights; i++) { environment.add(new DirectionalLight().set(randomColor(), randomPosition())); } }
this.pointLights = new PointLight[lighting && config.numPointLights > 0 ? config.numPointLights : 0]; for (int i = 0; i < pointLights.length; i++) pointLights[i] = new PointLight(); this.spotLights = new SpotLight[lighting && config.numSpotLights > 0 ? config.numSpotLights : 0]; for (int i = 0; i < spotLights.length; i++)
this.pointLights = new PointLight[lighting && config.numPointLights > 0 ? config.numPointLights : 0]; for (int i = 0; i < pointLights.length; i++) pointLights[i] = new PointLight(); this.spotLights = new SpotLight[lighting && config.numSpotLights > 0 ? config.numSpotLights : 0]; for (int i = 0; i < spotLights.length; i++)
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; } }
private void spawnLight(BlenderLight bLight) { Vector3 direction = new Vector3(V3_DOWN); direction.rotate(Vector3.X, bLight.rotation.x); direction.rotate(Vector3.Z, bLight.rotation.z); direction.rotate(Vector3.Y, bLight.rotation.y); // TODO: Don't know how to map lamp intensity in blender to libgdx correctly float intensity = bLight.lamp_energy; float cutoffAngle = bLight.lamp_falloff; float exponent = 1; if (bLight.type.equals("PointLamp")) { BaseLight<?> light = new PointLight().set( bLight.lamp_color.r, bLight.lamp_color.g, bLight.lamp_color.b, bLight.position, bLight.lamp_energy); lights.add(light); } else if (bLight.type.equals("SpotLamp")) { BaseLight<?> light = new SpotLight().set(bLight.lamp_color, bLight.position, direction, intensity, cutoffAngle, exponent); lights.add(light); } else if (bLight.type.equals("SunLamp")) { BaseLight<?> light = new DirectionalLight().set( bLight.lamp_color.r, bLight.lamp_color.g, bLight.lamp_color.b, direction.x, direction.y, direction.z); lights.add(light); shadowCameraDirection.set(direction); } }
this.pointLights = new PointLight[lighting && config.numPointLights > 0 ? config.numPointLights : 0]; for (int i = 0; i < pointLights.length; i++) pointLights[i] = new PointLight(); this.spotLights = new SpotLight[lighting && config.numSpotLights > 0 ? config.numSpotLights : 0]; for (int i = 0; i < spotLights.length; i++)