Search in sources :

Example 16 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class ShadowUtil method addGeometriesInCamFrustumAndViewPortFromNode.

/**
     * Helper function to recursively collect the geometries for getLitGeometriesInViewPort function.
     * 
     * @param vpCamera the viewPort camera 
     * @param cameras the camera array to check geometries against, representing the light viewspace
     * @param scene the Node to traverse or geometry to possibly add
     * @param outputGeometryList the output list of all geometries that are in the camera frustum
     */
private static void addGeometriesInCamFrustumAndViewPortFromNode(Camera vpCamera, Camera[] cameras, Spatial scene, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) {
    if (scene.getCullHint() == Spatial.CullHint.Always)
        return;
    boolean inFrustum = false;
    for (int j = 0; j < cameras.length && inFrustum == false; j++) {
        Camera camera = cameras[j];
        int planeState = camera.getPlaneState();
        camera.setPlaneState(0);
        inFrustum = camera.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside && scene.checkCulling(vpCamera);
        camera.setPlaneState(planeState);
    }
    if (inFrustum) {
        if (scene instanceof Node) {
            Node node = (Node) scene;
            for (Spatial child : node.getChildren()) {
                addGeometriesInCamFrustumAndViewPortFromNode(vpCamera, cameras, child, mode, outputGeometryList);
            }
        } else if (scene instanceof Geometry) {
            if (checkShadowMode(scene.getShadowMode(), mode) && !((Geometry) scene).isGrouped()) {
                outputGeometryList.add((Geometry) scene);
            }
        }
    }
}
Also used : Geometry(com.jme3.scene.Geometry) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Camera(com.jme3.renderer.Camera)

Example 17 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class DirectionalLightShadowRenderer method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    lambda = ic.readFloat("lambda", 0.65f);
    zFarOverride = ic.readInt("zFarOverride", 0);
    light = (DirectionalLight) ic.readSavable("light", null);
    fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null);
    fadeLength = ic.readFloat("fadeLength", 0f);
    init(nbShadowMaps, (int) shadowMapSize);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 18 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class PointLightShadowRenderer method write.

@Override
public void write(JmeExporter ex) throws IOException {
    super.write(ex);
    OutputCapsule oc = ex.getCapsule(this);
    oc.write(light, "light", null);
}
Also used : OutputCapsule(com.jme3.export.OutputCapsule)

Example 19 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class PointLightShadowRenderer method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    light = (PointLight) ic.readSavable("light", null);
    init((int) shadowMapSize);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 20 with Light

use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.

the class PointLightShadowRenderer method checkCulling.

/**
     *
     * @param viewCam
     * @return 
     */
@Override
protected boolean checkCulling(Camera viewCam) {
    if (light == null) {
        return false;
    }
    Camera cam = viewCam;
    if (frustumCam != null) {
        cam = frustumCam;
        cam.setLocation(viewCam.getLocation());
        cam.setRotation(viewCam.getRotation());
    }
    TempVars vars = TempVars.get();
    boolean intersects = light.intersectsFrustum(cam, vars);
    vars.release();
    return intersects;
}
Also used : Camera(com.jme3.renderer.Camera) TempVars(com.jme3.util.TempVars)

Aggregations

Vector3f (com.jme3.math.Vector3f)64 Material (com.jme3.material.Material)61 DirectionalLight (com.jme3.light.DirectionalLight)55 Geometry (com.jme3.scene.Geometry)52 PointLight (com.jme3.light.PointLight)27 Spatial (com.jme3.scene.Spatial)27 Box (com.jme3.scene.shape.Box)26 Sphere (com.jme3.scene.shape.Sphere)26 ColorRGBA (com.jme3.math.ColorRGBA)24 Quaternion (com.jme3.math.Quaternion)21 Node (com.jme3.scene.Node)21 AmbientLight (com.jme3.light.AmbientLight)20 Texture (com.jme3.texture.Texture)18 SpotLight (com.jme3.light.SpotLight)16 FilterPostProcessor (com.jme3.post.FilterPostProcessor)15 KeyTrigger (com.jme3.input.controls.KeyTrigger)11 Test (org.junit.Test)11 TempVars (com.jme3.util.TempVars)10 Light (com.jme3.light.Light)9 Camera (com.jme3.renderer.Camera)9