Search in sources :

Example 41 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestBatchNodeCluster method simpleInitApp.

//protected
//    protected Geometry player;
@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    batchNode = new SimpleBatchNode("BatchNode");
    xPosition.add(0);
    yPosition.add(0);
    zPosition.add(0);
    mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.White);
    mat1.setColor("GlowColor", ColorRGBA.Blue.mult(10));
    mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.White);
    mat2.setColor("GlowColor", ColorRGBA.Red.mult(10));
    mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat3.setColor("Color", ColorRGBA.White);
    mat3.setColor("GlowColor", ColorRGBA.Yellow.mult(10));
    mat4 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat4.setColor("Color", ColorRGBA.White);
    mat4.setColor("GlowColor", ColorRGBA.Orange.mult(10));
    randomGenerator();
    //rootNode.attachChild(SkyFactory.createSky(
    //  assetManager, "Textures/SKY02.zip", false));
    inputManager.addMapping("Start Game", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addListener(al, new String[] { "Start Game" });
    cam.setLocation(new Vector3f(-34.403286f, 126.65158f, 434.791f));
    cam.setRotation(new Quaternion(0.022630932f, 0.9749435f, -0.18736298f, 0.11776358f));
    batchNode.batch();
    terrain = new Node("terrain");
    terrain.setLocalTranslation(50, 0, 50);
    terrain.attachChild(batchNode);
    flyCam.setMoveSpeed(100);
    rootNode.attachChild(terrain);
    Vector3f pos = new Vector3f(-40, 0, -40);
    batchNode.setLocalTranslation(pos);
    Arrow a = new Arrow(new Vector3f(0, 50, 0));
    Geometry g = new Geometry("a", a);
    g.setLocalTranslation(terrain.getLocalTranslation());
    Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m.setColor("Color", ColorRGBA.Blue);
    g.setMaterial(m);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
    //        SSAOFilter ssao = new SSAOFilter(8.630104f,22.970434f,2.9299977f,0.2999997f);    
    //        fpp.addFilter(ssao);
    viewPort.addProcessor(fpp);
//   viewPort.setBackgroundColor(ColorRGBA.DarkGray);
}
Also used : Arrow(com.jme3.scene.debug.Arrow) NanoTimer(com.jme3.system.NanoTimer) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 42 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class TestBatchNodeTower method simpleInitApp.

@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    batchNode.batch();
    batchNode.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(batchNode);
    shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    shadowRenderer.setLight(dl);
    shadowRenderer.setLambda(0.55f);
    shadowRenderer.setShadowIntensity(0.6f);
    shadowRenderer.setShadowCompareMode(CompareMode.Hardware);
    shadowRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(shadowRenderer);
    viewPort.addProcessor(fpp);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) NanoTimer(com.jme3.system.NanoTimer) Vector2f(com.jme3.math.Vector2f) BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter)

Example 43 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project jmonkeyengine by jMonkeyEngine.

the class VRViewManagerOSVR method syncScreenProcessing.

/**
     * Sets the two views to use the list of {@link SceneProcessor processors}.
     * @param sourceViewport the {@link ViewPort viewport} that contains the processors to use.
     */
