diff --git a/sdk/jme3-core/src/com/jme3/gde/core/assets/ExternalChangeScanner.java b/sdk/jme3-core/src/com/jme3/gde/core/assets/ExternalChangeScanner.java index 1b8384879..61a036582 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/assets/ExternalChangeScanner.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/assets/ExternalChangeScanner.java @@ -130,14 +130,14 @@ public class ExternalChangeScanner implements AssetDataPropertyChangeListener, F Spatial original = loadOriginalSpatial(); Spatial spat = (Spatial) assetDataObject.loadAsset(); 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(); -// 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(); } catch (Exception e) { logger.log(Level.SEVERE, "Exception when trying to update external data.", e); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java b/sdk/jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java index 36d2142d2..6895934c8 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java @@ -256,6 +256,7 @@ public class SpatialUtil { 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 //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() { @Override public void visit(Spatial spat) { @@ -273,11 +274,11 @@ public class SpatialUtil { if (myAnimControl != null) { mySpatial.removeControl(myAnimControl); } - AnimControl newControl = (AnimControl)animControl.cloneForSpatial(mySpatial); + AnimControl newControl = (AnimControl) animControl.cloneForSpatial(mySpatial); if (mySpatial.getControl(SkeletonControl.class) == null) { logger.log(Level.INFO, "Adding control for {0}", mySpatial.getName()); mySpatial.addControl(newControl); - }else{ + } else { logger.log(Level.INFO, "Control for {0} was added automatically", mySpatial.getName()); } if (mySpatial.getControl(SkeletonControl.class) == null) { @@ -295,6 +296,22 @@ public class SpatialUtil { //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) { //TODO: Clear old stuff at all? return;