- changes in Scene opening (all callbacks are coming on the EDT now)
- optimize selection callbacks
- optimize/simplify threading
- recognize changes in classpath and recreate ClassPath for AssetManager based on that

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8621 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 1fa17fa99a
commit 10ce82f423
  1. 2
      sdk/jme3-assetpack-support/src/com/jme3/gde/assetpack/actions/PreviewAssetAction.java
  2. 24
      sdk/jme3-core/src/com/jme3/gde/core/assets/AssetDataObject.java
  3. 119
      sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java
  4. 6
      sdk/jme3-core/src/com/jme3/gde/core/assets/SpatialAssetDataObject.java
  5. 2
      sdk/jme3-core/src/com/jme3/gde/core/assets/actions/OpenModel.java
  6. 24
      sdk/jme3-core/src/com/jme3/gde/core/properties/preview/DDSPreview.java
  7. 276
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneApplication.java
  8. 6
      sdk/jme3-core/src/com/jme3/gde/core/scene/SceneListener.java
  9. 26
      sdk/jme3-core/src/com/jme3/gde/core/scene/ScenePreviewProcessor.java
  10. 78
      sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/SceneExplorerTopComponent.java
  11. 2
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.form
  12. 7
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.java
  13. 2
      sdk/jme3-ogrexml/src/com/jme3/gde/ogrexml/OgreSceneDataObject.java
  14. 6
      sdk/jme3-ogrexml/src/com/jme3/gde/ogrexml/OgreXMLDataObject.java
  15. 5
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/OpenSceneComposer.java
  16. 198
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.java
  17. 4
      sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/SelectTool.java
  18. 76
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java
  19. 2
      sdk/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.form
  20. 21
      sdk/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java
  21. 106
      sdk/jme3-welcome-screen/src/com/jme3/gde/welcome/WelcomeScreen.java

@ -52,7 +52,7 @@ public final class PreviewAssetAction implements Action {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
request.setWindowTitle("AssetPack - PreView Model"); request.setWindowTitle("AssetPack - PreView Model");
app.requestScene(request); app.openScene(request);
} }

