com.jme3.post.Filter Java Examples

The following examples show how to use com.jme3.post.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenderFilterExtension.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Register the new additional filter.
 *
 * @param filter the filter.
 */
@JmeThread
public void register(@NotNull Filter filter) {
    this.filters.add(filter);
    EditorUtil.getGlobalFilterPostProcessor()
            .addFilter(filter);
}
 
Example #2
Source File: NewBloomFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected Filter doCreateFilter(FilterPostProcessor parent, Object configuration) {
    if (configuration != null) {
        WizardDescriptor wiz = (WizardDescriptor) configuration;
        if (wiz.getProperty("mode").equals("Scene")) {
            return new BloomFilter(BloomFilter.GlowMode.Scene);
        } else {
            return new BloomFilter(BloomFilter.GlowMode.Objects);
        }
    }
    return null;
}
 
Example #3
Source File: FilterIndexSupport.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void reorder(final int[] perm) {

    SceneApplication.getApplication().enqueue(new Callable<Object>() {

        public Object call() throws Exception {
            List<Filter> filters = new ArrayList<Filter>();
            for (Iterator<Filter> it = fppNode.getFilterPostProcessor().getFilterIterator(); it.hasNext();) {
                Filter f = it.next();
                filters.add(f);
            }
            System.err.println("reordering");
            fppNode.getFilterPostProcessor().removeAllFilters();
            for (int i = 0; i < perm.length; i++) {
                fppNode.getFilterPostProcessor().addFilter(filters.get(perm[i]));
            }
            return null;
        }
    });
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            ((FilterChildren) fppNode.getChildren()).reorderNotify();
            ((FilterChildren) fppNode.getChildren()).doRefresh();
        }
    });

}
 
Example #4
Source File: NewFilterPopup.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addFilterUndo(final FilterPostProcessor fpp, final Filter filter) {
    //add undo
    if (fpp != null && filter != null) {
        Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {

            @Override
            public void sceneUndo() throws CannotUndoException {
                fpp.removeFilter(filter);
            }

            @Override
            public void sceneRedo() throws CannotRedoException {
                fpp.addFilter(filter);
            }

            @Override
            public void awtRedo() {
                filterNode.refresh();
            }

            @Override
            public void awtUndo() {
                filterNode.refresh();
            }
        });
    }
}
 
Example #5
Source File: EnableFiterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void actionPerformed(ActionEvent ev) {

        SceneApplication.getApplication().enqueue(new Callable<Void>() {

            public Void call() throws Exception {
                Filter filter=context.getFilter();
                filter.setEnabled(!filter.isEnabled());                        
                Logger.getLogger(EnableFiterAction.class.getName()).info( (filter.isEnabled()?"Enabled":"Disabled")+" "+filter.getName());
                context.propertyChange("Enabled", !filter.isEnabled(), filter.isEnabled());
              
                return null;
            }
        });
    }
 
Example #6
Source File: AbstractFilterNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected Sheet createSheet() {
    Sheet sheet = super.createSheet();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("Filter");
    set.setName("Filter");
    Filter obj = filter;
    if (obj == null) {
        return sheet;
    }
    createFields(Filter.class, set, obj);
    sheet.put(set);
    return sheet;

}
 
Example #7
Source File: AbstractFilterNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public AbstractFilterNode(Filter filter) {
    super(Children.LEAF);
    this.filter = filter;
    setName(filter.getName());
    icon = ImageUtilities.loadImage(ICON_ENABLED);
    setIconBaseWithExtension(ICON_ENABLED);

}
 
Example #8
Source File: FilterPostProcessorNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected Node[] createNodes(Object t) {
    Filter filter = (Filter) t;
    for (FilterNode di : Lookup.getDefault().lookupAll(FilterNode.class)) {
        if (di.getExplorerObjectClass().getName().equals(filter.getClass().getName())) {
            Node[] ret = di.createNodes(filter, dataObject, readOnly);
            if (ret != null) {
                return ret;
            }
        }
    }
    return new Node[]{};
}
 
