Fixed wire frame processor toggle
This commit is contained in:
parent
e12cc0bf30
commit
6bdada9846
1 changed files with 14 additions and 0 deletions
|
|
@ -2,10 +2,12 @@ package se.cookery.gfx.input;
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.input.controls.ActionListener;
|
import com.jme3.input.controls.ActionListener;
|
||||||
|
import com.jme3.post.SceneProcessor;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
import se.cookery.gfx.util.WireFrameProcessor;
|
import se.cookery.gfx.util.WireFrameProcessor;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class WireFrameToggleAction implements ActionListener {
|
public class WireFrameToggleAction implements ActionListener {
|
||||||
|
|
@ -13,6 +15,7 @@ public class WireFrameToggleAction implements ActionListener {
|
||||||
|
|
||||||
private ViewPort viewPort;
|
private ViewPort viewPort;
|
||||||
private WireFrameProcessor processor;
|
private WireFrameProcessor processor;
|
||||||
|
private ArrayList<SceneProcessor> tmpProcessorList = new ArrayList<>();
|
||||||
|
|
||||||
public WireFrameToggleAction(AssetManager assetManager, ViewPort viewPort) {
|
public WireFrameToggleAction(AssetManager assetManager, ViewPort viewPort) {
|
||||||
this.viewPort = viewPort;
|
this.viewPort = viewPort;
|
||||||
|
|
@ -25,8 +28,19 @@ public class WireFrameToggleAction implements ActionListener {
|
||||||
if (viewPort.getProcessors().contains(processor)) {
|
if (viewPort.getProcessors().contains(processor)) {
|
||||||
logger.info("Disabling WireFrame processor.");
|
logger.info("Disabling WireFrame processor.");
|
||||||
viewPort.removeProcessor(processor);
|
viewPort.removeProcessor(processor);
|
||||||
|
|
||||||
|
for (SceneProcessor proc : tmpProcessorList) {
|
||||||
|
viewPort.addProcessor(proc);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info("Enabling WireFrame processor.");
|
logger.info("Enabling WireFrame processor.");
|
||||||
|
|
||||||
|
tmpProcessorList.clear();
|
||||||
|
for (SceneProcessor proc : viewPort.getProcessors()) {
|
||||||
|
tmpProcessorList.add(proc);
|
||||||
|
}
|
||||||
|
|
||||||
|
viewPort.clearProcessors();
|
||||||
viewPort.addProcessor(processor);
|
viewPort.addProcessor(processor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue