Hey, just wanted to see if anyone can tell me what I’m doing wrong here… I’m trying to decrease a pointlight based on a percentage of lifetime. So i’m creating the light like this:
private void createPointLight(Entity e) {
PointLightComponent plc = e.get(PointLightComponent.class);
BodyPosition bp = e.get(BodyPosition.class);
PointLight pl = new PointLight();
pl.setColor(plc.getColor());
pl.setRadius(plc.getRadius());
pointLightMap.put(e.getId(), pl);
//Create pointer to the threadsafe same position buffer array as modelviewstate.
//Ensure it is the same by initialising it everywhere it's used
bp.initialize(e.getId(), 12);
bufferMap.put(e.getId(), bp.getBuffer());
rootNode.addLight(pl);
}
And updating it like this:
decayingPointLights.applyChanges();
for (Entity e : decayingPointLights) {
if (pointLightMap.containsKey(e.getId())) {
PointLightComponent plc = e.get(PointLightComponent.class);
Decay d = e.get(Decay.class);
PointLight pl = pointLightMap.get(e.getId());
double percentage = d.getPercent();
float factor = (float) (1 - (FastMath.pow((float)percentage, 5f)));
float newRadius = Math.max(plc.getRadius() * factor , 0f);
ColorRGBA oldColor = pl.getColor();
ColorRGBA newColor = oldColor.clone();
newColor.a = factor;
pl.setColor(newColor);
pl.setRadius(newRadius);
if (factor < 0.5) {
log.info(String.valueOf(pl.getRadius()) + " " + pl.getColor());
}
}
}
The log was just to make sure my factor was working - now, the radius and alpha is decreasing as I want it to, but there’s no change in the lighting in the scene…’
Here’s the output from the log:
19:58:36,481 INFO [LightState] 138.6073 Color[1.0, 0.0, 0.0, 0.2772146]
19:58:36,497 INFO [LightState] 117.23256 Color[1.0, 0.0, 0.0, 0.23446512]
19:58:36,514 INFO [LightState] 93.824776 Color[1.0, 0.0, 0.0, 0.18764955]
19:58:36,530 INFO [LightState] 70.141045 Color[1.0, 0.0, 0.0, 0.1402821]
19:58:36,547 INFO [LightState] 44.515133 Color[1.0, 0.0, 0.0, 0.089030266]
19:58:36,564 INFO [LightState] 18.401415 Color[1.0, 0.0, 0.0, 0.03680283]
19:58:36,580 INFO [LightState] 0.0 Color[1.0, 0.0, 0.0, -0.017885804]