Example #9
Source File: FilterPostProcessorNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void removeFilter(final Filter filter) {
    SceneApplication.getApplication().enqueue(new Callable<Object>() {

        public Object call() throws Exception {
            getFilterPostProcessor().removeFilter(filter);
            return null;
        }
    });
    setModified();
    refresh();
}
 
Example #10
Source File: FilterPostProcessorNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void addFilter(final Filter filter) {
    SceneApplication.getApplication().enqueue(new Callable<Object>() {

        public Object call() throws Exception {
            getFilterPostProcessor().addFilter(filter);
            return null;
        }
    });
    setModified();
    refresh();
}
 
Example #11
Source File: MaterialDebugAppState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Will reload the filter's materials whenever the trigger is fired.
 * @param trigger the trigger
 * @param filter the filter to reload
 */
public void registerBinding(Trigger trigger, final Filter filter) {
    FilterBinding binding = new FilterBinding(trigger, filter);
    bindings.add(binding);
    if (isInitialized()) {
        bind(binding);
    }
}
 
Example #12
Source File: DefaultTreeNodeFactory.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) {

    if (element instanceof LayersRoot) {
        return unsafeCast(new LayersRootTreeNode((LayersRoot) element, objectId));
    } else if (element instanceof TerrainGrid) {
        return unsafeCast(new TerrainGridTreeNode((TerrainGrid) element, objectId));
    } else if (element instanceof TerrainQuad) {
        return unsafeCast(new TerrainQuadTreeNode((TerrainQuad) element, objectId));
    } else if (element instanceof SceneNode) {
        return unsafeCast(new SceneNodeTreeNode((SceneNode) element, objectId));
    } else if (element instanceof SceneLayer) {
        return unsafeCast(new SceneLayerTreeNode((SceneLayer) element, objectId));
    } else if (element instanceof Mesh) {
        return unsafeCast(new MeshTreeNode((Mesh) element, objectId));
    } else if (element instanceof Geometry) {
        return unsafeCast(new GeometryTreeNode<>((Geometry) element, objectId));
    } else if (element instanceof AudioNode) {
        return unsafeCast(new AudioTreeNode((AudioNode) element, objectId));
    } else if (element instanceof AssetLinkNode) {
        return unsafeCast(new AssetLinkNodeTreeNode((AssetLinkNode) element, objectId));
    } else if (element instanceof Node) {
        return unsafeCast(new NodeTreeNode<>((Node) element, objectId));
    } else if (element instanceof Material) {
        return unsafeCast(new MaterialTreeNode((Material) element, objectId));
    } else if (element instanceof SceneFiltersNode) {
        return unsafeCast(new SceneFiltersTreeNode((SceneFiltersNode) element, objectId));
    } else if (element instanceof SceneAppStatesNode) {
        return unsafeCast(new SceneAppStatesTreeNode((SceneAppStatesNode) element, objectId));
    } else if (element instanceof Filter) {
        return unsafeCast(new SceneFilterTreeNode((Filter) element, objectId));
    } else if (element instanceof SceneAppState) {
        return unsafeCast(new SceneAppStateTreeNode((SceneAppState) element, objectId));
    }

    return null;
}
 
Example #13
Source File: FilterElementModelPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
public FilterElementModelPropertyControl(
        @Nullable Filter propertyValue,
        @NotNull String propertyName,
        @NotNull SceneChangeConsumer changeConsumer
) {
    super(Filter.class, propertyValue, propertyName, changeConsumer);
}
 
Example #14
Source File: RenderFilterExtension.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Refresh all filters.
 */
@JmeThread
public void refreshFilters() {
    refreshActions.forEach((filter, consumer) -> {
        var cast = ClassUtils.<Consumer<Filter>>unsafeCast(consumer);
        cast.accept(filter);
    });
}
 
Example #15
Source File: RenderFilterExtension.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Set the handler to handle refresh events.
 *
 * @param filter  the filter.
 * @param handler the handler.
 * @param <T>     the filter's type.
 */
@JmeThread
public <T extends Filter> void setOnRefresh(@NotNull T filter, @NotNull Consumer<T> handler) {

    if (!filters.contains(filter)) {
        throw new IllegalArgumentException("The filter " + filter + "isn't registered.");
    }

    refreshActions.put(filter, handler);
}
 
