Search in sources :

Example 1 with CartoonEdgeFilter

use of com.jme3.post.filters.CartoonEdgeFilter in project jmonkeyengine by jMonkeyEngine.

the class TestMultiViewsFilters method simpleInitApp.

public void simpleInitApp() {
    // create the geometry and attach it
    Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
    teaGeom.scale(3);
    teaGeom.getMaterial().setColor("GlowColor", ColorRGBA.Green);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White);
    dl.setDirection(Vector3f.UNIT_XYZ.negate());
    rootNode.addLight(dl);
    rootNode.attachChild(teaGeom);
    // Setup first view      
    cam.setViewPort(.5f, 1f, 0f, 0.5f);
    cam.setLocation(new Vector3f(3.3212643f, 4.484704f, 4.2812433f));
    cam.setRotation(new Quaternion(-0.07680723f, 0.92299235f, -0.2564353f, -0.27645364f));
    // Setup second view
    Camera cam2 = cam.clone();
    cam2.setViewPort(0f, 0.5f, 0f, 0.5f);
    cam2.setLocation(new Vector3f(-0.10947256f, 1.5760219f, 4.81758f));
    cam2.setRotation(new Quaternion(0.0010108891f, 0.99857414f, -0.04928594f, 0.020481428f));
    final ViewPort view2 = renderManager.createMainView("Bottom Left", cam2);
    view2.setClearFlags(true, true, true);
    view2.attachScene(rootNode);
    // Setup third view
    Camera cam3 = cam.clone();
    cam3.setName("cam3");
    cam3.setViewPort(0f, .5f, .5f, 1f);
    cam3.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
    cam3.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));
    final ViewPort view3 = renderManager.createMainView("Top Left", cam3);
    view3.setClearFlags(true, true, true);
    view3.attachScene(rootNode);
    // Setup fourth view
    Camera cam4 = cam.clone();
    cam4.setName("cam4");
    cam4.setViewPort(.5f, 1f, .5f, 1f);
    cam4.setLocation(new Vector3f(4.775564f, 1.4548365f, 0.11491505f));
    cam4.setRotation(new Quaternion(0.02356979f, -0.74957186f, 0.026729556f, 0.66096294f));
    final ViewPort view4 = renderManager.createMainView("Top Right", cam4);
    view4.setClearFlags(true, true, true);
    view4.attachScene(rootNode);
    //        Camera cam5 = new Camera(200, 200);
    //        cam5.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f);
    //        cam5.setName("cam5");
    //        cam5.setViewPort(5.23f, 6.33f, 0.56f, 1.66f);
    //          this.setViewPortAreas(5.23f, 6.33f, 0.56f, 1.66f);
    //          this.setViewPortCamSize(200, 200);
    //          1046,1266,112,332
    Camera cam5 = cam.clone();
    cam5.setName("cam5");
    cam5.setViewPort(1046f / settings.getWidth(), 1266f / settings.getWidth(), 112f / settings.getHeight(), 332f / settings.getHeight());
    cam5.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
    cam5.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));
    final ViewPort view5 = renderManager.createMainView("center", cam5);
    view5.setClearFlags(true, true, true);
    view5.attachScene(rootNode);
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
    final FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    final FilterPostProcessor fpp2 = new FilterPostProcessor(assetManager);
    final FilterPostProcessor fpp3 = new FilterPostProcessor(assetManager);
    final FilterPostProcessor fpp4 = new FilterPostProcessor(assetManager);
    final FilterPostProcessor fpp5 = new FilterPostProcessor(assetManager);
    //  fpp.addFilter(new WaterFilter(rootNode, Vector3f.UNIT_Y.mult(-1)));
    fpp3.addFilter(new CartoonEdgeFilter());
    fpp2.addFilter(new CrossHatchFilter());
    final FogFilter ff = new FogFilter(ColorRGBA.Yellow, 0.7f, 2);
    fpp.addFilter(ff);
    final RadialBlurFilter rbf = new RadialBlurFilter(1, 10);
    //    rbf.setEnabled(false);
    fpp.addFilter(rbf);
    SSAOFilter f = new SSAOFilter(1.8899765f, 20.490374f, 0.4699998f, 0.1f);
    ;
    fpp4.addFilter(f);
    SSAOUI ui = new SSAOUI(inputManager, f);
    fpp5.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
    viewPort.addProcessor(fpp);
    view2.addProcessor(fpp2);
    view3.addProcessor(fpp3);
    view4.addProcessor(fpp4);
    view5.addProcessor(fpp5);
    inputManager.addListener(new ActionListener() {

        public void onAction(String name, boolean isPressed, float tpf) {
            if (name.equals("press") && isPressed) {
                if (filterEnabled) {
                    viewPort.removeProcessor(fpp);
                    view2.removeProcessor(fpp2);
                    view3.removeProcessor(fpp3);
                    view4.removeProcessor(fpp4);
                    view5.removeProcessor(fpp5);
                } else {
                    viewPort.addProcessor(fpp);
                    view2.addProcessor(fpp2);
                    view3.addProcessor(fpp3);
                    view4.addProcessor(fpp4);
                    view5.addProcessor(fpp5);
                }
                filterEnabled = !filterEnabled;
            }
            if (name.equals("filter") && isPressed) {
                ff.setEnabled(!ff.isEnabled());
                rbf.setEnabled(!rbf.isEnabled());
            }
        }
    }, "press", "filter");
    inputManager.addMapping("press", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("filter", new KeyTrigger(KeyInput.KEY_F));
}
Also used : SSAOFilter(com.jme3.post.ssao.SSAOFilter) Quaternion(com.jme3.math.Quaternion) KeyTrigger(com.jme3.input.controls.KeyTrigger) FilterPostProcessor(com.jme3.post.FilterPostProcessor) Geometry(com.jme3.scene.Geometry) ActionListener(com.jme3.input.controls.ActionListener) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) ViewPort(com.jme3.renderer.ViewPort) Camera(com.jme3.renderer.Camera)

