use of com.jme3.light.LightProbe in project jmonkeyengine by jMonkeyEngine.
the class LightsDebugState method update.
@Override
public void update(float tpf) {
for (Light light : scene.getWorldLightList()) {
switch(light.getType()) {
case Probe:
LightProbe probe = (LightProbe) light;
probes.add(probe);
Node n = probeMapping.get(probe);
if (n == null) {
n = new Node("DebugProbe");
n.attachChild(debugGeom.clone(true));
n.attachChild(debugBounds.clone(false));
debugNode.attachChild(n);
probeMapping.put(probe, n);
}
Geometry probeGeom = ((Geometry) n.getChild(0));
Material m = probeGeom.getMaterial();
probeGeom.setLocalScale(probeScale);
if (probe.isReady()) {
if (debugMode == DebugMode.IrradianceMap) {
m.setTexture("CubeMap", probe.getIrradianceMap());
} else {
m.setTexture("CubeMap", probe.getPrefilteredEnvMap());
}
}
n.setLocalTranslation(probe.getPosition());
n.getChild(1).setLocalScale(((BoundingSphere) probe.getBounds()).getRadius());
break;
default:
break;
}
}
debugNode.updateLogicalState(tpf);
debugNode.updateGeometricState();
cleanProbes();
}
use of com.jme3.light.LightProbe in project jmonkeyengine by jMonkeyEngine.
the class DefaultLightFilter method filterLights.
@Override
public void filterLights(Geometry geometry, LightList filteredLightList) {
TempVars vars = TempVars.get();
try {
LightList worldLights = geometry.getWorldLightList();
for (int i = 0; i < worldLights.size(); i++) {
Light light = worldLights.get(i);
// If this light is not enabled it will be ignored.
if (!light.isEnabled()) {
continue;
}
if (light.frustumCheckNeeded) {
processedLights.add(light);
light.frustumCheckNeeded = false;
light.intersectsFrustum = light.intersectsFrustum(camera, vars);
}
if (!light.intersectsFrustum) {
continue;
}
BoundingVolume bv = geometry.getWorldBound();
if (bv instanceof BoundingBox) {
if (!light.intersectsBox((BoundingBox) bv, vars)) {
continue;
}
} else if (bv instanceof BoundingSphere) {
if (!Float.isInfinite(((BoundingSphere) bv).getRadius())) {
if (!light.intersectsSphere((BoundingSphere) bv, vars)) {
continue;
}
}
}
if (light.getType() == Light.Type.Probe) {
probeBlendStrat.registerProbe((LightProbe) light);
} else {
filteredLightList.add(light);
}
}
probeBlendStrat.populateProbes(geometry, filteredLightList);
} finally {
vars.release();
}
}
use of com.jme3.light.LightProbe in project jmonkeyengine by jMonkeyEngine.
the class RefEnv method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
// guiNode.attachChild(tex);
rootNode.getChild("Scene").setCullHint(Spatial.CullHint.Dynamic);
}
});
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
}
}
use of com.jme3.light.LightProbe in project jmonkeyengine by jMonkeyEngine.
the class TestPBRLighting method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
modelNode.removeFromParent();
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.err.println("Done rendering env maps");
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
tex2 = EnvMapUtils.getCubeMapCrossDebugView(result.getIrradianceMap(), assetManager);
}
});
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
//getStateManager().getState(EnvironmentManager.class).addEnvProbe(probe);
}
if (frame > 10 && modelNode.getParent() == null) {
rootNode.attachChild(modelNode);
}
}
use of com.jme3.light.LightProbe in project TeachingInSimulation by ScOrPiOzzy.
the class TestPBRLighting method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
frame++;
if (frame == 2) {
// modelNode.removeFromParent();
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode);
((BoundingSphere) probe.getBounds()).setRadius(100);
rootNode.addLight(probe);
// getStateManager().getState(EnvironmentManager.class).addEnvProbe(probe);
}
// if (frame > 10 && modelNode.getParent() == null) {
// rootNode.attachChild(modelNode);
// }
}
Aggregations