Example #16
Source File: NewPosterizationFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new PosterizationFilter();
}
 
Example #17
Source File: NewDepthOfFieldFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new DepthOfFieldFilter();
}
 
Example #18
Source File: NewCrossHatchFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new CrossHatchFilter();
}
 
Example #19
Source File: NewCartoonEdgeFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new CartoonEdgeFilter();
}
 
Example #20
Source File: NewLightScatteringFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new LightScatteringFilter();
}
 
Example #21
Source File: NewFXAAFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new FXAAFilter();
}
 
Example #22
Source File: NewSSAOFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new SSAOFilter();
}
 
Example #23
Source File: NewColorOverlayFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new ColorOverlayFilter();
}
 
Example #24
Source File: NewWaterFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new WaterFilter();
}
 
Example #25
Source File: AbstractNewFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Action makeAction(final FilterPostProcessorNode rootNode) {
        return new AbstractAction(name) {

            public void actionPerformed(ActionEvent e) {
                SceneApplication.getApplication().enqueue(new Callable<Void>() {

                    public Void call() throws Exception {
                        final Filter filter = doCreateFilter();
                        if (filter != null && rootNode != null) {
                            rootNode.addFilter(filter);
                            SceneUndoRedoManager undoRedo = Lookup.getDefault().lookup(SceneUndoRedoManager.class);
                            if(undoRedo==null) return null;
                            undoRedo.addEdit(this, new AbstractUndoableSceneEdit() {

                                @Override
                                public void sceneUndo() throws CannotUndoException {
                                    rootNode.removeFilter(filter);
                                }

                                @Override
                                public void sceneRedo() throws CannotRedoException {
                                    rootNode.addFilter(filter);
                                }

                                @Override
                                public void awtRedo() {
//                                    rootNode.refresh();
                                }

                                @Override
                                public void awtUndo() {
//                                    rootNode.refresh();
                                }
                            });
                        }
                        return null;
                    }
                });
            }
        };
    }
 
Example #26
Source File: NewFogFilterAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected Filter doCreateFilter() {
    return new FogFilter();
}
 
Example #27
Source File: AbstractNewFilterWizardAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected Action makeAction(final FilterPostProcessorNode rootNode) {
        return new AbstractAction(name) {

            public void actionPerformed(ActionEvent e) {
                final Object obj = showWizard(rootNode);
                SceneApplication.getApplication().enqueue(new Callable<Void>() {

                    public Void call() throws Exception {
                        final Filter filter = doCreateFilter(rootNode.getFilterPostProcessor(), obj);
                        if (filter != null) {
                            rootNode.addFilter(filter);
                            SceneUndoRedoManager undoRedo = Lookup.getDefault().lookup(SceneUndoRedoManager.class);
                            if(undoRedo==null) return null;
                            undoRedo.addEdit(this, new AbstractUndoableSceneEdit() {

                                @Override
                                public void sceneUndo() throws CannotUndoException {
                                    rootNode.removeFilter(filter);
                                }

                                @Override
                                public void sceneRedo() throws CannotRedoException {
                                    rootNode.addFilter(filter);
                                }

                                @Override
                                public void awtRedo() {
//                                    rootNode.refresh();
                                }

                                @Override
                                public void awtUndo() {
//                                    rootNode.refresh();
                                }
                            });
                        }
                        return null;                    }
                });
            }

        };
    }
 
Example #28
Source File: RenderFilterExtension.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
private RenderFilterExtension() {
    this.filters = ArrayFactory.newArray(Filter.class);
    this.refreshActions = DictionaryFactory.newObjectDictionary();
}
 
Example #29
Source File: FilterSceneSelectorDialog.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
public FilterSceneSelectorDialog(@NotNull final SceneNode sceneNode, @NotNull final Consumer<Filter> handler) {
    super(sceneNode, Filter.class, handler);
}
 
Example #30
Source File: AbstractFilterNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Filter getFilter() {
    return filter;
}