Search in sources :

Example 1 with LightProbe

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();
}
Also used : Geometry(com.jme3.scene.Geometry) LightProbe(com.jme3.light.LightProbe) Light(com.jme3.light.Light) Node(com.jme3.scene.Node) Material(com.jme3.material.Material)

Example 2 with LightProbe

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();
    }
}
Also used : BoundingSphere(com.jme3.bounding.BoundingSphere) BoundingBox(com.jme3.bounding.BoundingBox) BoundingVolume(com.jme3.bounding.BoundingVolume) TempVars(com.jme3.util.TempVars)

Example 3 with LightProbe

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);
    }
}
Also used : BoundingSphere(com.jme3.bounding.BoundingSphere) LightProbe(com.jme3.light.LightProbe) EnvironmentCamera(com.jme3.environment.EnvironmentCamera)

Example 4 with LightProbe

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);
    }
}
Also used : BoundingSphere(com.jme3.bounding.BoundingSphere) LightProbe(com.jme3.light.LightProbe) EnvironmentCamera(com.jme3.environment.EnvironmentCamera)

Example 5 with LightProbe

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);
// }
}
Also used : BoundingSphere(com.jme3.bounding.BoundingSphere) LightProbe(com.jme3.light.LightProbe) EnvironmentCamera(com.jme3.environment.EnvironmentCamera)

Aggregations

BoundingSphere (com.jme3.bounding.BoundingSphere)6 LightProbe (com.jme3.light.LightProbe)6 EnvironmentCamera (com.jme3.environment.EnvironmentCamera)3 TempVars (com.jme3.util.TempVars)3 Node (com.jme3.scene.Node)2 BoundingBox (com.jme3.bounding.BoundingBox)1 BoundingVolume (com.jme3.bounding.BoundingVolume)1 IrradianceMapGenerator (com.jme3.environment.generation.IrradianceMapGenerator)1 PrefilteredEnvMapFaceGenerator (com.jme3.environment.generation.PrefilteredEnvMapFaceGenerator)1 Light (com.jme3.light.Light)1 Material (com.jme3.material.Material)1 Geometry (com.jme3.scene.Geometry)1 Spatial (com.jme3.scene.Spatial)1 TextureCubeMap (com.jme3.texture.TextureCubeMap)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1