Search in sources :

Example 26 with Camera

use of com.jme3.renderer.Camera 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)

Example 27 with Camera

use of com.jme3.renderer.Camera in project jmonkeyengine by jMonkeyEngine.

the class SpotLightShadowRenderer method getReceivers.

@Override
protected void getReceivers(GeometryList lightReceivers) {
    lightReceivers.clear();
    Camera[] cameras = new Camera[1];
    cameras[0] = shadowCam;
    for (Spatial scene : viewPort.getScenes()) {
        ShadowUtil.getLitGeometriesInViewPort(scene, viewPort.getCamera(), cameras, RenderQueue.ShadowMode.Receive, lightReceivers);
    }
}
Also used : Spatial(com.jme3.scene.Spatial) Camera(com.jme3.renderer.Camera)

Example 28 with Camera

use of com.jme3.renderer.Camera in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRenderer method renderShadowMap.

protected void renderShadowMap(int shadowMapIndex) {
    shadowMapOccluders = getOccludersToRender(shadowMapIndex, shadowMapOccluders);
    Camera shadowCam = getShadowCam(shadowMapIndex);
    //saving light view projection matrix for this split            
    lightViewProjectionsMatrices[shadowMapIndex].set(shadowCam.getViewProjectionMatrix());
    renderManager.setCamera(shadowCam, false);
    renderManager.getRenderer().setFrameBuffer(shadowFB[shadowMapIndex]);
    renderManager.getRenderer().clearBuffers(true, true, true);
    renderManager.setForcedRenderState(forcedRenderState);
    // render shadow casters to shadow map
    viewPort.getQueue().renderShadowQueue(shadowMapOccluders, renderManager, shadowCam, true);
    renderManager.setForcedRenderState(null);
}
Also used : Camera(com.jme3.renderer.Camera)

Example 29 with Camera

use of com.jme3.renderer.Camera in project jmonkeyengine by jMonkeyEngine.

the class TestColorApp method simpleInitApp.

@Override
public void simpleInitApp() {
    // Lights
    DirectionalLight sun = new DirectionalLight();
    Vector3f sunPosition = new Vector3f(1, -1, 1);
    sun.setDirection(sunPosition);
    sun.setColor(new ColorRGBA(1f, 1f, 1f, 1f));
    rootNode.addLight(sun);
    //DirectionalLightShadowFilter sun_renderer = new DirectionalLightShadowFilter(assetManager, 2048, 4);
    DirectionalLightShadowRenderer sun_renderer = new DirectionalLightShadowRenderer(assetManager, 2048, 1);
    sun_renderer.setLight(sun);
    viewPort.addProcessor(sun_renderer);
    //        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    //        fpp.addFilter(sun_renderer);
    //        viewPort.addProcessor(fpp);
    rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
    // Camera
    viewPort.setBackgroundColor(new ColorRGBA(.6f, .6f, .6f, 1f));
    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    // Objects
    // Ground Object
    final Geometry groundBoxWhite = new Geometry("Box", new Box(7.5f, 7.5f, .25f));
    float[] f = { -FastMath.PI / 2, 3 * FastMath.PI / 2, 0f };
    groundBoxWhite.setLocalRotation(new Quaternion(f));
    groundBoxWhite.move(7.5f, -.75f, 7.5f);
    final Material groundMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    groundMaterial.setColor("Diffuse", new ColorRGBA(.9f, .9f, .9f, .9f));
    groundBoxWhite.setMaterial(groundMaterial);
    groundBoxWhite.addControl(chaseCam);
    rootNode.attachChild(groundBoxWhite);
    // Planter
    Geometry planterBox = new Geometry("Box", new Box(.5f, .5f, .5f));
    final Material planterMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    planterMaterial.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
    planterBox.setMaterial(groundMaterial);
    planterBox.setLocalTranslation(10, 0, 9);
    rootNode.attachChild(planterBox);
    // Action!
    inputManager.addMapping("on", new KeyTrigger(KeyInput.KEY_Z));
    inputManager.addMapping("off", new KeyTrigger(KeyInput.KEY_X));
    inputManager.addListener(new AnalogListener() {

        @Override
        public void onAnalog(String s, float v, float v1) {
            if (s.equals("on")) {
                groundBoxWhite.setMaterial(planterMaterial);
            }
            if (s.equals("off")) {
                groundBoxWhite.setMaterial(groundMaterial);
            }
        }
    }, "on", "off");
    inputEnabled = true;
}
Also used : Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) ChaseCamera(com.jme3.input.ChaseCamera) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Geometry(com.jme3.scene.Geometry) ColorRGBA(com.jme3.math.ColorRGBA) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) AnalogListener(com.jme3.input.controls.AnalogListener)

Example 30 with Camera

use of com.jme3.renderer.Camera in project jmonkeyengine by jMonkeyEngine.

the class TestDirectionalLightShadow method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    //        cam.setLocation(new Vector3f(65.25412f, 44.38738f, 9.087874f));
    //        cam.setRotation(new Quaternion(0.078139365f, 0.050241485f, -0.003942559f, 0.9956679f));
    cam.setLocation(new Vector3f(3.3720117f, 42.838284f, -83.43792f));
    cam.setRotation(new Quaternion(0.13833192f, -0.08969371f, 0.012581267f, 0.9862358f));
    flyCam.setMoveSpeed(100);
    loadScene();
    dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
    dlsr.setLight(l);
    dlsr.setLambda(0.55f);
    dlsr.setShadowIntensity(0.8f);
    dlsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsr.displayDebug();
    viewPort.addProcessor(dlsr);
    dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 3);
    dlsf.setLight(l);
    dlsf.setLambda(0.55f);
    dlsf.setShadowIntensity(0.8f);
    dlsf.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsf.setEnabled(false);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(dlsf);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter)

Aggregations

Camera (com.jme3.renderer.Camera)63 Vector3f (com.jme3.math.Vector3f)51 Material (com.jme3.material.Material)26 Geometry (com.jme3.scene.Geometry)26 Quaternion (com.jme3.math.Quaternion)23 Spatial (com.jme3.scene.Spatial)19 TempVars (com.jme3.util.TempVars)16 Box (com.jme3.scene.shape.Box)13 ViewPort (com.jme3.renderer.ViewPort)11 Node (com.jme3.scene.Node)11 DirectionalLight (com.jme3.light.DirectionalLight)10 FrameBuffer (com.jme3.texture.FrameBuffer)10 Texture (com.jme3.texture.Texture)10 FilterPostProcessor (com.jme3.post.FilterPostProcessor)9 Texture2D (com.jme3.texture.Texture2D)9 ArrayList (java.util.ArrayList)9 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)8 AbstractHeightMap (com.jme3.terrain.heightmap.AbstractHeightMap)8 ImageBasedHeightMap (com.jme3.terrain.heightmap.ImageBasedHeightMap)8 CameraNode (com.jme3.scene.CameraNode)7