First off, G’day! I’m new to JME, with all of about 3 days experience. That experience isn’t without problems however, hence why I’m here.
I’ve been playing around with the concepts in the first couple of tutorials. I’ve sucessfully created a cube, created a textured cube, imported a model from blender, imported a textured model from blender… so on and so forth. Then I thought I’d try my hand at getting some animation, but have had no luck.
I created a quick test model in blender, gave it an armature, and a single animation. I put the .blend in my Project Assets folder, and have been working straight off the .blend (no conversion to .j3o).
I can load and view the model with no problems. But for some reason, I can not get the AnimControl from the spatial (using Spatial.getControl(AnimControl.class)). The method returns null, and obviously any subsequent method called on the non-existent control results in a NullPointerException. Furthermore, calling getNumControls() on the Spatial returns 0. The strange thing is, I have no problems viewing the animation in the SceneExplorer. The AnimControl exists, and it does what its supposed to (making me think there is nothing wrong with the model or animation itself???).
I thought it might be a problem with working out of the .blend, so tried to convert it to .j3o, but trying to load the .j3o results in an exception too…
I’ve really got no idea whats going on, and feel like a complete nuffty. As such, are you guys able to please shed some light on the situation? It would be greatly appreciated. I’ll attach the code and errors to this post.
Im running jMP Alpha-4, with the latest nightlies (as @ a couple of hours ago). Its probably obvious in the following code, but “zzz” is the Spatial and “doStuff” is the animation.
Here’s the main class:
[java] public class Main extends SimpleApplication {
AnimControl control;
AnimChannel channel;
Spatial zzz;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setColor(“Color”, ColorRGBA.Blue);
zzz = assetManager.loadModel(“Blends/zzz.blend”);
zzz.setMaterial(mat);
rootNode.attachChild(zzz);
control = zzz.getControl(AnimControl.class);
//Chucks a wobbly here, as getControl has returned null.
channel = control.createChannel();
channel.setAnim(“doStuff”);
channel.setLoopMode(LoopMode.Loop);
DirectionalLight light = new DirectionalLight();
light.setDirection(new Vector3f(-0.1f, -0.7f, -1f));
rootNode.addLight(light);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
[/java]
The associated exception is:
05/10/2011 11:33:03 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Main.simpleInitApp(Main.java:39)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:230)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:662)
05/10/2011 11:33:03 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
05/10/2011 11:33:03 PM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
05/10/2011 11:33:03 PM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
05/10/2011 11:33:03 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
Java Result: -1073741819
The exception thrown from trying to use the .j3o in place of the .blend is:
05/10/2011 11:34:21 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.ClassCastException: [Lcom.jme3.export.Savable; cannot be cast to [Lcom.jme3.animation.Track;
at com.jme3.animation.Animation.read(Animation.java:202)
at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:357)
at com.jme3.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:484)
at com.jme3.export.binary.BinaryInputCapsule.readStringSavableMap(BinaryInputCapsule.java:668)
at com.jme3.animation.AnimControl.read(AnimControl.java:359)
at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:357)
at com.jme3.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:484)
at com.jme3.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:472)
at com.jme3.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:588)
at com.jme3.scene.Spatial.read(Spatial.java:1283)
at com.jme3.scene.Node.read(Node.java:609)
at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:357)
at com.jme3.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:484)
at com.jme3.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:472)
at com.jme3.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:588)
at com.jme3.scene.Node.read(Node.java:599)
at com.jme3.export.binary.BinaryImporter.readObject(BinaryImporter.java:357)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:264)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:147)
at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:131)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:243)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:376)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:386)
at mygame.Main.simpleInitApp(Main.java:33)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:230)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
at java.lang.Thread.run(Thread.java:662)
05/10/2011 11:34:21 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
05/10/2011 11:34:21 PM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
05/10/2011 11:34:21 PM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
05/10/2011 11:34:21 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
Let me know if you need any more info, or if I have commited any major social faux pas with this post.
Thank you all very much.