public void syncScreenProcessing(ViewPort sourceViewport) {
    if (rightViewport == null) {
        return;
    }
    if (environment != null) {
        if (environment.getApplication() != null) {
            // setup post processing filters
            if (rightPostProcessor == null) {
                rightPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager());
                leftPostProcessor = new FilterPostProcessor(environment.getApplication().getAssetManager());
            }
            // clear out all filters & processors, to start from scratch
            rightPostProcessor.removeAllFilters();
            leftPostProcessor.removeAllFilters();
            leftViewport.clearProcessors();
            rightViewport.clearProcessors();
            // if we have no processors to sync, don't add the FilterPostProcessor
            if (sourceViewport.getProcessors().isEmpty())
                return;
            // add post processors we just made, which are empty
            leftViewport.addProcessor(leftPostProcessor);
            rightViewport.addProcessor(rightPostProcessor);
            // add them to the left viewport processor & clone them to the right
            for (SceneProcessor sceneProcessor : sourceViewport.getProcessors()) {
                if (sceneProcessor instanceof FilterPostProcessor) {
                    for (Filter f : ((FilterPostProcessor) sceneProcessor).getFilterList()) {
                        if (f instanceof TranslucentBucketFilter) {
                            // just remove this filter, we will add it at the end manually
                            ((FilterPostProcessor) sceneProcessor).removeFilter(f);
                        } else {
                            leftPostProcessor.addFilter(f);
                            // clone to the right
                            Filter f2;
                            if (f instanceof FogFilter) {
                                f2 = FilterUtil.cloneFogFilter((FogFilter) f);
                            } else if (f instanceof CartoonSSAO) {
                                f2 = new CartoonSSAO((CartoonSSAO) f);
                            } else if (f instanceof SSAOFilter) {
                                f2 = FilterUtil.cloneSSAOFilter((SSAOFilter) f);
                            } else if (f instanceof DirectionalLightShadowFilter) {
                                f2 = FilterUtil.cloneDirectionalLightShadowFilter(environment.getApplication().getAssetManager(), (DirectionalLightShadowFilter) f);
                            } else {
                                // dof, bloom, lightscattering etc.
                                f2 = f;
                            }
                            rightPostProcessor.addFilter(f2);
                        }
                    }
                } else if (sceneProcessor instanceof VRDirectionalLightShadowRenderer) {
                    // shadow processing
                    // TODO: make right shadow processor use same left shadow maps for performance
                    VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor;
                    VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone();
                    dlsrRight.setLight(dlsr.getLight());
                    rightViewport.getProcessors().add(0, dlsrRight);
                    leftViewport.getProcessors().add(0, sceneProcessor);
                }
            }
            // make sure each has a translucent filter renderer
            leftPostProcessor.addFilter(new TranslucentBucketFilter());
            rightPostProcessor.addFilter(new TranslucentBucketFilter());
        } else {
            throw new IllegalStateException("This VR environment is not attached to any application.");
        }
    } else {
        throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
    }
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) TranslucentBucketFilter(com.jme3.post.filters.TranslucentBucketFilter) VRDirectionalLightShadowRenderer(com.jme3.shadow.VRDirectionalLightShadowRenderer) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter) Filter(com.jme3.post.Filter) SSAOFilter(com.jme3.post.ssao.SSAOFilter) FogFilter(com.jme3.post.filters.FogFilter) TranslucentBucketFilter(com.jme3.post.filters.TranslucentBucketFilter) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter) FogFilter(com.jme3.post.filters.FogFilter) SceneProcessor(com.jme3.post.SceneProcessor) CartoonSSAO(com.jme3.post.CartoonSSAO)

Example 44 with FilterPostProcessor

use of com.jme3.post.FilterPostProcessor in project chordatlas by twak.

the class Tweed method simpleInitApp.

