Additional locators added to locate blender resources.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8073 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b8df569d86
commit
b5e4914ac7
@ -35,8 +35,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ import com.jme3.texture.plugins.AWTLoader;
|
|||||||
public class ManualBlenderTester extends SimpleApplication {
|
public class ManualBlenderTester extends SimpleApplication {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(ManualBlenderTester.class.getName());
|
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;
|
private final boolean debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,7 +106,7 @@ public class ManualBlenderTester extends SimpleApplication {
|
|||||||
public ManualBlenderTester(BlenderKeyConfiguration bkc, boolean debug) {
|
public ManualBlenderTester(BlenderKeyConfiguration bkc, boolean debug) {
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
Logger.getLogger("com.jme3").setLevel(bkc.getLogLevel());
|
Logger.getLogger("com.jme3").setLevel(bkc.getLogLevel());
|
||||||
this.modelKey = bkc.getKeyToUse();
|
this.blenderKeyConfiguration = bkc;
|
||||||
this.showSettings = false;
|
this.showSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,14 +116,20 @@ public class ManualBlenderTester extends SimpleApplication {
|
|||||||
mouseInput.setCursorVisible(true);
|
mouseInput.setCursorVisible(true);
|
||||||
}
|
}
|
||||||
assetManager.registerLocator(".", FileLocator.class);
|
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(BlenderLoader.class, "blend");
|
||||||
assetManager.registerLoader(AWTLoader.class, "png");
|
assetManager.registerLoader(AWTLoader.class, "png", "jpg", "bmp");
|
||||||
|
|
||||||
viewPort.setBackgroundColor(ColorRGBA.Gray);
|
viewPort.setBackgroundColor(ColorRGBA.Gray);
|
||||||
|
|
||||||
flyCam.setMoveSpeed(20);
|
flyCam.setMoveSpeed(20);
|
||||||
cam.setFrustumFar(1000.0f);
|
cam.setFrustumFar(1000.0f);
|
||||||
cam.setFrustumNear(1.0f);
|
cam.setFrustumNear(1.0f);
|
||||||
|
|
||||||
|
ModelKey modelKey = blenderKeyConfiguration.getKeyToUse();
|
||||||
AssetInfo ai = new AssetInfo(assetManager, modelKey) {
|
AssetInfo ai = new AssetInfo(assetManager, modelKey) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -140,19 +145,17 @@ public class ManualBlenderTester extends SimpleApplication {
|
|||||||
rootNode.attachChild(new Pivot(assetManager));
|
rootNode.attachChild(new Pivot(assetManager));
|
||||||
if (modelKey instanceof BlenderKey) {
|
if (modelKey instanceof BlenderKey) {
|
||||||
this.testBlenderLoader(ai);
|
this.testBlenderLoader(ai);
|
||||||
Map<String, Map<String, int[]>> animations = ((BlenderKey) modelKey).getAnimations();
|
//setting the selected animations as active
|
||||||
//setting the first animation as active
|
List<String[]> selectedAnimations = blenderKeyConfiguration.getSelectedAnimations().get(modelKey.getName());
|
||||||
if (((BlenderKey) modelKey).getAnimations() != null) {
|
if(selectedAnimations != null) {
|
||||||
for (Entry<String, Map<String, int[]>> animEntry : animations.entrySet()) {
|
for(String[] animData : selectedAnimations) {
|
||||||
for (Entry<String, int[]> anim : animEntry.getValue().entrySet()) {
|
Spatial animatedSpatial = this.findNode(this.rootNode, animData[0]);
|
||||||
Spatial animatedSpatial = this.findNode(this.rootNode, animEntry.getKey());
|
|
||||||
if(animatedSpatial != null) {
|
if(animatedSpatial != null) {
|
||||||
animatedSpatial.getControl(AnimControl.class).createChannel().setAnim(anim.getKey());
|
animatedSpatial.getControl(AnimControl.class).createChannel().setAnim(animData[1]);
|
||||||
break;
|
} else {
|
||||||
|
LOGGER.warning("Cannot find the node to play its animation: " + animData[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.testBlenderModelLoader(ai);
|
this.testBlenderModelLoader(ai);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user