|
@@ -31,13 +31,19 @@
|
|
*/
|
|
*/
|
|
package com.jme3.gde.core.sceneexplorer.nodes.actions;
|
|
package com.jme3.gde.core.sceneexplorer.nodes.actions;
|
|
|
|
|
|
|
|
+import com.jme3.bounding.BoundingSphere;
|
|
|
|
+import com.jme3.environment.EnvironmentCamera;
|
|
|
|
+import com.jme3.environment.LightProbeFactory;
|
|
|
|
+import com.jme3.environment.generation.JobProgressAdapter;
|
|
import com.jme3.gde.core.scene.SceneApplication;
|
|
import com.jme3.gde.core.scene.SceneApplication;
|
|
|
|
+import com.jme3.gde.core.scene.controller.SceneToolController;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
|
|
import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit;
|
|
import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit;
|
|
import com.jme3.gde.core.undoredo.SceneUndoRedoManager;
|
|
import com.jme3.gde.core.undoredo.SceneUndoRedoManager;
|
|
import com.jme3.light.AmbientLight;
|
|
import com.jme3.light.AmbientLight;
|
|
import com.jme3.light.DirectionalLight;
|
|
import com.jme3.light.DirectionalLight;
|
|
import com.jme3.light.Light;
|
|
import com.jme3.light.Light;
|
|
|
|
+import com.jme3.light.LightProbe;
|
|
import com.jme3.light.PointLight;
|
|
import com.jme3.light.PointLight;
|
|
import com.jme3.light.SpotLight;
|
|
import com.jme3.light.SpotLight;
|
|
import com.jme3.math.ColorRGBA;
|
|
import com.jme3.math.ColorRGBA;
|
|
@@ -79,6 +85,7 @@ public class NewLightPopup extends AbstractAction implements Presenter.Popup {
|
|
result.add(new JMenuItem(new AddDirectionalAction()));
|
|
result.add(new JMenuItem(new AddDirectionalAction()));
|
|
result.add(new JMenuItem(new AddPointAction()));
|
|
result.add(new JMenuItem(new AddPointAction()));
|
|
result.add(new JMenuItem(new AddSpotAction()));
|
|
result.add(new JMenuItem(new AddSpotAction()));
|
|
|
|
+ result.add(new JMenuItem(new AddProbeAction()));
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -147,7 +154,7 @@ public class NewLightPopup extends AbstractAction implements Presenter.Popup {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private class AddSpotAction extends AbstractAction {
|
|
|
|
|
|
+ private class AddSpotAction extends AbstractAction {
|
|
|
|
|
|
public AddSpotAction() {
|
|
public AddSpotAction() {
|
|
putValue(NAME, "Spot Light");
|
|
putValue(NAME, "Spot Light");
|
|
@@ -167,6 +174,44 @@ public class NewLightPopup extends AbstractAction implements Presenter.Popup {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private class AddProbeAction extends AbstractAction {
|
|
|
|
+
|
|
|
|
+ public AddProbeAction() {
|
|
|
|
+ putValue(NAME, "Light Probe");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
|
+ SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Void call() throws Exception {
|
|
|
|
+
|
|
|
|
+ EnvironmentCamera envCam = SceneApplication.getApplication().getStateManager().getState(EnvironmentCamera.class);
|
|
|
|
+ SceneToolController toolController = SceneApplication.getApplication().getStateManager().getState(SceneToolController.class);
|
|
|
|
+ if(toolController != null){
|
|
|
|
+ envCam.setPosition(toolController.getCursorLocation());
|
|
|
|
+ } else {
|
|
|
|
+ envCam.setPosition(new Vector3f(0, 0, 0));
|
|
|
|
+ }
|
|
|
|
+ LightProbe lightProbe = LightProbeFactory.makeProbe(envCam, node, new JobProgressAdapter<LightProbe>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void done(LightProbe t) {
|
|
|
|
+ System.err.println("Done computing env maps");
|
|
|
|
+ ((BoundingSphere)t.getBounds()).setRadius(200);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ node.addLight(lightProbe);
|
|
|
|
+ addLightUndo(node, lightProbe);
|
|
|
|
+ setModified();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
private void addLightUndo(final Spatial undoParent, final Light undoLight) {
|
|
private void addLightUndo(final Spatial undoParent, final Light undoLight) {
|
|
//add undo
|
|
//add undo
|