@ -140,7 +140,7 @@ public class AssetDataObject extends MultiDataObject {
} }
@Override @Override
public void setModified(boolean modif) { public synchronized void setModified(boolean modif) {
super.setModified(modif); super.setModified(modif);
if (modif && saveCookie != null) { if (modif && saveCookie != null) {
getCookieSet().assign(SaveCookie.class, saveCookie); getCookieSet().assign(SaveCookie.class, saveCookie);
@ -158,13 +158,13 @@ public class AssetDataObject extends MultiDataObject {
return lookupContents; return lookupContents;
} }
public void setSaveCookie(SaveCookie cookie) { public synchronized void setSaveCookie(SaveCookie cookie) {
this.saveCookie = cookie; this.saveCookie = cookie;
getCookieSet().assign(SaveCookie.class, saveCookie); getCookieSet().assign(SaveCookie.class, saveCookie);
setModified(false); setModified(false);
} }
public Savable loadAsset() { public synchronized Savable loadAsset() {
if (isModified() && savable != null) { if (isModified() && savable != null) {
return savable; return savable;
} }
@ -191,7 +191,7 @@ public class AssetDataObject extends MultiDataObject {
return savable; return savable;
} }
public void saveAsset() throws IOException { public synchronized void saveAsset() throws IOException {
if (savable == null) { if (savable == null) {
Logger.getLogger(AssetDataObject.class.getName()).log(Level.WARNING, "Trying to save asset that has not been loaded before or does not support saving!"); Logger.getLogger(AssetDataObject.class.getName()).log(Level.WARNING, "Trying to save asset that has not been loaded before or does not support saving!");
return; return;
@ -227,7 +227,7 @@ public class AssetDataObject extends MultiDataObject {
setModified(false); setModified(false);
} }
public AssetKey<?> getAssetKey() { public synchronized AssetKey<?> getAssetKey() {
if (assetKey == null) { if (assetKey == null) {
ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class); ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
if (mgr == null) { if (mgr == null) {
@ -239,7 +239,7 @@ public class AssetDataObject extends MultiDataObject {
return assetKey; return assetKey;
} }
public void setAssetKeyData(AssetKey key) { public synchronized void setAssetKeyData(AssetKey key) {
try { try {
BeanUtils.copyProperties(getAssetKey(), key); BeanUtils.copyProperties(getAssetKey(), key);
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
@ -249,16 +249,16 @@ public class AssetDataObject extends MultiDataObject {
} }
} }
public List<FileObject> getAssetList() { public synchronized List<FileObject> getAssetList() {
return assetList; return new LinkedList<FileObject>(assetList);
} }
public List<AssetKey> getAssetKeyList() { public synchronized List<AssetKey> getAssetKeyList() {
return assetKeyList; return new LinkedList<AssetKey>(assetKeyList);
} }
public List<AssetKey> getFailedList() { public synchronized List<AssetKey> getFailedList() {
return failedList; return new LinkedList<AssetKey>(failedList);
} }
protected static class AssetListListener implements AssetEventListener { protected static class AssetListListener implements AssetEventListener {

@ -38,6 +38,7 @@ import com.jme3.asset.DesktopAssetManager;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@ -50,7 +51,11 @@ import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.ProjectManager;
import org.netbeans.api.project.SourceGroup; import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources; import org.netbeans.api.project.Sources;
import org.openide.filesystems.FileAttributeEvent;
import org.openide.filesystems.FileChangeListener;
import org.openide.filesystems.FileEvent;
import org.openide.filesystems.FileObject; import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileRenameEvent;
import org.openide.filesystems.FileStateInvalidException; import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.XMLFileSystem; import org.openide.filesystems.XMLFileSystem;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
@ -66,9 +71,11 @@ public class ProjectAssetManager extends DesktopAssetManager {
private Project project; private Project project;
private List<String> folderNames = new LinkedList<String>(); private List<String> folderNames = new LinkedList<String>();
private List<AssetEventListener> assetEventListeners = new LinkedList<AssetEventListener>(); private List<AssetEventListener> assetEventListeners = Collections.synchronizedList(new LinkedList<AssetEventListener>());
private List<ClassPathChangeListener> classPathListeners = Collections.synchronizedList(new LinkedList<ClassPathChangeListener>());
private URLClassLoader loader; private URLClassLoader loader;
private LinkedList<FileObject> classPathItems = new LinkedList<FileObject>(); private LinkedList<FileObject> jarItems = new LinkedList<FileObject>();
private LinkedList<ClassPathItem> classPathItems = new LinkedList<ClassPathItem>();
public ProjectAssetManager(Project prj, String folderName) { public ProjectAssetManager(Project prj, String folderName) {
super(true); super(true);
@ -106,15 +113,20 @@ public class ProjectAssetManager extends DesktopAssetManager {
this(null); this(null);
} }
public void updateClassLoader() { private synchronized void updateClassLoader() {
for (FileObject fileObject : classPathItems) { for (FileObject fileObject : jarItems) {
try { try {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Remove classpath locator:{0}", fileObject.getURL());
unregisterLocator(fileObject.getURL().toExternalForm(), unregisterLocator(fileObject.getURL().toExternalForm(),
com.jme3.asset.plugins.UrlLocator.class); com.jme3.asset.plugins.UrlLocator.class);
} catch (FileStateInvalidException ex) { } catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
} }
} }
jarItems.clear();
for (ClassPathItem fileObject : classPathItems) {
fileObject.object.removeRecursiveListener(fileObject.listener);
}
classPathItems.clear(); classPathItems.clear();
Sources sources = project.getLookup().lookup(Sources.class); Sources sources = project.getLookup().lookup(Sources.class);
if (sources != null) { if (sources != null) {
@ -129,10 +141,41 @@ public class ProjectAssetManager extends DesktopAssetManager {
try { try {
FileObject[] roots = path.getRoots(); FileObject[] roots = path.getRoots();
for (FileObject fileObject : roots) { for (FileObject fileObject : roots) {
FileChangeListener listener = new FileChangeListener() {
public void fileFolderCreated(FileEvent fe) {
// notifyClassPathListeners();
}
public void fileDataCreated(FileEvent fe) {
// notifyClassPathListeners();
}
public void fileChanged(FileEvent fe) {
System.out.println(fe);
if (!fe.isExpected()) {
notifyClassPathListeners();
}
}
public void fileDeleted(FileEvent fe) {
// notifyClassPathListeners();
}
public void fileRenamed(FileRenameEvent fre) {
// notifyClassPathListeners();
}
public void fileAttributeChanged(FileAttributeEvent fae) {
// notifyClassPathListeners();
}
};
fileObject.addRecursiveListener(listener);
classPathItems.add(new ClassPathItem(fileObject, listener));
urls.add(fileObject.getURL()); urls.add(fileObject.getURL());
if(fileObject.getURL().toExternalForm().startsWith("jar")){ if (fileObject.getURL().toExternalForm().startsWith("jar")) {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add classpath locator:{0}", fileObject.getURL()); Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Add classpath locator:{0}", fileObject.getURL());
classPathItems.add(fileObject); jarItems.add(fileObject);
registerLocator(fileObject.getURL().toExternalForm(), registerLocator(fileObject.getURL().toExternalForm(),
"com.jme3.asset.plugins.UrlLocator"); "com.jme3.asset.plugins.UrlLocator");
} }
@ -151,25 +194,31 @@ public class ProjectAssetManager extends DesktopAssetManager {
public void setAssetEventListener(AssetEventListener listener) { public void setAssetEventListener(AssetEventListener listener) {
throw new UnsupportedOperationException("Setting the asset event listener is not allowed for ProjectAssetManager, use addAssetEventListener instead"); throw new UnsupportedOperationException("Setting the asset event listener is not allowed for ProjectAssetManager, use addAssetEventListener instead");
} }
private void prepAssetEventListeners() { private void prepAssetEventListeners() {
super.setAssetEventListener(new AssetEventListener() { super.setAssetEventListener(new AssetEventListener() {
public void assetLoaded(AssetKey ak) { public void assetLoaded(AssetKey ak) {
for (AssetEventListener assetEventListener : assetEventListeners) { synchronized (assetEventListeners) {
assetEventListener.assetLoaded(ak); for (AssetEventListener assetEventListener : assetEventListeners) {
assetEventListener.assetLoaded(ak);
}
} }
} }
public void assetRequested(AssetKey ak) { public void assetRequested(AssetKey ak) {
for (AssetEventListener assetEventListener : assetEventListeners) { synchronized (assetEventListeners) {
assetEventListener.assetRequested(ak); for (AssetEventListener assetEventListener : assetEventListeners) {
assetEventListener.assetRequested(ak);
}
} }
} }
public void assetDependencyNotFound(AssetKey ak, AssetKey ak1) { public void assetDependencyNotFound(AssetKey ak, AssetKey ak1) {
for (AssetEventListener assetEventListener : assetEventListeners) { synchronized (assetEventListeners) {
assetEventListener.assetDependencyNotFound(ak, ak1); for (AssetEventListener assetEventListener : assetEventListeners) {
assetEventListener.assetDependencyNotFound(ak, ak1);
}
} }
} }
}); });
@ -336,10 +385,33 @@ public class ProjectAssetManager extends DesktopAssetManager {
assetEventListeners.remove(listener); assetEventListeners.remove(listener);
} }
public void addClassPathEventListener(ClassPathChangeListener listener) {
classPathListeners.add(listener);
}
public void removeClassPathEventListener(ClassPathChangeListener listener) {
classPathListeners.remove(listener);
}
private void notifyClassPathListeners() {
updateClassLoader();
final ProjectAssetManager pm = this;
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
synchronized (classPathListeners) {
for (ClassPathChangeListener classPathChangeListener : classPathListeners) {
classPathChangeListener.classPathChanged(pm);
}
}
}
});
}
/** /**
* For situations with no Project * For situations with no Project
*/ */
private class DummyProject implements Project { private static class DummyProject implements Project {
ProjectAssetManager pm; ProjectAssetManager pm;
FileObject folder; FileObject folder;
@ -365,4 +437,23 @@ public class ProjectAssetManager extends DesktopAssetManager {
return fileSystem.getRoot(); return fileSystem.getRoot();
} }
} }
private static class ClassPathItem {
FileObject object;
FileChangeListener listener;
public ClassPathItem() {
}
public ClassPathItem(FileObject object, FileChangeListener listener) {
this.object = object;
this.listener = listener;
}
}
public static interface ClassPathChangeListener {
public void classPathChanged(ProjectAssetManager manager);
}
} }

@ -58,7 +58,7 @@ public class SpatialAssetDataObject extends AssetDataObject {
} }
@Override @Override
public ModelKey getAssetKey() { public synchronized ModelKey getAssetKey() {
AssetKey superKey = super.getAssetKey(); AssetKey superKey = super.getAssetKey();
if (superKey instanceof ModelKey) { if (superKey instanceof ModelKey) {
return (ModelKey)superKey; return (ModelKey)superKey;
@ -73,7 +73,7 @@ public class SpatialAssetDataObject extends AssetDataObject {
} }
@Override @Override
public Spatial loadAsset() { public synchronized Spatial loadAsset() {
if (isModified() && savable != null) { if (isModified() && savable != null) {
return (Spatial) savable; return (Spatial) savable;
} }
@ -102,7 +102,7 @@ public class SpatialAssetDataObject extends AssetDataObject {
return null; return null;
} }
public void saveAsset() throws IOException { public synchronized void saveAsset() throws IOException {
super.saveAsset(); super.saveAsset();
ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class); ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
if (mgr == null) { if (mgr == null) {

@ -84,7 +84,7 @@ public final class OpenModel implements ActionListener {
SceneRequest request = new SceneRequest(app, jmeNode, manager); SceneRequest request = new SceneRequest(app, jmeNode, manager);
request.setDataObject(context); request.setDataObject(context);
request.setWindowTitle("OpenGL Window - View Model"); request.setWindowTitle("OpenGL Window - View Model");
app.requestScene(request); app.openScene(request);
} else { } else {
Confirmation msg = new NotifyDescriptor.Confirmation( Confirmation msg = new NotifyDescriptor.Confirmation(
"Error opening " + context.getPrimaryFile().getNameExt(), "Error opening " + context.getPrimaryFile().getNameExt(),

@ -120,27 +120,21 @@ public class DDSPreview implements SceneListener {
SceneApplication.getApplication().removeSceneListener(this); SceneApplication.getApplication().removeSceneListener(this);
} }
public void sceneRequested(SceneRequest request) { public void sceneOpened(SceneRequest request) {
} }
public boolean sceneClose(SceneRequest request) { public void sceneClosed(SceneRequest request) {
return true;
} }
public void previewRequested(PreviewRequest request) { public void previewCreated(PreviewRequest request) {
if (request.getRequester() == this) { if (request.getRequester() == this) {
final ImageIcon icon = new ImageIcon(request.getImage()); final ImageIcon icon = new ImageIcon(request.getImage());
java.awt.EventQueue.invokeLater(new Runnable() { if (picPreview instanceof JLabel) {
((JLabel) picPreview).setIcon(icon);
public void run() { }
if (picPreview instanceof JLabel) { if (picPreview instanceof JButton) {
((JLabel) picPreview).setIcon(icon); ((JButton) picPreview).setIcon(icon);
} }
if (picPreview instanceof JButton) {
((JButton) picPreview).setIcon(icon);
}
}
});
} }
} }
} }

@ -32,7 +32,6 @@ import com.jme3.font.BitmapText;
import com.jme3.gde.core.Installer; import com.jme3.gde.core.Installer;
import com.jme3.gde.core.assets.AssetData; import com.jme3.gde.core.assets.AssetData;
import com.jme3.gde.core.scene.controller.AbstractCameraController; import com.jme3.gde.core.scene.controller.AbstractCameraController;
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
import com.jme3.gde.core.scene.processors.WireProcessor; import com.jme3.gde.core.scene.processors.WireProcessor;
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent; import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
import com.jme3.gde.core.undoredo.SceneUndoRedoManager; import com.jme3.gde.core.undoredo.SceneUndoRedoManager;
@ -56,7 +55,6 @@ import com.jme3.system.awt.AwtPanelsContext;
import com.jme3.system.awt.PaintMode; import com.jme3.system.awt.PaintMode;
import java.awt.Component; import java.awt.Component;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
@ -69,13 +67,11 @@ import org.openide.NotifyDescriptor;
import org.openide.NotifyDescriptor.Confirmation; import org.openide.NotifyDescriptor.Confirmation;
import org.openide.NotifyDescriptor.Message; import org.openide.NotifyDescriptor.Message;
import org.openide.awt.StatusDisplayer; import org.openide.awt.StatusDisplayer;
import org.openide.loaders.DataObject;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.HelpCtx; import org.openide.util.HelpCtx;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.NbPreferences; import org.openide.util.NbPreferences;
import org.openide.util.Utilities;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
/** /**
@ -84,7 +80,7 @@ import org.openide.util.lookup.Lookups;
* @author normenhansen * @author normenhansen
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class SceneApplication extends Application implements LookupProvider, LookupListener { public class SceneApplication extends Application implements LookupProvider {
private PointLight camLight; private PointLight camLight;
private static SceneApplication application; private static SceneApplication application;
@ -110,7 +106,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
private SceneRequest currentSceneRequest; private SceneRequest currentSceneRequest;
private ConcurrentLinkedQueue<SceneListener> listeners = new ConcurrentLinkedQueue<SceneListener>(); private ConcurrentLinkedQueue<SceneListener> listeners = new ConcurrentLinkedQueue<SceneListener>();
private ScenePreviewProcessor previewProcessor; private ScenePreviewProcessor previewProcessor;
private Lookup.Result nodeSelectionResult;
private ApplicationLogHandler logHandler = new ApplicationLogHandler(); private ApplicationLogHandler logHandler = new ApplicationLogHandler();
private WireProcessor wireProcessor; private WireProcessor wireProcessor;
private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer.."); private ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening SceneViewer..");
@ -139,9 +134,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
setPauseOnLostFocus(false); setPauseOnLostFocus(false);
//add listener for project selection
nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(JmeSpatial.class);
nodeSelectionResult.addLookupListener(this);
if (useCanvas) { if (useCanvas) {
createCanvas(); createCanvas();
startCanvas(true); startCanvas(true);
@ -303,20 +295,6 @@ public class SceneApplication extends Application implements LookupProvider, Loo
return Lookups.fixed(getApplication()); return Lookups.fixed(getApplication());
} }
/**
* updates node selection
* @param ev
*/
public void resultChanged(LookupEvent ev) {
Collection collection = nodeSelectionResult.allInstances();
for (Iterator it = collection.iterator(); it.hasNext();) {
Object object = it.next();
if (object instanceof JmeSpatial) {
return;
}
}
}
//TODO: replace with Lookup functionality //TODO: replace with Lookup functionality
public void addSceneListener(SceneListener listener) { public void addSceneListener(SceneListener listener) {
listeners.add(listener); listeners.add(listener);
@ -326,28 +304,30 @@ public class SceneApplication extends Application implements LookupProvider, Loo
listeners.remove(listener); listeners.remove(listener);
} }
private void notifySceneListeners() { private void notifyOpen() {
for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) { for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
SceneListener sceneViewerListener = it.next(); SceneListener sceneViewerListener = it.next();
sceneViewerListener.sceneRequested(currentSceneRequest); sceneViewerListener.sceneOpened(currentSceneRequest);
} }
} }
private boolean notifySceneListeners(SceneRequest closed) { private void notifyClose(final SceneRequest closed) {
for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) { for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
SceneListener sceneViewerListener = it.next(); SceneListener sceneViewerListener = it.next();
if (!sceneViewerListener.sceneClose(closed)) { sceneViewerListener.sceneClosed(closed);
return false;
}
} }
return true;
} }
public void notifySceneListeners(PreviewRequest request) { public void notifyPreview(final PreviewRequest request) {
for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) { java.awt.EventQueue.invokeLater(new Runnable() {
SceneListener sceneViewerListener = it.next();
sceneViewerListener.previewRequested(request); public void run() {
} for (Iterator<SceneListener> it = listeners.iterator(); it.hasNext();) {
SceneListener sceneViewerListener = it.next();
sceneViewerListener.previewCreated(request);
}
}
});
} }
public void createPreview(final PreviewRequest request) { public void createPreview(final PreviewRequest request) {
@ -358,21 +338,11 @@ public class SceneApplication extends Application implements LookupProvider, Loo
* method to display the node tree of a plugin (threadsafe) * method to display the node tree of a plugin (threadsafe)
* @param tree * @param tree
*/ */
public void requestScene(final SceneRequest request) { public void openScene(final SceneRequest request) {
enqueue(new Callable() { closeScene(currentSceneRequest);
java.awt.EventQueue.invokeLater(new Runnable() {
public Object call() throws Exception { public void run() {
if (!closeCurrentScene()) {
return null;
}
if (request.getManager() != null) {
assetManager = request.getManager();
}
if (request.getRequester() instanceof SceneApplication) {
camController.enable();
} else {
camController.disable();
}
currentSceneRequest = request; currentSceneRequest = request;
if (request.getDataObject() != null) { if (request.getDataObject() != null) {
setCurrentFileNode(request.getDataObject().getNodeDelegate()); setCurrentFileNode(request.getDataObject().getNodeDelegate());
@ -380,48 +350,34 @@ public class SceneApplication extends Application implements LookupProvider, Loo
setCurrentFileNode(null); setCurrentFileNode(null);
} }
setHelpContext(request.getHelpCtx()); setHelpContext(request.getHelpCtx());
getCurrentSceneRequest().setDisplayed(true);
Spatial model = request.getRootNode();
if (model == null) {
StatusDisplayer.getDefault().setStatusText("could not load Spatial from request: " + getCurrentSceneRequest().getWindowTitle());
return null;
}
rootNode.attachChild(model);
if (request.getToolNode() != null) {
toolsNode.attachChild(request.getToolNode());
}
notifySceneListeners();
setWindowTitle(request.getWindowTitle()); setWindowTitle(request.getWindowTitle());
return null; notifyOpen();
} enqueue(new Callable() {
});
}
private void checkSave() { public Object call() throws Exception {
if ((currentSceneRequest != null) if (request.getManager() != null) {
&& currentSceneRequest.getDataObject().isModified()) { assetManager = request.getManager();
final SceneRequest req = currentSceneRequest;
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Confirmation mesg = new NotifyDescriptor.Confirmation("Scene has not been saved,\ndo you want to save it?",
"Not Saved",
NotifyDescriptor.YES_NO_OPTION);
DialogDisplayer.getDefault().notify(mesg);
if (mesg.getValue() == Confirmation.YES_OPTION) {
try {
req.getDataObject().getLookup().lookup(AssetData.class).saveAsset();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} }
} else if (mesg.getValue() == Confirmation.CANCEL_OPTION) { if (request.getRequester() instanceof SceneApplication) {
return; camController.enable();
} else if (mesg.getValue() == Confirmation.NO_OPTION) { } else {
req.getDataObject().setModified(false); camController.disable();
}
Spatial model = request.getRootNode();
if (model == null) {
StatusDisplayer.getDefault().setStatusText("could not load Spatial from request: " + getCurrentSceneRequest().getWindowTitle());
return null;
}
rootNode.attachChild(model);
if (request.getToolNode() != null) {
toolsNode.attachChild(request.getToolNode());
}
getCurrentSceneRequest().setDisplayed(true);
return null;
} }
} });
}); }
} });
} }
/** /**
@ -429,59 +385,70 @@ public class SceneApplication extends Application implements LookupProvider, Loo
* @param tree * @param tree
*/ */
public void closeScene(final SceneRequest request) { public void closeScene(final SceneRequest request) {
enqueue(new Callable() { if (request != null) {
java.awt.EventQueue.invokeLater(new Runnable() {
public Object call() throws Exception { public void run() {
if (request == currentSceneRequest) {
if (closeCurrentScene()) { if (request == currentSceneRequest) {
if (request.getRequester() instanceof SceneApplication) { checkSave();
camController.disable();
}
currentSceneRequest = null;
setCurrentFileNode(null); setCurrentFileNode(null);
setWindowTitle("OpenGL Window"); setWindowTitle("OpenGL Window");
setHelpContext(null);
SceneUndoRedoManager manager = Lookup.getDefault().lookup(SceneUndoRedoManager.class);
if (manager != null) {
manager.discardAllEdits();
}
final SceneRequest currentRequest = currentSceneRequest;
currentSceneRequest = null;
notifyClose(request);
enqueue(new Callable() {
public Object call() throws Exception {
if (request.getRequester() instanceof SceneApplication) {
camController.disable();
}
notifyClose(currentRequest);
if (physicsState != null) {
physicsState.getPhysicsSpace().removeAll(rootNode);
getStateManager().detach(physicsState);
physicsState = null;
}
currentRequest.setDisplayed(false);
toolsNode.detachAllChildren();
rootNode.detachAllChildren();
// resetCam();
lastError = "";
return null;
}
});
} }
}
return null;
}
});
}
private boolean closeCurrentScene() {
return closeCurrentScene(false);
}
private boolean closeCurrentScene(boolean force) {
if (currentSceneRequest != null) {
if (!notifySceneListeners(currentSceneRequest)) {
if (!force) {
return false;
} }
} });
checkSave();
if (physicsState != null) {
physicsState.getPhysicsSpace().removeAll(rootNode);
getStateManager().detach(physicsState);
physicsState = null;
}
currentSceneRequest.setDisplayed(false);
} }
toolsNode.detachAllChildren(); }
rootNode.detachAllChildren();
setHelpContext(null);
// resetCam();
currentSceneRequest = null;
lastError = "";
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { private void checkSave() {
SceneUndoRedoManager manager = Lookup.getDefault().lookup(SceneUndoRedoManager.class); if ((currentSceneRequest != null)
if (manager != null) { && currentSceneRequest.getDataObject().isModified()) {
manager.discardAllEdits(); final DataObject req = currentSceneRequest.getDataObject();
Confirmation mesg = new NotifyDescriptor.Confirmation("Scene has not been saved,\ndo you want to save it?",
"Not Saved",
NotifyDescriptor.YES_NO_OPTION);
DialogDisplayer.getDefault().notify(mesg);
if (mesg.getValue() == Confirmation.YES_OPTION) {
try {
req.getLookup().lookup(AssetData.class).saveAsset();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} }
} else if (mesg.getValue() == Confirmation.CANCEL_OPTION) {
return;
} else if (mesg.getValue() == Confirmation.NO_OPTION) {
req.setModified(false);
} }
}); }
return true;
} }
private void resetCam() { private void resetCam() {
@ -490,41 +457,26 @@ public class SceneApplication extends Application implements LookupProvider, Loo
} }
private void setWindowTitle(final String string) { private void setWindowTitle(final String string) {
java.awt.EventQueue.invokeLater(new Runnable() { SceneViewerTopComponent.findInstance().setDisplayName(string);
public void run() {
SceneViewerTopComponent.findInstance().setDisplayName(string);
}
});
} }
public void setCurrentFileNode(final org.openide.nodes.Node node) { private void setCurrentFileNode(final org.openide.nodes.Node node) {
java.awt.EventQueue.invokeLater(new Runnable() { if (node == null) {
SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{});
public void run() { SceneViewerTopComponent.findInstance().close();
if (node == null) { } else {
SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{}); SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{node});
SceneViewerTopComponent.findInstance().close(); SceneViewerTopComponent.findInstance().open();
} else { SceneViewerTopComponent.findInstance().requestVisible();
SceneViewerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{node}); }
SceneViewerTopComponent.findInstance().open();
SceneViewerTopComponent.findInstance().requestVisible();
}
}
});
} }
public void setHelpContext(final HelpCtx helpContext) { private void setHelpContext(final HelpCtx helpContext) {
java.awt.EventQueue.invokeLater(new Runnable() { if (helpContext == null) {
SceneViewerTopComponent.findInstance().setHelpContext(new HelpCtx("com.jme3.gde.core.sceneviewer"));
public void run() { } else {
if (helpContext == null) { SceneViewerTopComponent.findInstance().setHelpContext(helpContext);
SceneViewerTopComponent.findInstance().setHelpContext(new HelpCtx("com.jme3.gde.core.sceneviewer")); }
} else {
SceneViewerTopComponent.findInstance().setHelpContext(helpContext);
}
}
});
} }
public void enableCamLight(final boolean enabled) { public void enableCamLight(final boolean enabled) {

@ -37,10 +37,10 @@ package com.jme3.gde.core.scene;
*/ */
public interface SceneListener { public interface SceneListener {
public void sceneRequested(SceneRequest request); public void sceneOpened(SceneRequest request);
public boolean sceneClose(SceneRequest request); public void sceneClosed(SceneRequest request);
public void previewRequested(PreviewRequest request); public void previewCreated(PreviewRequest request);
} }

@ -71,18 +71,6 @@ public class ScenePreviewProcessor implements SceneProcessor {
public void addRequest(PreviewRequest request) { public void addRequest(PreviewRequest request) {
previewQueue.add(request); previewQueue.add(request);
boolean reInit = false;
if (request.getCameraRequest().getWidth() != width) {
reInit = true;
width = request.getCameraRequest().getWidth();
}
if (request.getCameraRequest().getHeight() != height) {
reInit = true;
height = request.getCameraRequest().getHeight();
}
if (reInit) {
setupPreviewView();
}
} }
private void update(float tpf) { private void update(float tpf) {
@ -148,6 +136,18 @@ public class ScenePreviewProcessor implements SceneProcessor {
public void preFrame(float f) { public void preFrame(float f) {
currentPreviewRequest = previewQueue.poll(); currentPreviewRequest = previewQueue.poll();
if (currentPreviewRequest != null) { if (currentPreviewRequest != null) {
boolean reInit = false;
if (currentPreviewRequest.getCameraRequest().getWidth() != width) {
reInit = true;
width = currentPreviewRequest.getCameraRequest().getWidth();
}
if (currentPreviewRequest.getCameraRequest().getHeight() != height) {
reInit = true;
height = currentPreviewRequest.getCameraRequest().getHeight();
}
if (reInit) {
setupPreviewView();
}
previewNode.attachChild(currentPreviewRequest.getSpatial()); previewNode.attachChild(currentPreviewRequest.getSpatial());
if (currentPreviewRequest.getCameraRequest().location != null) { if (currentPreviewRequest.getCameraRequest().location != null) {
offCamera.setLocation(currentPreviewRequest.getCameraRequest().location); offCamera.setLocation(currentPreviewRequest.getCameraRequest().location);
@ -197,7 +197,7 @@ public class ScenePreviewProcessor implements SceneProcessor {
currentPreviewRequest.setImage(image); currentPreviewRequest.setImage(image);
previewNode.detachAllChildren(); previewNode.detachAllChildren();
SceneApplication.getApplication().notifySceneListeners(currentPreviewRequest); SceneApplication.getApplication().notifyPreview(currentPreviewRequest);
currentPreviewRequest = null; currentPreviewRequest = null;
} }
} }

@ -39,15 +39,15 @@ import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
import com.jme3.gde.core.util.TerrainUtils; import com.jme3.gde.core.util.TerrainUtils;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import java.beans.PropertyVetoException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.openide.util.Lookup.Result; import org.openide.util.Exceptions;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
@ -64,9 +64,6 @@ import org.openide.explorer.view.BeanTreeView;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.HelpCtx; import org.openide.util.HelpCtx;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.Utilities;
import org.openide.util.actions.SystemAction; import org.openide.util.actions.SystemAction;
/** /**
@ -74,14 +71,14 @@ import org.openide.util.actions.SystemAction;
*/ */
@ConvertAsProperties(dtd = "-//com.jme3.gde.core.sceneexplorer//SceneExplorer//EN", @ConvertAsProperties(dtd = "-//com.jme3.gde.core.sceneexplorer//SceneExplorer//EN",
autostore = false) autostore = false)
public final class SceneExplorerTopComponent extends TopComponent implements ExplorerManager.Provider, SceneListener, LookupListener { public final class SceneExplorerTopComponent extends TopComponent implements ExplorerManager.Provider, SceneListener/*, LookupListener */ {
private static SceneExplorerTopComponent instance; private static SceneExplorerTopComponent instance;
/** path to the icon used by the component and its open action */ /** path to the icon used by the component and its open action */
static final String ICON_PATH = "com/jme3/gde/core/sceneexplorer/jme-logo.png"; static final String ICON_PATH = "com/jme3/gde/core/sceneexplorer/jme-logo.png";
private static final String PREFERRED_ID = "SceneExplorerTopComponent"; private static final String PREFERRED_ID = "SceneExplorerTopComponent";
private SceneRequest request; private SceneRequest request;
private final Result<AbstractSceneExplorerNode> nodeSelectionResult; // private final Result<AbstractSceneExplorerNode> nodeSelectionResult;
private AbstractSceneExplorerNode selectedSpatial; private AbstractSceneExplorerNode selectedSpatial;
private AbstractSceneExplorerNode lastSelected; private AbstractSceneExplorerNode lastSelected;
private Map<String, MaterialChangeProvider> materialChangeProviders = new HashMap<String, MaterialChangeProvider>(); private Map<String, MaterialChangeProvider> materialChangeProviders = new HashMap<String, MaterialChangeProvider>();
@ -94,8 +91,8 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
setToolTipText(NbBundle.getMessage(SceneExplorerTopComponent.class, "HINT_SceneExplorerTopComponent")); setToolTipText(NbBundle.getMessage(SceneExplorerTopComponent.class, "HINT_SceneExplorerTopComponent"));
setIcon(ImageUtilities.loadImage(ICON_PATH, true)); setIcon(ImageUtilities.loadImage(ICON_PATH, true));
associateLookup(ExplorerUtils.createLookup(explorerManager, getActionMap())); associateLookup(ExplorerUtils.createLookup(explorerManager, getActionMap()));
nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(AbstractSceneExplorerNode.class); // nodeSelectionResult = Utilities.actionsGlobalContext().lookupResult(AbstractSceneExplorerNode.class);
nodeSelectionResult.addLookupListener(this); // nodeSelectionResult.addLookupListener(this);
} }
private void initActions() { private void initActions() {
@ -253,20 +250,35 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
return explorerManager; return explorerManager;
} }
public void resultChanged(LookupEvent ev) { public void setSelectedNode(AbstractSceneExplorerNode node) {
Collection collection = nodeSelectionResult.allInstances(); selectedSpatial = node;
for (Iterator it = collection.iterator(); it.hasNext();) { if (node != null) {
Object object = it.next(); lastSelected = node;
if (object instanceof AbstractSceneExplorerNode) { }
selectedSpatial = (AbstractSceneExplorerNode) object; try {
lastSelected = (AbstractSceneExplorerNode) object; if (node != null) {
return; explorerManager.setSelectedNodes(new Node[]{node});
// setActivatedNodes(new Node[]{node});
} else {
explorerManager.setSelectedNodes(new Node[]{});
// setActivatedNodes(new Node[]{});
} }
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
} }
selectedSpatial = null;
} }
public void sceneRequested(SceneRequest request) { // public void resultChanged(LookupEvent ev) {
// Collection collection = nodeSelectionResult.allInstances();
// for (Iterator it = collection.iterator(); it.hasNext();) {
// Object object = it.next();
// if (object instanceof AbstractSceneExplorerNode) {
// return;
// }
// }
// selectedSpatial = null;
// }
public void sceneOpened(SceneRequest request) {
this.request = request; this.request = request;
final JmeNode node = request.getJmeNode(); final JmeNode node = request.getJmeNode();
for (Iterator it = materialChangeProviders.values().iterator(); it.hasNext();) { for (Iterator it = materialChangeProviders.values().iterator(); it.hasNext();) {
@ -274,25 +286,25 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
provider.clearMaterialChangeListeners(); provider.clearMaterialChangeListeners();
} }
if (node != null) { if (node != null) {
java.awt.EventQueue.invokeLater(new Runnable() { explorerManager.setRootContext(node);
explorerManager.getRootContext().setDisplayName(node.getName());
public void run() { setActivatedNodes(new Node[]{node});
explorerManager.setRootContext(node); requestVisible();
explorerManager.getRootContext().setDisplayName(node.getName()); try {
requestVisible(); explorerManager.setSelectedNodes(new Node[]{node});
} } catch (PropertyVetoException ex) {
}); Exceptions.printStackTrace(ex);
}
} }
setTerrainLodCamera(node); setTerrainLodCamera(node);
} }
public boolean sceneClose(SceneRequest request) { public void sceneClosed(SceneRequest request) {
this.request = null; this.request = null;
explorerManager.setRootContext(Node.EMPTY); explorerManager.setRootContext(Node.EMPTY);
return true;
} }
public void previewRequested(PreviewRequest request) { public void previewCreated(PreviewRequest request) {
} }
/** /**
@ -321,7 +333,7 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
public void addMaterialChangeListener(MaterialChangeListener listener) { public void addMaterialChangeListener(MaterialChangeListener listener) {
if (listener.getKey() != null) { if (listener.getKey() != null) {
Logger.getLogger(SceneExplorerTopComponent.class.getName()).log(Level.INFO, "New material listener for : {0}", listener.getKey()); Logger.getLogger(SceneExplorerTopComponent.class.getName()).log(Level.INFO, "New material listener for : {0}", listener.getKey());
List<MaterialChangeListener> listeners = materialChangeListeners.get(listener.getKey()); List<MaterialChangeListener> listeners = materialChangeListeners.get(listener.getKey());
if (listeners == null) { if (listeners == null) {
listeners = new ArrayList<MaterialChangeListener>(); listeners = new ArrayList<MaterialChangeListener>();
@ -366,7 +378,7 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
if (newKey != null) { if (newKey != null) {
// assert newKey.equals(listener.getKey()); // assert newKey.equals(listener.getKey());
List<MaterialChangeListener> listeners = materialChangeListeners.get(newKey); List<MaterialChangeListener> listeners = materialChangeListeners.get(newKey);
if (listeners == null) { if (listeners == null) {
listeners = new ArrayList<MaterialChangeListener>(); listeners = new ArrayList<MaterialChangeListener>();
materialChangeListeners.put(newKey, listeners); materialChangeListeners.put(newKey, listeners);
@ -379,7 +391,7 @@ public final class SceneExplorerTopComponent extends TopComponent implements Exp
} }
} }
} }
/** /**
* Terrain has a LOD control that requires the camera to function. * Terrain has a LOD control that requires the camera to function.
*/ */

@ -1,6 +1,6 @@
<?xml version="1.1" encoding="UTF-8" ?> <?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents> <NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="toggleButtonGroup"> <Component class="javax.swing.ButtonGroup" name="toggleButtonGroup">
</Component> </Component>

@ -103,18 +103,17 @@ public class MaterialPreviewWidget extends javax.swing.JPanel implements SceneLi
previewLabel.setIcon(null); previewLabel.setIcon(null);
} }
public void sceneRequested(SceneRequest request) { public void sceneOpened(SceneRequest request) {
} }
public boolean sceneClose(SceneRequest request) { public void sceneClosed(SceneRequest request) {
return true;
} }
public void cleanUp(){ public void cleanUp(){
SceneApplication.getApplication().removeSceneListener(this); SceneApplication.getApplication().removeSceneListener(this);
} }
public void previewRequested(PreviewRequest request) { public void previewCreated(PreviewRequest request) {
if (request.getRequester() == this) { if (request.getRequester() == this) {
final ImageIcon icon = new ImageIcon(request.getImage()); final ImageIcon icon = new ImageIcon(request.getImage());
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {

@ -51,7 +51,7 @@ public class OgreSceneDataObject extends SpatialAssetDataObject {
} }
@Override @Override
public Spatial loadAsset() { public synchronized Spatial loadAsset() {
if (isModified() && savable != null) { if (isModified() && savable != null) {
return (Spatial) savable; return (Spatial) savable;
} }

@ -62,7 +62,7 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
} }
@Override @Override
public ModelKey getAssetKey() { public synchronized ModelKey getAssetKey() {
if(super.getAssetKey() instanceof OgreMeshKey){ if(super.getAssetKey() instanceof OgreMeshKey){
return (OgreMeshKey)assetKey; return (OgreMeshKey)assetKey;
} }
@ -71,7 +71,7 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
} }
@Override @Override
public Spatial loadAsset() { public synchronized Spatial loadAsset() {
if (isModified() && savable != null) { if (isModified() && savable != null) {
return (Spatial) savable; return (Spatial) savable;
} }
@ -125,7 +125,7 @@ public class OgreXMLDataObject extends SpatialAssetDataObject {
return null; return null;
} }
public void saveAsset() throws IOException { public synchronized void saveAsset() throws IOException {
ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class); ProjectAssetManager mgr = getLookup().lookup(ProjectAssetManager.class);
if (mgr == null) { if (mgr == null) {
return; return;

@ -34,15 +34,12 @@ public final class OpenSceneComposer implements ActionListener {
ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in SceneComposer"); ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in SceneComposer");
progressHandle.start(); progressHandle.start();
try { try {
manager.clearCache();
final Spatial asset = context.loadAsset(); final Spatial asset = context.loadAsset();
if (asset != null) { if (asset != null) {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
manager.updateClassLoader();
manager.clearCache();
SceneComposerTopComponent composer = SceneComposerTopComponent.findInstance(); SceneComposerTopComponent composer = SceneComposerTopComponent.findInstance();
composer.openScene(asset, context, manager); composer.openScene(asset, context, manager);
} }

@ -13,6 +13,7 @@ import com.jme3.gde.core.scene.PreviewRequest;
import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.core.scene.SceneListener; import com.jme3.gde.core.scene.SceneListener;
import com.jme3.gde.core.scene.SceneRequest; import com.jme3.gde.core.scene.SceneRequest;
import com.jme3.gde.core.sceneexplorer.SceneExplorerTopComponent;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial; import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility; import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility;
@ -28,8 +29,8 @@ import java.util.concurrent.Callable;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import org.openide.util.Lookup.Result; import org.netbeans.api.progress.ProgressHandle;
import org.openide.util.LookupEvent; import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
@ -45,6 +46,8 @@ import org.openide.awt.UndoRedo;
import org.openide.filesystems.FileObject; import org.openide.filesystems.FileObject;
import org.openide.util.HelpCtx; import org.openide.util.HelpCtx;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.Lookup.Result;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener; import org.openide.util.LookupListener;
import org.openide.util.Utilities; import org.openide.util.Utilities;
@ -64,9 +67,9 @@ public final class SceneComposerTopComponent extends TopComponent implements Sce
ComposerCameraController camController; ComposerCameraController camController;
SceneComposerToolController toolController; SceneComposerToolController toolController;
SceneEditorController editorController; SceneEditorController editorController;
// private SaveCookie saveCookie = new SaveCookieImpl();
private SceneRequest currentRequest; private SceneRequest currentRequest;
private HelpCtx ctx = new HelpCtx("sdk.scene_composer"); private HelpCtx ctx = new HelpCtx("sdk.scene_composer");
// private ProjectAssetManager.ClassPathChangeListener listener;
public SceneComposerTopComponent() { public SceneComposerTopComponent() {
initComponents(); initComponents();
@ -555,7 +558,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
SceneApplication.getApplication().setPhysicsEnabled(false); SceneApplication.getApplication().setPhysicsEnabled(false);
}//GEN-LAST:event_jButton3ActionPerformed }//GEN-LAST:event_jButton3ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton camToCursorSelectionButton; private javax.swing.JButton camToCursorSelectionButton;
private javax.swing.JButton createPhysicsMeshButton; private javax.swing.JButton createPhysicsMeshButton;
@ -693,7 +695,7 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
protected void componentActivated() { protected void componentActivated() {
SceneViewerTopComponent.findInstance().requestVisible(); SceneViewerTopComponent.findInstance().requestVisible();
} }
void writeProperties(java.util.Properties p) { void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at // better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles // http://wiki.apidesign.org/wiki/PropertyFiles
@ -724,7 +726,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
public void run() { public void run() {
if (text != null) { if (text != null) {
//XXX: wtf? why do i have to repaint?
((TitledBorder) jPanel4.getBorder()).setTitle("Utilities - " + text); ((TitledBorder) jPanel4.getBorder()).setTitle("Utilities - " + text);
} else { } else {
((TitledBorder) jPanel4.getBorder()).setTitle("Utilities - no spatial selected"); ((TitledBorder) jPanel4.getBorder()).setTitle("Utilities - no spatial selected");
@ -738,49 +739,43 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
*/ */
private void setSceneInfo(final JmeNode jmeNode, final FileObject file, final boolean active) { private void setSceneInfo(final JmeNode jmeNode, final FileObject file, final boolean active) {
final SceneComposerTopComponent inst = this; final SceneComposerTopComponent inst = this;
java.awt.EventQueue.invokeLater(new Runnable() { if (jmeNode != null) {
((TitledBorder) sceneInfoPanel.getBorder()).setTitle(jmeNode.getName());
public void run() { selectSpatial(jmeNode);
if (jmeNode != null) { } else {
((TitledBorder) sceneInfoPanel.getBorder()).setTitle(jmeNode.getName()); ((TitledBorder) sceneInfoPanel.getBorder()).setTitle("");
selectSpatial(jmeNode); }
} else { //XXX: wtf? why do i have to repaint?
((TitledBorder) sceneInfoPanel.getBorder()).setTitle(""); sceneInfoPanel.repaint();
}
//XXX: wtf? why do i have to repaint? if (!active) {
sceneInfoPanel.repaint(); result.removeLookupListener(inst);
showSelectionToggleButton.setSelected(true);
if (!active) { showGridToggleButton.setSelected(false);
result.removeLookupListener(inst); sceneInfoLabel1.setText("");
showSelectionToggleButton.setSelected(true); sceneInfoLabel2.setText("");
showGridToggleButton.setSelected(false); sceneInfoLabel1.setToolTipText("");
sceneInfoLabel1.setText(""); sceneInfoLabel2.setToolTipText("");
sceneInfoLabel2.setText(""); close();
sceneInfoLabel1.setToolTipText(""); } else {
sceneInfoLabel2.setToolTipText(""); showSelectionToggleButton.setSelected(true);
close(); showGridToggleButton.setSelected(false);
} else { //TODO: threading
showSelectionToggleButton.setSelected(true); if (file != null) {
showGridToggleButton.setSelected(false); sceneInfoLabel1.setText("Name: " + file.getNameExt());
//TODO: threading sceneInfoLabel2.setText("Size: " + file.getSize() / 1024 + " kB");
if (file != null) { sceneInfoLabel1.setToolTipText("Name: " + file.getNameExt());
sceneInfoLabel1.setText("Name: " + file.getNameExt()); sceneInfoLabel2.setToolTipText("Size: " + file.getSize() / 1024 + " kB");
sceneInfoLabel2.setText("Size: " + file.getSize() / 1024 + " kB");
sceneInfoLabel1.setToolTipText("Name: " + file.getNameExt());
sceneInfoLabel2.setToolTipText("Size: " + file.getSize() / 1024 + " kB");
}
open();
requestActive();
}
} }
}); open();
requestActive();
}
} }
public void openScene(Spatial spat, AssetDataObject file, ProjectAssetManager manager) { public void openScene(Spatial spat, AssetDataObject file, ProjectAssetManager manager) {
cleanupControllers(); cleanupControllers();
SceneApplication.getApplication().addSceneListener(this); SceneApplication.getApplication().addSceneListener(this);
result.addLookupListener(this); result.addLookupListener(this);
//TODO: handle request change
Node node; Node node;
if (spat instanceof Node) { if (spat instanceof Node) {
node = (Node) spat; node = (Node) spat;
@ -792,7 +787,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
SceneRequest request = new SceneRequest(this, jmeNode, manager); SceneRequest request = new SceneRequest(this, jmeNode, manager);
request.setDataObject(file); request.setDataObject(file);
request.setHelpCtx(ctx); request.setHelpCtx(ctx);
// file.setSaveCookie(saveCookie);
if (editorController != null) { if (editorController != null) {
editorController.cleanup(); editorController.cleanup();
} }
@ -800,7 +794,7 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
this.currentRequest = request; this.currentRequest = request;
request.setWindowTitle("SceneComposer - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath())); request.setWindowTitle("SceneComposer - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath()));
request.setToolNode(new Node("SceneComposerToolNode")); request.setToolNode(new Node("SceneComposerToolNode"));
SceneApplication.getApplication().requestScene(request); SceneApplication.getApplication().openScene(request);
} }
public void addModel(Spatial model) { public void addModel(Spatial model) {
@ -856,7 +850,6 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
if (editorController != null) { if (editorController != null) {
editorController.setSelectedSpat(spatial); editorController.setSelectedSpat(spatial);
} }
setActivatedNodes(new org.openide.nodes.Node[]{});
return; return;
} else { } else {
if (toolController != null) { if (toolController != null) {
@ -874,39 +867,9 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
} else { } else {
setSelectedObjectText(null); setSelectedObjectText(null);
} }
SceneApplication.getApplication().setCurrentFileNode(spatial); SceneExplorerTopComponent.findInstance().setSelectedNode(spatial);
setActivatedNodes(new org.openide.nodes.Node[]{spatial});
}
private boolean checkSaved() {
if (editorController != null && editorController.isNeedSave()) {
Confirmation msg = new NotifyDescriptor.Confirmation(
"Your Scene is not saved, do you want to save?",
NotifyDescriptor.YES_NO_OPTION,
NotifyDescriptor.WARNING_MESSAGE);
Object result = DialogDisplayer.getDefault().notify(msg);
if (NotifyDescriptor.CANCEL_OPTION.equals(result)) {
return false;
} else if (NotifyDescriptor.YES_OPTION.equals(result)) {
editorController.saveScene();
return true;
} else if (NotifyDescriptor.NO_OPTION.equals(result)) {
return true;
}
}
return true;
} }
// public class SaveCookieImpl implements SaveCookie {
//
// public void save() throws IOException {
// editorController.saveScene();
// //TODO: update infos.. runs on callable..
//// if (currentRequest != null) {
//// setSceneInfo(currentRequest.getRootNode(), editorController.getCurrentFileObject(), true);
//// }
// }
// }
private void cleanupControllers() { private void cleanupControllers() {
if (camController != null) { if (camController != null) {
camController.disable(); camController.disable();
@ -920,14 +883,14 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
editorController.cleanup(); editorController.cleanup();
editorController = null; editorController = null;
} }
setActivatedNodes(new org.openide.nodes.Node[]{});
} }
/* /*
* SceneListener * SceneListener
*/ */
public void sceneRequested(SceneRequest request) { public void sceneOpened(SceneRequest request) {
if (request.equals(currentRequest)) { if (request.equals(currentRequest)) {
setActivatedNodes(new org.openide.nodes.Node[]{currentRequest.getDataObject().getNodeDelegate()});
setSceneInfo(currentRequest.getJmeNode(), editorController.getCurrentFileObject(), true); setSceneInfo(currentRequest.getJmeNode(), editorController.getCurrentFileObject(), true);
if (camController != null) { if (camController != null) {
camController.disable(); camController.disable();
@ -947,44 +910,79 @@ private void scaleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
SelectTool tool = new SelectTool(); SelectTool tool = new SelectTool();
toolController.showEditTool(tool); toolController.showEditTool(tool);
toolController.setShowSelection(true); toolController.setShowSelection(true);
editorController.setToolController(toolController); editorController.setToolController(toolController);
toolController.refreshNonSpatialMarkers(); toolController.refreshNonSpatialMarkers();
editorController.setTerrainLodCamera(); editorController.setTerrainLodCamera();
}/* else { // final SpatialAssetDataObject dobj = ((SpatialAssetDataObject) currentRequest.getDataObject());
SceneApplication.getApplication().removeSceneListener(this); // listener = new ProjectAssetManager.ClassPathChangeListener() {
currentRequest = null; //
setSceneInfo(null, false); // public void classPathChanged(final ProjectAssetManager manager) {
cleanupControllers(); // if (dobj.isModified()) {
}*/ // Confirmation msg = new NotifyDescriptor.Confirmation(
// "Classes have been changed, reload scene?",
// NotifyDescriptor.OK_CANCEL_OPTION,
// NotifyDescriptor.ERROR_MESSAGE);
// Object result = DialogDisplayer.getDefault().notify(msg);
// if (!NotifyDescriptor.OK_OPTION.equals(result)) {
// return;
// }
// }
// Runnable call = new Runnable() {
//
// public void run() {
// ProgressHandle progressHandle = ProgressHandleFactory.createHandle("Opening in SceneComposer");
// progressHandle.start();
// try {
// manager.clearCache();
// final Spatial asset = dobj.loadAsset();
// if (asset != null) {
// java.awt.EventQueue.invokeLater(new Runnable() {
//
// public void run() {
// SceneComposerTopComponent composer = SceneComposerTopComponent.findInstance();
// composer.openScene(asset, dobj, manager);
// }
// });
// } else {
// Confirmation msg = new NotifyDescriptor.Confirmation(
// "Error opening " + dobj.getPrimaryFile().getNameExt(),
// NotifyDescriptor.OK_CANCEL_OPTION,
// NotifyDescriptor.ERROR_MESSAGE);
// DialogDisplayer.getDefault().notify(msg);
// }
// } finally {
// progressHandle.finish();
// }
// }
// };
// new Thread(call).start();
// }
// };
// currentRequest.getManager().addClassPathEventListener(listener);
}
} }
public boolean sceneClose(SceneRequest request) { public void sceneClosed(SceneRequest request) {
if (request.equals(currentRequest)) { if (request.equals(currentRequest)) {
// if (checkSaved()) { setActivatedNodes(new org.openide.nodes.Node[]{});
// if (currentRequest != null) {
// currentRequest.getManager().removeClassPathEventListener(listener);
// listener = null;
// }
SceneApplication.getApplication().removeSceneListener(this); SceneApplication.getApplication().removeSceneListener(this);
currentRequest = null; currentRequest = null;
setSceneInfo(null, null, false); setSceneInfo(null, null, false);
java.awt.EventQueue.invokeLater(new Runnable() { cleanupControllers();
public void run() {
cleanupControllers();
}
});
// } else {
// return false;
// }
} }
return true;
} }
public void previewRequested(PreviewRequest request) { public void previewCreated(PreviewRequest request) {
} }
public void displayInfo(String info) { public void displayInfo(String info) {
Message msg = new NotifyDescriptor.Message(info); Message msg = new NotifyDescriptor.Message(info);
DialogDisplayer.getDefault().notifyLater(msg); DialogDisplayer.getDefault().notifyLater(msg);
} }
} }

@ -34,11 +34,11 @@ public class SelectTool extends SceneEditTool {
if (result != null) { if (result != null) {
// System.out.println(rootNode.getChild(result).getName()); // System.out.println(rootNode.getChild(result).getName());
// SceneExplorerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{rootNode.getChild(result)}); // SceneExplorerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{rootNode.getChild(result)});
SceneApplication.getApplication().setCurrentFileNode(rootNode.getChild(result)); SceneExplorerTopComponent.findInstance().setSelectedNode(rootNode.getChild(result));
} else { } else {
// SceneExplorerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{rootNode}); // SceneExplorerTopComponent.findInstance().setActivatedNodes(new org.openide.nodes.Node[]{rootNode});
SceneApplication.getApplication().setCurrentFileNode(rootNode); SceneExplorerTopComponent.findInstance().setSelectedNode(rootNode);
} }
} }
}); });

@ -871,8 +871,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
selectedSpat = spatial; selectedSpat = spatial;
editorController.setSelectedSpat(spatial); editorController.setSelectedSpat(spatial);
/*if (selectedSpat instanceof JmeTerrainQuad) { //TODO shouldn't be terrainQuad, should be a generic JmeTerrain /*if (selectedSpat instanceof JmeTerrainQuad) { //TODO shouldn't be terrainQuad, should be a generic JmeTerrain
selectedSpat.removeNodeListener(terrainDeletedNodeListener); // remove it if it exists, no way to check if it is there already selectedSpat.removeNodeListener(terrainDeletedNodeListener); // remove it if it exists, no way to check if it is there already
selectedSpat.addNodeListener(terrainDeletedNodeListener); // add it back selectedSpat.addNodeListener(terrainDeletedNodeListener); // add it back
}*/ }*/
} }
@ -948,7 +948,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
protected void componentActivated() { protected void componentActivated() {
SceneViewerTopComponent.findInstance().requestVisible(); SceneViewerTopComponent.findInstance().requestVisible();
} }
void writeProperties(java.util.Properties p) { void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at // better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles // http://wiki.apidesign.org/wiki/PropertyFiles
@ -1009,15 +1009,15 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
this.currentRequest = request; this.currentRequest = request;
request.setWindowTitle("TerrainEditor - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath())); request.setWindowTitle("TerrainEditor - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath()));
request.setToolNode(new Node("TerrainEditorToolNode")); request.setToolNode(new Node("TerrainEditorToolNode"));
SceneApplication.getApplication().requestScene(request); SceneApplication.getApplication().openScene(request);
terrainDeletedNodeListener = new TerrainNodeListener(); terrainDeletedNodeListener = new TerrainNodeListener();
editorController.enableTextureButtons(); editorController.enableTextureButtons();
} }
// run on GL thread // runs on AWT thread now
public void sceneRequested(SceneRequest request) { public void sceneOpened(SceneRequest request) {
if (request.equals(currentRequest)) { if (request.equals(currentRequest)) {
Logger.getLogger(TerrainEditorTopComponent.class.getName()).finer("Terrain sceneRequested " + request.getWindowTitle()); Logger.getLogger(TerrainEditorTopComponent.class.getName()).finer("Terrain sceneRequested " + request.getWindowTitle());
@ -1064,16 +1064,11 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
toolController.setHeightToolHeight((float) heightSlider.getValue() / (float) heightSlider.getMaximum()); toolController.setHeightToolHeight((float) heightSlider.getValue() / (float) heightSlider.getMaximum());
editorController.setTerrainLodCamera(); editorController.setTerrainLodCamera();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { reinitTextureTable(); // update the UI
reinitTextureTable(); // update the UI if (editorController.getTerrain(null) != null) {
if (editorController.getTerrain(null) != null) { //createTerrainButton.setEnabled(false); // only let the user add one terrain
//createTerrainButton.setEnabled(false); // only let the user add one terrain }
}
}
});
} }
} }
@ -1110,24 +1105,18 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
}); });
} }
public boolean sceneClose(SceneRequest request) { public void sceneClosed(SceneRequest request) {
if (request.equals(currentRequest)) { if (request.equals(currentRequest)) {
// if (checkSaved()) { // if (checkSaved()) {
SceneApplication.getApplication().removeSceneListener(this); SceneApplication.getApplication().removeSceneListener(this);
setSceneInfo(null, false); setSceneInfo(null, false);
currentRequest = null; currentRequest = null;
java.awt.EventQueue.invokeLater(new Runnable() { cleanupControllers();
public void run() {
cleanupControllers();
}
});
// } // }
} }
return true;
} }
public void previewRequested(PreviewRequest request) { public void previewCreated(PreviewRequest request) {
} }
private void cleanupControllers() { private void cleanupControllers() {
@ -1175,14 +1164,15 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
textureTable.getColumnModel().getColumn(2).setCellEditor(rendererNormal); textureTable.getColumnModel().getColumn(2).setCellEditor(rendererNormal);
// empty out the table // empty out the table
while (textureTable.getModel().getRowCount() > 0) while (textureTable.getModel().getRowCount() > 0) {
((TextureTableModel) textureTable.getModel()).removeRow(0); ((TextureTableModel) textureTable.getModel()).removeRow(0);
}
if (editorController.getTerrain(null) == null) { if (editorController.getTerrain(null) == null) {
return; return;
} }
} }
/** /**
* Adds another texture layer to the material, sets a default texture for it. * Adds another texture layer to the material, sets a default texture for it.
* Assumes that the new index is in the range of the amount of available textures * Assumes that the new index is in the range of the amount of available textures
@ -1596,22 +1586,22 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
throw new UnsupportedOperationException("Unable to create directory"); throw new UnsupportedOperationException("Unable to create directory");
} }
/* /*
@Override @Override
public File[] getRoots() public File[] getRoots()
{ {
return rootDirectories; return rootDirectories;
} }
@Override @Override
public boolean isRoot(File file) public boolean isRoot(File file)
{ {
for (File root : rootDirectories) { for (File root : rootDirectories) {
if (root.equals(file)) { if (root.equals(file)) {
return true; return true;
} }
} }
return false; return false;
}*/ }*/
} }
public class Utils { public class Utils {

@ -753,7 +753,7 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="56" max="32767" attributes="0"/> <EmptySpace min="0" pref="59" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">

@ -17,6 +17,7 @@ import com.jme3.light.DirectionalLight;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import java.util.concurrent.Callable;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
@ -874,25 +875,31 @@ public final class VehicleCreatorTopComponent extends TopComponent implements Sc
currentRequest.setDataObject(file); currentRequest.setDataObject(file);
currentRequest.setToolNode(editorController.getToolsNode()); currentRequest.setToolNode(editorController.getToolsNode());
currentRequest.setHelpCtx(ctx); currentRequest.setHelpCtx(ctx);
SceneApplication.getApplication().requestScene(currentRequest); SceneApplication.getApplication().openScene(currentRequest);
} }
public void previewRequested(PreviewRequest request) { public void previewCreated(PreviewRequest request) {
} }
public boolean sceneClose(SceneRequest request) { public void sceneClosed(SceneRequest request) {
if (request == currentRequest) { if (request == currentRequest) {
SceneApplication.getApplication().removeSceneListener(this); SceneApplication.getApplication().removeSceneListener(this);
currentRequest.getRootNode().getParent().removeLight(dirLight);
editorController.cleanupApplication(); editorController.cleanupApplication();
SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState());
setLoadedScene(null, false); setLoadedScene(null, false);
final SceneRequest current= currentRequest;
currentRequest = null; currentRequest = null;
SceneApplication.getApplication().enqueue(new Callable<Void>() {
public Void call() throws Exception {
current.getRootNode().getParent().removeLight(dirLight);
SceneApplication.getApplication().getStateManager().detach(editorController.getBulletState());
return null;
}
});
} }
return true;
} }
public void sceneRequested(SceneRequest request) { public void sceneOpened(SceneRequest request) {
if (request == currentRequest) { if (request == currentRequest) {
editorController.prepareApplication(); editorController.prepareApplication();
SceneApplication.getApplication().getStateManager().attach(editorController.getBulletState()); SceneApplication.getApplication().getStateManager().attach(editorController.getBulletState());

@ -61,60 +61,60 @@ public class WelcomeScreen implements ScreenController {
final DirectionalLight dirLight = new DirectionalLight(); final DirectionalLight dirLight = new DirectionalLight();
dirLight.setDirection(new Vector3f(.1f, 1, .1f).normalizeLocal()); dirLight.setDirection(new Vector3f(.1f, 1, .1f).normalizeLocal());
dirLight.setColor(ColorRGBA.Gray); dirLight.setColor(ColorRGBA.Gray);
SceneApplication.getApplication().addSceneListener(new SceneListener() { // SceneApplication.getApplication().addSceneListener(new SceneListener() {
//
@Override // @Override
public void sceneRequested(SceneRequest request) { // public void sceneRequested(SceneRequest request) {
if (request.getRequester() == WelcomeScreen.this) { // if (request.getRequester() == WelcomeScreen.this) {
//FIXME: planet location dont work? // //FIXME: planet location dont work?
if (SceneApplication.getApplication().getRenderer().getCaps().contains(Caps.OpenGL21)) { // if (SceneApplication.getApplication().getRenderer().getCaps().contains(Caps.OpenGL21)) {
// planetView = new PlanetRendererState(new Planet(100f, new Vector3f(0, 0, 0)), dirLight); //// planetView = new PlanetRendererState(new Planet(100f, new Vector3f(0, 0, 0)), dirLight);
// SceneApplication.getApplication().getStateManager().attach(planetView); //// SceneApplication.getApplication().getStateManager().attach(planetView);
} // }
SceneApplication.getApplication().getViewPort().getScenes().get(0).addLight(dirLight); // SceneApplication.getApplication().getViewPort().getScenes().get(0).addLight(dirLight);
SceneApplication.getApplication().getCamera().setLocation(new Vector3f(0, 0, 400)); // SceneApplication.getApplication().getCamera().setLocation(new Vector3f(0, 0, 400));
setupSkyBox(); // setupSkyBox();
niftyDisplay = new NiftyJmeDisplay(SceneApplication.getApplication().getAssetManager(), // niftyDisplay = new NiftyJmeDisplay(SceneApplication.getApplication().getAssetManager(),
SceneApplication.getApplication().getInputManager(), // SceneApplication.getApplication().getInputManager(),
SceneApplication.getApplication().getAudioRenderer(), // SceneApplication.getApplication().getAudioRenderer(),
SceneApplication.getApplication().getGuiViewPort()); // SceneApplication.getApplication().getGuiViewPort());
nifty = niftyDisplay.getNifty(); // nifty = niftyDisplay.getNifty();
try { // try {
nifty.fromXml("Interface/WelcomeScreen.xml", new URL("nbres:/Interface/WelcomeScreen.xml").openStream(), "start", welcomeScreen); // nifty.fromXml("Interface/WelcomeScreen.xml", new URL("nbres:/Interface/WelcomeScreen.xml").openStream(), "start", welcomeScreen);
} catch (Exception ex) { // } catch (Exception ex) {
Exceptions.printStackTrace(ex); // Exceptions.printStackTrace(ex);
} // }
//
// attach the nifty display to the gui view port as a processor // // attach the nifty display to the gui view port as a processor
SceneApplication.getApplication().getGuiViewPort().addProcessor(niftyDisplay); // SceneApplication.getApplication().getGuiViewPort().addProcessor(niftyDisplay);
}
}
@Override
public boolean sceneClose(SceneRequest request) {
SceneApplication.getApplication().getViewPort().getScenes().get(0).removeLight(dirLight);
skyBox.removeFromParent();
SceneApplication.getApplication().getGuiViewPort().removeProcessor(niftyDisplay);
nifty.exit();
// if (planetView != null) {
// SceneApplication.getApplication().getStateManager().detach(planetView);
// } // }
SceneApplication.getApplication().removeSceneListener(this); // }
return true; //
} // @Override
// public boolean sceneClose(SceneRequest request) {
@Override // SceneApplication.getApplication().getViewPort().getScenes().get(0).removeLight(dirLight);
public void previewRequested(PreviewRequest request) { // skyBox.removeFromParent();
} // SceneApplication.getApplication().getGuiViewPort().removeProcessor(niftyDisplay);
}); // nifty.exit();
SceneApplication.getApplication().enqueue(new Callable<Object>() { //// if (planetView != null) {
//// SceneApplication.getApplication().getStateManager().detach(planetView);
@Override //// }
public Object call() throws Exception { // SceneApplication.getApplication().removeSceneListener(this);
SceneApplication.getApplication().requestScene(request); // return true;
return null; // }
} //
}); // @Override
// public void previewRequested(PreviewRequest request) {
// }
// });
// SceneApplication.getApplication().enqueue(new Callable<Object>() {
//
// @Override
// public Object call() throws Exception {
// SceneApplication.getApplication().requestScene(request);
// return null;
// }
// });
} }
private void setupSkyBox() { private void setupSkyBox() {

Loading…
Cancel
Save