- update external change scanner to allow import of animations

experimental
Normen Hansen 10 years ago
parent a2fc435167
commit b61656ffaa
  1. 14
      sdk/jme3-core/src/com/jme3/gde/core/assets/ExternalChangeScanner.java
  2. 17
      sdk/jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java

@ -130,14 +130,14 @@ public class ExternalChangeScanner implements AssetDataPropertyChangeListener, F
Spatial original = loadOriginalSpatial(); Spatial original = loadOriginalSpatial();
Spatial spat = (Spatial) assetDataObject.loadAsset(); Spatial spat = (Spatial) assetDataObject.loadAsset();
SpatialUtil.updateMeshDataFromOriginal(spat, original); SpatialUtil.updateMeshDataFromOriginal(spat, original);
NotifyDescriptor.Confirmation mesg = new NotifyDescriptor.Confirmation("Model appears to have animations, try to import as well?\nCurrently this will unlink attachment Nodes and clear\nadded effects tracks.",
"Animations Available",
NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE);
DialogDisplayer.getDefault().notify(mesg);
if (mesg.getValue() == NotifyDescriptor.Confirmation.YES_OPTION) {
SpatialUtil.updateAnimControlDataFromOriginal(spat, original);
}
closeOriginalSpatial(); closeOriginalSpatial();
// NotifyDescriptor.Confirmation mesg = new NotifyDescriptor.Confirmation("Model appears to have animations, try to import as well?\nCurrently this will unlink attachment Nodes and clear\nadded effects tracks.",
// "Animations Available",
// NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE);
// DialogDisplayer.getDefault().notify(mesg);
// if (mesg.getValue() == NotifyDescriptor.Confirmation.YES_OPTION) {
// SpatialUtil.updateAnimControlDataFromOriginal(spat, original);
// }
assetDataObject.saveAsset(); assetDataObject.saveAsset();
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.SEVERE, "Exception when trying to update external data.", e); logger.log(Level.SEVERE, "Exception when trying to update external data.", e);

@ -256,6 +256,7 @@ public class SpatialUtil {
public static void updateAnimControlDataFromOriginal(final Spatial root, final Spatial original) { public static void updateAnimControlDataFromOriginal(final Spatial root, final Spatial original) {
//loop through original to also find new AnimControls, we expect all nodes etc. to exist //loop through original to also find new AnimControls, we expect all nodes etc. to exist
//TODO: can (blender) AnimControls end up in other nodes that are not a parent of the geometry they modify? //TODO: can (blender) AnimControls end up in other nodes that are not a parent of the geometry they modify?
removeAnimData(root);
original.depthFirstTraversal(new SceneGraphVisitor() { original.depthFirstTraversal(new SceneGraphVisitor() {
@Override @Override
public void visit(Spatial spat) { public void visit(Spatial spat) {
@ -295,6 +296,22 @@ public class SpatialUtil {
//TODO: remove old AnimControls? //TODO: remove old AnimControls?
} }
public static void removeAnimData(Spatial root) {
root.depthFirstTraversal(new SceneGraphVisitor() {
@Override
public void visit(Spatial spat) {
AnimControl animControl = spat.getControl(AnimControl.class);
if (animControl != null) {
spat.removeControl(animControl);
SkeletonControl skeletonControl = spat.getControl(SkeletonControl.class);
if (skeletonControl != null) {
spat.removeControl(skeletonControl);
}
}
}
});
}
public static void clearRemovedOriginals(final Spatial root, final Spatial original) { public static void clearRemovedOriginals(final Spatial root, final Spatial original) {
//TODO: Clear old stuff at all? //TODO: Clear old stuff at all?
return; return;

Loading…
Cancel
Save