public void simpleInitApp() {
    // TweedSettings.load( new File ( Tweed.DATA ) );
    point = new PointLight();
    point.setEnabled(true);
    point.setColor(ColorRGBA.White.mult(4));
    point.setRadius(50);
    rootNode.addLight(point);
    sun = new DirectionalLight();
    // sun.setDirection(new Vector3f(-0.0f, -1f, -0f).normalizeLocal());
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    sun.setColor(new ColorRGBA(1f, 0.95f, 0.99f, 1f));
    rootNode.addLight(sun);
    // enable multiple lights
    renderManager.setPreferredLightMode(LightMode.SinglePass);
    renderManager.setSinglePassLightBatchSize(16);
    ambient = new AmbientLight();
    rootNode.addLight(ambient);
    setAmbient(0);
    setDisplayFps(false);
    setDisplayStatView(false);
    clearBackground();
    buildBackground();
    getFlyByCamera().setDragToRotate(true);
    setTool(tools[0]);
    debug = new Node("dbg");
    rootNode.attachChild(debug);
    // String folder = ; // data-source
    // SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024);
    // shadows.setLight(sun);
    // shadows.setShadowIntensity(0.3f);
    // shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8);
    // viewPort.addProcessor(shadows);
    cam.setLocation(TweedSettings.settings.cameraLocation);
    cam.setRotation(TweedSettings.settings.cameraOrientation);
    setFov(0);
    setCameraSpeed(0);
    if (false) {
        // TweedSettings.settings.SSAO ) {
        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
        SSAOFilter filter = new SSAOFilter(0.50997847f, 1.440001f, 1.39999998f, 0);
        // fpp.addFilter( new ColorOverlayFilter( ColorRGBA.Magenta ));
        fpp.addFilter(filter);
        fpp.addFilter(new FXAAFilter());
        viewPort.addProcessor(fpp);
    }
    TweedSettings.loadDefault();
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_X, false));
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_X, true));
    inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
    inputManager.addListener(moveListener, MOUSE_MOVE);
    inputManager.addMapping(CLICK, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
    inputManager.addListener(analogListener, CLICK);
    inputManager.addMapping(SPEED_UP, new KeyTrigger(KeyInput.KEY_UP));
    inputManager.addMapping(SPEED_DOWN, new KeyTrigger(KeyInput.KEY_DOWN));
    inputManager.addMapping(AMBIENT_UP, new KeyTrigger(KeyInput.KEY_RIGHT));
    inputManager.addMapping(AMBIENT_DOWN, new KeyTrigger(KeyInput.KEY_LEFT));
    inputManager.addMapping(FOV_UP, new KeyTrigger(KeyInput.KEY_PGUP));
    inputManager.addMapping(FOV_DOWN, new KeyTrigger(KeyInput.KEY_PGDN));
    inputManager.addMapping(TOGGLE_ORTHO, new KeyTrigger(KeyInput.KEY_O));
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (name == SPEED_UP)
                setCameraSpeed(+1);
            else
                setCameraSpeed(-1);
        }
    }, SPEED_UP, SPEED_DOWN);
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (!isPressed)
                return;
            if (name == AMBIENT_UP)
                setAmbient(+1);
            else
                setAmbient(-1);
        }
    }, AMBIENT_UP, AMBIENT_DOWN);
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (!isPressed)
                return;
            if (name == FOV_UP)
                setFov(+1);
            else
                setFov(-1);
        }
    }, FOV_UP, FOV_DOWN);
    inputManager.addListener(new com.jme3.input.controls.ActionListener() {

        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if (isPressed) {
                TweedSettings.settings.ortho = !TweedSettings.settings.ortho;
                setCameraPerspective();
            }
        }
    }, TOGGLE_ORTHO);
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) FXAAFilter(com.jme3.post.filters.FXAAFilter) Node(com.jme3.scene.Node) MouseAxisTrigger(com.jme3.input.controls.MouseAxisTrigger) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) ColorRGBA(com.jme3.math.ColorRGBA) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLight(com.jme3.light.PointLight) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) AmbientLight(com.jme3.light.AmbientLight)

Aggregations

FilterPostProcessor (com.jme3.post.FilterPostProcessor)42 Vector3f (com.jme3.math.Vector3f)33 DirectionalLight (com.jme3.light.DirectionalLight)26 Quaternion (com.jme3.math.Quaternion)23 Geometry (com.jme3.scene.Geometry)18 Material (com.jme3.material.Material)17 Spatial (com.jme3.scene.Spatial)16 KeyTrigger (com.jme3.input.controls.KeyTrigger)14 Node (com.jme3.scene.Node)14 Box (com.jme3.scene.shape.Box)13 SSAOFilter (com.jme3.post.ssao.SSAOFilter)11 ColorRGBA (com.jme3.math.ColorRGBA)10 ActionListener (com.jme3.input.controls.ActionListener)9 AmbientLight (com.jme3.light.AmbientLight)9 BloomFilter (com.jme3.post.filters.BloomFilter)9 Sphere (com.jme3.scene.shape.Sphere)7 DirectionalLightShadowFilter (com.jme3.shadow.DirectionalLightShadowFilter)7 ChaseCamera (com.jme3.input.ChaseCamera)5 FXAAFilter (com.jme3.post.filters.FXAAFilter)4 DirectionalLightShadowRenderer (com.jme3.shadow.DirectionalLightShadowRenderer)4