Example 2 with CartoonEdgeFilter

use of com.jme3.post.filters.CartoonEdgeFilter in project jmonkeyengine by jMonkeyEngine.

the class TestTransparentCartoonEdge method simpleInitApp.

public void simpleInitApp() {
    renderManager.setAlphaToCoverage(true);
    cam.setLocation(new Vector3f(0.14914267f, 0.58147097f, 4.7686534f));
    cam.setRotation(new Quaternion(-0.0044764364f, 0.9767943f, 0.21314798f, 0.020512417f));
    //        cam.setLocation(new Vector3f(2.0606942f, 3.20342f, 6.7860126f));
    //        cam.setRotation(new Quaternion(-0.017481906f, 0.98241085f, -0.12393151f, -0.13857932f));
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(5));
    Geometry geom = new Geometry("floor", q);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    geom.setMaterial(mat);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(geom);
    // create the geometry and attach it
    Spatial teaGeom = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    teaGeom.setQueueBucket(Bucket.Transparent);
    teaGeom.setShadowMode(ShadowMode.Cast);
    makeToonish(teaGeom);
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(al);
    DirectionalLight dl1 = new DirectionalLight();
    dl1.setDirection(new Vector3f(1, -1, 1).normalizeLocal());
    dl1.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl1);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.965f, 0.949f, 0.772f, 1f).mult(0.7f));
    rootNode.addLight(dl);
    rootNode.attachChild(teaGeom);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    CartoonEdgeFilter toon = new CartoonEdgeFilter();
    toon.setEdgeWidth(0.5f);
    toon.setEdgeIntensity(1.0f);
    toon.setNormalThreshold(0.8f);
    fpp.addFilter(toon);
    viewPort.addProcessor(fpp);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) AmbientLight(com.jme3.light.AmbientLight) CartoonEdgeFilter(com.jme3.post.filters.CartoonEdgeFilter)

Example 3 with CartoonEdgeFilter

use of com.jme3.post.filters.CartoonEdgeFilter in project jmonkeyengine by jMonkeyEngine.

the class TestCartoonEdge method setupFilters.

public void setupFilters() {
    if (renderer.getCaps().contains(Caps.GLSL100)) {
        fpp = new FilterPostProcessor(assetManager);
        //fpp.setNumSamples(4);
        int numSamples = getContext().getSettings().getSamples();
        if (numSamples > 0) {
            fpp.setNumSamples(numSamples);
        }
        CartoonEdgeFilter toon = new CartoonEdgeFilter();
        toon.setEdgeColor(ColorRGBA.Yellow);
        fpp.addFilter(toon);
        viewPort.addProcessor(fpp);
    }
}
Also used : FilterPostProcessor(com.jme3.post.FilterPostProcessor) CullHint(com.jme3.scene.Spatial.CullHint) CartoonEdgeFilter(com.jme3.post.filters.CartoonEdgeFilter)

Aggregations

FilterPostProcessor (com.jme3.post.FilterPostProcessor)3 DirectionalLight (com.jme3.light.DirectionalLight)2 CartoonEdgeFilter (com.jme3.post.filters.CartoonEdgeFilter)2 Geometry (com.jme3.scene.Geometry)2 ActionListener (com.jme3.input.controls.ActionListener)1 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 AmbientLight (com.jme3.light.AmbientLight)1 Material (com.jme3.material.Material)1 Quaternion (com.jme3.math.Quaternion)1 Vector3f (com.jme3.math.Vector3f)1 SSAOFilter (com.jme3.post.ssao.SSAOFilter)1 Camera (com.jme3.renderer.Camera)1 ViewPort (com.jme3.renderer.ViewPort)1 Spatial (com.jme3.scene.Spatial)1 CullHint (com.jme3.scene.Spatial.CullHint)1 Quad (com.jme3.scene.shape.Quad)1