- add list of external AssetKeys and FileObjects to AssetDataObject
- use AssetDataObject asset tracking in ModelImportTool instead of own solution git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8610 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
70d600bc24
commit
a9501c7ed4
@ -48,6 +48,7 @@ import org.openide.util.Exceptions;
|
||||
*
|
||||
* @author normenhansen
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssetData extends Properties {
|
||||
|
||||
private AssetDataObject file;
|
||||
@ -82,6 +83,10 @@ public class AssetData extends Properties {
|
||||
return file.getAssetList();
|
||||
}
|
||||
|
||||
public List<AssetKey> getAssetKeyList(){
|
||||
return file.getAssetKeyList();
|
||||
}
|
||||
|
||||
public List<AssetKey> getFailedList() {
|
||||
return file.getFailedList();
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ public class AssetDataObject extends MultiDataObject {
|
||||
protected AbstractLookup contentLookup;
|
||||
protected AssetListListener listListener;
|
||||
protected List<FileObject> assetList = new LinkedList<FileObject>();
|
||||
protected List<AssetKey> assetKeyList = new LinkedList<AssetKey>();
|
||||
protected List<AssetKey> failedList = new LinkedList<AssetKey>();
|
||||
|
||||
public AssetDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
|
||||
@ -103,7 +104,7 @@ public class AssetDataObject extends MultiDataObject {
|
||||
contentLookup = new AbstractLookup(getLookupContents());
|
||||
lookupContents.add(new AssetData(this));
|
||||
lookup = new ProxyLookup(getCookieSet().getLookup(), contentLookup);
|
||||
listListener = new AssetListListener(this, assetList, failedList);
|
||||
listListener = new AssetListListener(this, assetList, assetKeyList, failedList);
|
||||
setSaveCookie(saveCookie);
|
||||
findAssetManager();
|
||||
}
|
||||
@ -252,6 +253,10 @@ public class AssetDataObject extends MultiDataObject {
|
||||
return assetList;
|
||||
}
|
||||
|
||||
public List<AssetKey> getAssetKeyList() {
|
||||
return assetKeyList;
|
||||
}
|
||||
|
||||
public List<AssetKey> getFailedList() {
|
||||
return failedList;
|
||||
}
|
||||
@ -260,12 +265,14 @@ public class AssetDataObject extends MultiDataObject {
|
||||
|
||||
private AssetDataObject obj;
|
||||
private List<FileObject> assetList;
|
||||
private List<AssetKey> assetKeyList;
|
||||
private List<AssetKey> failedList;
|
||||
private Thread loadingThread;
|
||||
|
||||
public AssetListListener(AssetDataObject obj, List<FileObject> assetList, List<AssetKey> failedList) {
|
||||
public AssetListListener(AssetDataObject obj, List<FileObject> assetList, List<AssetKey> assetKeyList, List<AssetKey> failedList) {
|
||||
this.obj = obj;
|
||||
this.assetList = assetList;
|
||||
this.assetKeyList = assetKeyList;
|
||||
this.failedList = failedList;
|
||||
}
|
||||
|
||||
@ -280,6 +287,7 @@ public class AssetDataObject extends MultiDataObject {
|
||||
FileObject obj = pm.getAssetFolder().getFileObject(ak.getName());
|
||||
if (obj != null) {
|
||||
assetList.add(obj);
|
||||
assetKeyList.add(ak);
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,6 +307,7 @@ public class AssetDataObject extends MultiDataObject {
|
||||
ProjectAssetManager pm = obj.getLookup().lookup(ProjectAssetManager.class);
|
||||
loadingThread = Thread.currentThread();
|
||||
assetList.clear();
|
||||
assetKeyList.clear();
|
||||
failedList.clear();
|
||||
if (pm == null) {
|
||||
return;
|
||||
|
@ -6,7 +6,6 @@ package com.jme3.gde.modelimporter;
|
||||
|
||||
import com.jme3.asset.AssetKey;
|
||||
import com.jme3.asset.TextureKey;
|
||||
import com.jme3.export.binary.BinaryExporter;
|
||||
import com.jme3.gde.core.assets.AssetData;
|
||||
import com.jme3.gde.core.assets.ProjectAssetManager;
|
||||
import com.jme3.gde.core.assets.SpatialAssetDataObject;
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
package com.jme3.gde.modelimporter;
|
||||
|
||||
import com.jme3.asset.AssetEventListener;
|
||||
import com.jme3.asset.AssetKey;
|
||||
import com.jme3.gde.core.assets.AssetData;
|
||||
import com.jme3.gde.core.assets.AssetDataObject;
|
||||
@ -13,7 +12,6 @@ import com.jme3.gde.core.scene.OffScenePanel;
|
||||
import com.jme3.math.Vector3f;
|
||||
import com.jme3.scene.Spatial;
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.swing.JPanel;
|
||||
@ -25,19 +23,20 @@ import org.openide.NotifyDescriptor.Message;
|
||||
import org.openide.WizardDescriptor;
|
||||
import org.openide.explorer.propertysheet.PropertySheet;
|
||||
import org.openide.filesystems.FileChooserBuilder;
|
||||
import org.openide.filesystems.FileObject;
|
||||
import org.openide.filesystems.FileUtil;
|
||||
import org.openide.loaders.DataObject;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.util.Exceptions;
|
||||
|
||||
@SuppressWarnings({"unchecked", "serial"})
|
||||
public final class ModelImporterVisualPanel1 extends JPanel implements AssetEventListener {
|
||||
public final class ModelImporterVisualPanel1 extends JPanel {
|
||||
|
||||
private OffScenePanel offPanel;
|
||||
private String currentPath;
|
||||
private String currentModelPath;
|
||||
private Spatial currentModel;
|
||||
private List<AssetKey> requestedAssets = new LinkedList<AssetKey>();
|
||||
private List<AssetKey> keys;
|
||||
private AssetKey mainKey;
|
||||
private PropertySheet ps;
|
||||
private AtomicBoolean loading = new AtomicBoolean(false);
|
||||
@ -64,7 +63,7 @@ public final class ModelImporterVisualPanel1 extends JPanel implements AssetEven
|
||||
|
||||
public void applySettings(WizardDescriptor wiz) {
|
||||
wiz.putProperty("path", currentPath);
|
||||
wiz.putProperty("assetlist", requestedAssets);
|
||||
wiz.putProperty("assetlist", keys);
|
||||
wiz.putProperty("mainkey", mainKey);
|
||||
if (mainKey != null) {
|
||||
wiz.putProperty("destpath", "Models/" + mainKey.getName().replaceAll(mainKey.getExtension(), "").replaceAll("\\.", "") + "/");
|
||||
@ -77,10 +76,9 @@ public final class ModelImporterVisualPanel1 extends JPanel implements AssetEven
|
||||
|
||||
public synchronized void loadModel(File path, AssetKey modelKey) {
|
||||
ProjectAssetManager manager = new ProjectAssetManager(FileUtil.toFileObject(path).getParent());
|
||||
manager.setAssetEventListener(this);
|
||||
try {
|
||||
if (modelKey != mainKey) {
|
||||
requestedAssets.clear();
|
||||
keys = null;
|
||||
}
|
||||
if (currentModel != null) {
|
||||
offPanel.detach(currentModel);
|
||||
@ -95,10 +93,12 @@ public final class ModelImporterVisualPanel1 extends JPanel implements AssetEven
|
||||
((AssetDataObject) obj).getLookupContents().add(manager);
|
||||
modelKey = data.getAssetKey();
|
||||
currentModel = (Spatial) data.loadAsset();
|
||||
keys = data.getAssetKeyList();
|
||||
} else {
|
||||
((AssetDataObject) obj).getLookupContents().add(manager);
|
||||
data.setAssetKey(modelKey);
|
||||
currentModel = (Spatial) data.loadAsset();
|
||||
keys = data.getAssetKeyList();
|
||||
}
|
||||
}
|
||||
mainKey = modelKey;
|
||||
@ -137,23 +137,6 @@ public final class ModelImporterVisualPanel1 extends JPanel implements AssetEven
|
||||
|
||||
}
|
||||
|
||||
public void assetRequested(AssetKey ak) {
|
||||
if (!"j3md".equalsIgnoreCase(ak.getExtension())
|
||||
&& !"glsllib".equalsIgnoreCase(ak.getExtension())
|
||||
&& !"frag".equalsIgnoreCase(ak.getExtension())
|
||||
&& !"vert".equalsIgnoreCase(ak.getExtension())) {
|
||||
if (!requestedAssets.contains(ak)) {
|
||||
requestedAssets.add(ak);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void assetLoaded(AssetKey ak) {
|
||||
}
|
||||
|
||||
public void assetDependencyNotFound(AssetKey ak, AssetKey ak1) {
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
offPanel.stopPreview();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user