- Only store ORIGINAL_PATH metadata in .j3odata when actually converting the model for the first time
- Store ORIGINAL_PATH and ORIGINAL_NAME UserData on geometry when creating j3o files with the SDK

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10242 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 6efe687825
commit d0dc0d1345
  1. 1
      sdk/jme3-blender/src/com/jme3/gde/blender/filetypes/AbstractBlenderAssetDataObject.java
  2. 51
      sdk/jme3-core/src/com/jme3/gde/core/assets/SpatialAssetDataObject.java
  3. 1
      sdk/jme3-ogretools/src/com/jme3/gde/ogretools/OgreBinaryMeshDataObject.java

@ -72,6 +72,7 @@ public abstract class AbstractBlenderAssetDataObject extends SpatialAssetDataObj
replaceFiles();
listListener.stop();
savable = spatial;
storeOriginalPathUserData();
return spatial;
} catch (IOException ex) {
Exceptions.printStackTrace(ex);

@ -33,8 +33,11 @@ package com.jme3.gde.core.assets;
import com.jme3.asset.AssetKey;
import com.jme3.asset.ModelKey;
import com.jme3.scene.Geometry;
import com.jme3.scene.SceneGraphVisitorAdapter;
import com.jme3.scene.Spatial;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.DialogDisplayer;
@ -94,6 +97,9 @@ public class SpatialAssetDataObject extends AssetDataObject {
Spatial spatial = mgr.loadModel(getAssetKey());
listListener.stop();
savable = spatial;
if (!(this instanceof BinaryModelDataObject)) {
storeOriginalPathUserData();
}
lock.releaseLock();
return spatial;
} catch (Exception ex) {
@ -136,4 +142,49 @@ public class SpatialAssetDataObject extends AssetDataObject {
Exceptions.printStackTrace(ex);
}
}
/*
* SDK:
- Only store ORIGINAL_PATH AssetData property when actually converting
- Store ORIGINAL_PATH and ORIGINAL_NAME UserData on geometry when creating j3o files with the SDK
*/
protected void storeOriginalPathUserData() {
final ArrayList<String> geomMap = new ArrayList<String>();
Spatial spat = (Spatial) savable;
if (spat != null) {
spat.depthFirstTraversal(new SceneGraphVisitorAdapter() {
@Override
public void visit(Geometry geom) {
StringBuilder geometryIdentifier = new StringBuilder();
Spatial curSpat = geom;
String geomName = curSpat.getName();
if (geomName == null) {
logger.log(Level.WARNING, "Null geometry name!");
geomName = "null";
}
geom.setUserData("ORIGINAL_NAME", geomName);
logger.log(Level.INFO, "Set ORIGINAL_NAME for {0}", geomName);
while (curSpat != null) {
String name = curSpat.getName();
if (name == null) {
logger.log(Level.WARNING, "Null spatial name!");
name = "null";
}
geometryIdentifier.insert(0, name);
geometryIdentifier.insert(0, '/');
curSpat = curSpat.getParent();
}
String id = geometryIdentifier.toString();
if (geomMap.contains(id)) {
logger.log(Level.WARNING, "Cannot create unique name for Geometry {0}: {1}", new Object[]{geom, id});
}
geomMap.add(id);
geom.setUserData("ORIGINAL_PATH", id);
logger.log(Level.INFO, "Set ORIGINAL_PATH for {0}", id);
super.visit(geom);
}
});
} else {
logger.log(Level.SEVERE, "No geometry available when trying to scan initial geometry configuration");
}
}
}

@ -64,6 +64,7 @@ public class OgreBinaryMeshDataObject extends SpatialAssetDataObject {
replaceXmlFiles(mgr);
listListener.stop();
savable = spatial;
storeOriginalPathUserData();
lock.releaseLock();
File deleteFile = new File(options.getDestFile());
deleteFile.delete();

Loading…
Cancel
Save