|
@@ -52,115 +52,92 @@ import org.openide.util.Exceptions;
|
|
|
import org.openide.util.Lookup;
|
|
|
|
|
|
/**
|
|
|
- * Example of a class that edits the scene, logic happens on the AWT side,
|
|
|
- * do.. methods do not use global variables.
|
|
|
+ * Example of a class that edits the scene, logic happens on the AWT side, do..
|
|
|
+ * methods do not use global variables.
|
|
|
+ *
|
|
|
* @author normenhansen
|
|
|
*/
|
|
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
|
-public class SceneEditorController implements PropertyChangeListener, NodeListener {
|
|
|
-
|
|
|
+public class SceneEditorController implements NodeListener {
|
|
|
+
|
|
|
private final JmeSpatial jmeRootNode;
|
|
|
- private JmeSpatial selectedSpat;
|
|
|
+ private Spatial selectedSpat;
|
|
|
+ private AbstractSceneExplorerNode selectedExplorerNode;
|
|
|
+
|
|
|
private DataObject currentFileObject;
|
|
|
// private boolean needSave = false;
|
|
|
private SceneComposerToolController toolController;
|
|
|
-
|
|
|
+
|
|
|
public SceneEditorController(JmeSpatial jmeRootNode, DataObject currentFileObject) {
|
|
|
this.jmeRootNode = jmeRootNode;
|
|
|
+ jmeRootNode.addNodeListener(this);
|
|
|
this.currentFileObject = currentFileObject;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void setToolController(SceneComposerToolController toolController) {
|
|
|
this.toolController = toolController;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public JmeSpatial getJmeRootNode() {
|
|
|
return jmeRootNode;
|
|
|
}
|
|
|
-
|
|
|
- public JmeSpatial getSelectedSpat() {
|
|
|
+
|
|
|
+ public Spatial getSelectedSpat() {
|
|
|
return selectedSpat;
|
|
|
}
|
|
|
-
|
|
|
- public void setSelectedSpat(JmeSpatial selectedSpat) {
|
|
|
- if (this.selectedSpat == selectedSpat) {
|
|
|
- return;
|
|
|
+
|
|
|
+ public void setSelectedExplorerNode(AbstractSceneExplorerNode node) {
|
|
|
+ if (selectedExplorerNode != null) {
|
|
|
+ selectedExplorerNode.removePropertyChangeListener(this);
|
|
|
+ selectedExplorerNode.removeNodeListener(this);
|
|
|
}
|
|
|
- if (this.selectedSpat != null) {
|
|
|
- this.selectedSpat.removePropertyChangeListener(this);
|
|
|
- this.selectedSpat.removeNodeListener(this);
|
|
|
+
|
|
|
+ selectedExplorerNode = node;
|
|
|
+
|
|
|
+ if (selectedExplorerNode != null) {
|
|
|
+ selectedExplorerNode.addPropertyChangeListener(this);
|
|
|
+ selectedExplorerNode.addNodeListener(this);
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSelectedSpat(Spatial selectedSpat) {
|
|
|
this.selectedSpat = selectedSpat;
|
|
|
- if (selectedSpat != null) {
|
|
|
- selectedSpat.addPropertyChangeListener(this);//WeakListeners.propertyChange(this, selectedSpat));
|
|
|
- selectedSpat.addNodeListener(this);//WeakListeners.propertyChange(this, selectedSpat));
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public FileObject getCurrentFileObject() {
|
|
|
return currentFileObject.getPrimaryFile();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public DataObject getCurrentDataObject() {
|
|
|
return currentFileObject;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void addSpatialUndo(final Node undoParent, final Spatial undoSpatial, final Light undoLight, final AbstractSceneExplorerNode parentNode) {
|
|
|
//add undo
|
|
|
if (undoParent != null && undoSpatial != null) {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneUndo() throws CannotUndoException {
|
|
|
//undo stuff here
|
|
|
undoSpatial.removeFromParent();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneRedo() throws CannotRedoException {
|
|
|
//redo stuff here
|
|
|
undoParent.attachChild(undoSpatial);
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public void awtRedo() {
|
|
|
- if (parentNode != null) {
|
|
|
- parentNode.refresh(true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void awtUndo() {
|
|
|
- if (parentNode != null) {
|
|
|
- parentNode.refresh(true);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- if (undoParent != null && undoLight != null) {
|
|
|
- Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void sceneUndo() throws CannotUndoException {
|
|
|
- //undo stuff here
|
|
|
- undoParent.removeLight(undoLight);
|
|
|
- toolController.removeLightMarker(undoLight);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void sceneRedo() throws CannotRedoException {
|
|
|
- //redo stuff here
|
|
|
- undoParent.addLight(undoLight);
|
|
|
- toolController.addLightMarker(undoLight);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void awtRedo() {
|
|
|
if (parentNode != null) {
|
|
|
parentNode.refresh(true);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void awtUndo() {
|
|
|
if (parentNode != null) {
|
|
@@ -170,21 +147,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void moveSelectedSpatial(final Vector3f point) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
if (node != null) {
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doMoveSpatial(node, point);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -194,7 +171,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doMoveSpatial(Spatial selected, Vector3f translation) {
|
|
|
Vector3f localTranslation = selected.getLocalTranslation();
|
|
|
Vector3f before = new Vector3f(localTranslation);
|
|
@@ -211,17 +188,17 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
selected.setLocalTranslation(localTranslation);
|
|
|
moveUndo(selected, before, after);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void moveUndo(final Spatial spatial, final Vector3f before, final Vector3f after) {
|
|
|
if (spatial != null && before != null) {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneUndo() throws CannotUndoException {
|
|
|
//undo stuff here
|
|
|
spatial.setLocalTranslation(before);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneRedo() throws CannotRedoException {
|
|
|
//redo stuff here
|
|
@@ -230,21 +207,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void nudgeSelectedSpatial(final Vector3f amount) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
if (node != null) {
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doNudgeSpatial(node, amount);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -254,24 +231,24 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doNudgeSpatial(Spatial selected, Vector3f translation) {
|
|
|
Vector3f before = new Vector3f(selected.getLocalTranslation());
|
|
|
selected.setLocalTranslation(before.add(translation));
|
|
|
Vector3f after = new Vector3f(selected.getLocalTranslation());
|
|
|
nudgeUndo(selected, before, after);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void nudgeUndo(final Spatial spatial, final Vector3f before, final Vector3f after) {
|
|
|
if (spatial != null && before != null) {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneUndo() throws CannotUndoException {
|
|
|
//undo stuff here
|
|
|
spatial.setLocalTranslation(before);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneRedo() throws CannotRedoException {
|
|
|
//redo stuff here
|
|
@@ -280,21 +257,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void rotateSelectedSpatial(final Quaternion amount) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
if (node != null) {
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doRotateSpatial(node, amount);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -304,24 +281,24 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doRotateSpatial(Spatial selected, Quaternion rotation) {
|
|
|
Quaternion before = new Quaternion(selected.getLocalRotation());
|
|
|
selected.rotate(rotation);
|
|
|
Quaternion after = new Quaternion(selected.getLocalRotation());
|
|
|
rotateUndo(selected, before, after);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void rotateUndo(final Spatial spatial, final Quaternion before, final Quaternion after) {
|
|
|
if (spatial != null && before != null) {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneUndo() throws CannotUndoException {
|
|
|
//undo stuff here
|
|
|
spatial.setLocalRotation(before);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneRedo() throws CannotRedoException {
|
|
|
//redo stuff here
|
|
@@ -330,21 +307,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void createTangentsForSelectedSpatial() {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
if (node != null) {
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doCreateTangents(node);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -354,7 +331,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doCreateTangents(Spatial selected) {
|
|
|
if (selected instanceof Geometry) {
|
|
|
Geometry geom = (Geometry) selected;
|
|
@@ -365,16 +342,16 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void createTrangentsUndo(final Mesh mesh) {
|
|
|
if (mesh != null) {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneUndo() throws CannotUndoException {
|
|
|
mesh.clearBuffer(Type.Tangent);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneRedo() throws CannotRedoException {
|
|
|
TangentBinormalGenerator.generate(mesh);
|
|
@@ -382,21 +359,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void createPhysicsMeshForSelectedSpatial() {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
setNeedsSave(true);
|
|
|
if (node != null) {
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doCreatePhysicsMesh(node);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -406,7 +383,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doCreatePhysicsMesh(Spatial selected) {
|
|
|
RigidBodyControl control = selected.getControl(RigidBodyControl.class);
|
|
|
if (control != null) {
|
|
@@ -422,21 +399,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
refreshSelected();
|
|
|
addControlUndo(parent, control, jmeRootNode);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void createDynamicPhysicsMeshForSelectedSpatial(final float weight) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
setNeedsSave(true);
|
|
|
if (node != null) {
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doCreateDynamicPhysicsMesh(node, weight);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -446,7 +423,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doCreateDynamicPhysicsMesh(Spatial selected, float weight) {
|
|
|
RigidBodyControl control = selected.getControl(RigidBodyControl.class);
|
|
|
if (control != null) {
|
|
@@ -462,21 +439,21 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
refreshSelected();
|
|
|
addControlUndo(parent, control, jmeRootNode);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void createCharacterControlForSelectedSpatial(final boolean auto, final float radius, final float height) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- final Spatial node = selectedSpat.getLookup().lookup(Spatial.class);
|
|
|
+ final Spatial node = selectedSpat;
|
|
|
setNeedsSave(true);
|
|
|
if (node != null) {
|
|
|
SceneApplication.getApplication().enqueue(new Callable() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doCreateCharacterControl(node, auto, radius, height);
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}).get();
|
|
|
}
|
|
@@ -486,7 +463,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doCreateCharacterControl(Spatial selected, boolean auto, float radius, float height) {
|
|
|
CharacterControl control = selected.getControl(CharacterControl.class);
|
|
|
if (control != null) {
|
|
@@ -507,30 +484,30 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
refreshSelected();
|
|
|
addControlUndo(parent, control, jmeRootNode);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void addControlUndo(final Node undoParent, final Control undoControl, final AbstractSceneExplorerNode parentNode) {
|
|
|
if (undoParent != null && undoControl != null) {
|
|
|
Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneUndo() throws CannotUndoException {
|
|
|
//undo stuff here
|
|
|
undoParent.removeControl(undoControl);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void sceneRedo() throws CannotRedoException {
|
|
|
//redo stuff here
|
|
|
undoParent.addControl(undoControl);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void awtRedo() {
|
|
|
if (parentNode != null) {
|
|
|
parentNode.refresh(true);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void awtUndo() {
|
|
|
if (parentNode != null) {
|
|
@@ -540,20 +517,20 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void addModel(final SpatialAssetDataObject file, final Vector3f location) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
- final Node selected = selectedSpat.getLookup().lookup(Node.class);
|
|
|
- ProjectAssetManager manager = file.getLookup().lookup(ProjectAssetManager.class);
|
|
|
- if (manager != null) {
|
|
|
- manager.clearCache();
|
|
|
- }
|
|
|
- if (selected != null) {
|
|
|
+ if (selectedSpat instanceof Node) {
|
|
|
+ final Node selected = (Node) selectedSpat;
|
|
|
+ ProjectAssetManager manager = file.getLookup().lookup(ProjectAssetManager.class);
|
|
|
+ if (manager != null) {
|
|
|
+ manager.clearCache();
|
|
|
+ }
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doAddModel(file, selected, location);
|
|
|
return null;
|
|
@@ -563,7 +540,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doAddModel(SpatialAssetDataObject file, Node selected, Vector3f location) {
|
|
|
ProgressHandle progressHandle = ProgressHandle.createHandle("Adding Model..");
|
|
|
progressHandle.start();
|
|
@@ -588,18 +565,18 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
DialogDisplayer.getDefault().notifyLater(msg);
|
|
|
}
|
|
|
progressHandle.finish();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void linkModel(final AssetManager manager, final String assetName, final Vector3f location) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
- final Node selected = selectedSpat.getLookup().lookup(Node.class);
|
|
|
- if (selected != null) {
|
|
|
+ if (selectedSpat instanceof Node) {
|
|
|
+ final Node selected = (Node) selectedSpat;
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doLinkModel(manager, assetName, selected, location);
|
|
|
return null;
|
|
@@ -609,7 +586,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doLinkModel(AssetManager manager, String assetName, Node selected, Vector3f location) {
|
|
|
ProgressHandle progressHandle = ProgressHandle.createHandle("Adding Model..");
|
|
|
progressHandle.start();
|
|
@@ -639,22 +616,22 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
DialogDisplayer.getDefault().notifyLater(msg);
|
|
|
}
|
|
|
progressHandle.finish();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void addModel(final Spatial file) {
|
|
|
addModel(file, null);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void addModel(final Spatial file, final Vector3f location) {
|
|
|
if (selectedSpat == null) {
|
|
|
return;
|
|
|
}
|
|
|
- final Node selected = selectedSpat.getLookup().lookup(Node.class);
|
|
|
- if (selected != null) {
|
|
|
+ if (selectedSpat instanceof Node) {
|
|
|
+ final Node selected = (Node) selectedSpat;
|
|
|
setNeedsSave(true);
|
|
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
|
|
-
|
|
|
+
|
|
|
public Object call() throws Exception {
|
|
|
doAddModel(file, selected, location);
|
|
|
return null;
|
|
@@ -664,7 +641,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
displayInfo("Please select a Node to attach to\nin the SceneExplorer.");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void doAddModel(Spatial file, Node selected, Vector3f location) {
|
|
|
ProgressHandle progressHandle = ProgressHandle.createHandle("Adding Model..");
|
|
|
progressHandle.start();
|
|
@@ -687,43 +664,48 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
DialogDisplayer.getDefault().notifyLater(msg);
|
|
|
}
|
|
|
progressHandle.finish();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void setNeedsSave(boolean state) {
|
|
|
currentFileObject.setModified(state);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean isNeedSave() {
|
|
|
return currentFileObject.isModified();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
// if ((evt.getOldValue() == null && !(evt.getNewValue() == null)) || ((evt.getOldValue() != null) && !evt.getOldValue().equals(evt.getNewValue()))) {
|
|
|
// setNeedsSave(true);
|
|
|
// }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public void childrenAdded(NodeMemberEvent ev) {
|
|
|
// setNeedsSave(true);
|
|
|
toolController.refreshNonSpatialMarkers();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public void childrenRemoved(NodeMemberEvent ev) {
|
|
|
// setNeedsSave(true);
|
|
|
toolController.refreshNonSpatialMarkers();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public void childrenReordered(NodeReorderEvent ev) {
|
|
|
// setNeedsSave(true);
|
|
|
toolController.refreshNonSpatialMarkers();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public void nodeDestroyed(NodeEvent ev) {
|
|
|
// setNeedsSave(true);
|
|
|
toolController.refreshNonSpatialMarkers();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void saveScene() {
|
|
|
try {
|
|
|
currentFileObject.getLookup().lookup(SaveCookie.class).save();
|
|
@@ -731,60 +713,19 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Exceptions.printStackTrace(ex);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void refreshSelected(final JmeSpatial spat) {
|
|
|
- java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
-
|
|
|
- public void run() {
|
|
|
- if (spat != null) {
|
|
|
- spat.refresh(false);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
private void refreshSelected() {
|
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
-
|
|
|
- public void run() {
|
|
|
- if (getSelectedSpat() != null) {
|
|
|
- getSelectedSpat().refresh(false);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void refreshSelectedParent() {
|
|
|
- java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
-
|
|
|
- public void run() {
|
|
|
- if (getSelectedSpat() != null) {
|
|
|
- ((JmeSpatial) getSelectedSpat().getParentNode()).refresh(false);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void refreshRoot() {
|
|
|
- java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
-
|
|
|
+
|
|
|
public void run() {
|
|
|
- if (getJmeRootNode() != null) {
|
|
|
- getJmeRootNode().refresh(true);
|
|
|
- }
|
|
|
+ jmeRootNode.refresh(false);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void cleanup() {
|
|
|
final Node node = jmeRootNode.getLookup().lookup(Node.class);
|
|
|
- if (selectedSpat != null) {
|
|
|
- selectedSpat.removePropertyChangeListener(this);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -795,7 +736,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen
|
|
|
Node root = jmeRootNode.getLookup().lookup(Node.class);
|
|
|
TerrainUtils.enableLodControl(camera, root);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void displayInfo(String info) {
|
|
|
Message msg = new NotifyDescriptor.Message(info);
|
|
|
DialogDisplayer.getDefault().notifyLater(msg);
|