From b5e4914ac7926575e00755d2af1213894af5ef2e Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Wed, 24 Aug 2011 18:16:26 +0000 Subject: [PATCH] Additional locators added to locate blender resources. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8073 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3test/blender/ManualBlenderTester.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/engine/src/test/jme3test/blender/ManualBlenderTester.java b/engine/src/test/jme3test/blender/ManualBlenderTester.java index a6a7c84bf..3e48159a4 100644 --- a/engine/src/test/jme3test/blender/ManualBlenderTester.java +++ b/engine/src/test/jme3test/blender/ManualBlenderTester.java @@ -35,8 +35,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.Map; -import java.util.Map.Entry; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -69,7 +68,7 @@ import com.jme3.texture.plugins.AWTLoader; public class ManualBlenderTester extends SimpleApplication { private static final Logger LOGGER = Logger.getLogger(ManualBlenderTester.class.getName()); - private ModelKey modelKey;//the key that holds the test file configuration + private BlenderKeyConfiguration blenderKeyConfiguration; private final boolean debug; /** @@ -107,7 +106,7 @@ public class ManualBlenderTester extends SimpleApplication { public ManualBlenderTester(BlenderKeyConfiguration bkc, boolean debug) { this.debug = debug; Logger.getLogger("com.jme3").setLevel(bkc.getLogLevel()); - this.modelKey = bkc.getKeyToUse(); + this.blenderKeyConfiguration = bkc; this.showSettings = false; } @@ -117,14 +116,20 @@ public class ManualBlenderTester extends SimpleApplication { mouseInput.setCursorVisible(true); } assetManager.registerLocator(".", FileLocator.class); + assetManager.registerLocator("./src/test-data/Blender/2.4x", FileLocator.class); + assetManager.registerLocator("./src/test-data/Blender/2.4x/textures", FileLocator.class); + assetManager.registerLocator("./src/test-data/Blender/2.5x", FileLocator.class); + assetManager.registerLoader(BlenderLoader.class, "blend"); - assetManager.registerLoader(AWTLoader.class, "png"); + assetManager.registerLoader(AWTLoader.class, "png", "jpg", "bmp"); viewPort.setBackgroundColor(ColorRGBA.Gray); flyCam.setMoveSpeed(20); cam.setFrustumFar(1000.0f); cam.setFrustumNear(1.0f); + + ModelKey modelKey = blenderKeyConfiguration.getKeyToUse(); AssetInfo ai = new AssetInfo(assetManager, modelKey) { @Override @@ -140,19 +145,17 @@ public class ManualBlenderTester extends SimpleApplication { rootNode.attachChild(new Pivot(assetManager)); if (modelKey instanceof BlenderKey) { this.testBlenderLoader(ai); - Map> animations = ((BlenderKey) modelKey).getAnimations(); - //setting the first animation as active - if (((BlenderKey) modelKey).getAnimations() != null) { - for (Entry> animEntry : animations.entrySet()) { - for (Entry anim : animEntry.getValue().entrySet()) { - Spatial animatedSpatial = this.findNode(this.rootNode, animEntry.getKey()); - if(animatedSpatial != null) { - animatedSpatial.getControl(AnimControl.class).createChannel().setAnim(anim.getKey()); - break; - } + //setting the selected animations as active + List selectedAnimations = blenderKeyConfiguration.getSelectedAnimations().get(modelKey.getName()); + if(selectedAnimations != null) { + for(String[] animData : selectedAnimations) { + Spatial animatedSpatial = this.findNode(this.rootNode, animData[0]); + if(animatedSpatial != null) { + animatedSpatial.getControl(AnimControl.class).createChannel().setAnim(animData[1]); + } else { + LOGGER.warning("Cannot find the node to play its animation: " + animData[0]); } - break; - } + } } } else { this.testBlenderModelLoader(ai);