Hey,
I have a problem with a j3o file. It is based on a blender file where the charakter is walking but when I convert it to a j3o and run my programm the charakter just rotates 90 degree round the x-axis… I dont know what to do - in Blender the animation is correct but in the j3o it is wrong. In the SceneExplorer it performs the same move when excuting the Animation…
package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
/** Sample 7 - how to load an OgreXML model and play an animation,
* using channels, a controller, and an AnimEventListener. */
public class HelloAnimation extends SimpleApplication
implements AnimEventListener {
private AnimChannel channel;
private AnimControl control;
Node player;
public static void main(String[] args) {
HelloAnimation app = new HelloAnimation();
app.start();
}
@Override
public void simpleInitApp() {
initKeys();
viewPort.setBackgroundColor(ColorRGBA.LightGray);
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
rootNode.addLight(dl);
player = (Node) assetManager.loadModel("Charakters/Archer/Movements/Walking/Walking.j3o");
player.setLocalScale(0.03f);
player.rotate((float) Math.PI/4, 0f, 0f);
rootNode.attachChild(player);
control = player.getChild("Armature").getControl(AnimControl.class);//new AnimControl(new Skeleton());
control.addListener(this);
channel = control.createChannel();
}
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
}
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
// unused
}
private void initKeys() {
inputManager.addMapping("Walk", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(actionListener, "Walk");
}
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("Walk") && !keyPressed) {
channel.setAnim("Walking", 0.50f);
channel.setLoopMode(LoopMode.Loop);
}
}
};
}
final SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton());
to my Code and I get a
java.lang.NullPointerException
at com.jme3.scene.debug.SkeletonWire.<init>(SkeletonWire.java:71)
at com.jme3.scene.debug.SkeletonDebugger.<init>(SkeletonDebugger.java:49)
at mygame.HelloAnimation.simpleInitApp(HelloAnimation.java:43)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)
The one in same subfolder as skeleton is the correct one and shows no animation so something is wrong in blender sounds like.
If I remember correctly, two AnimControls means you didn’t clean up your blender file prior to import. Did you remove the old actions and clean up your buffers? This is something you would do on a final model so only do this in a copy of the original or you will lose your actions.
At least the one you said would be the correct one is rotating the player again. The other one is still empty… I cleaned up my blender file but there still is a problem.
I suggest you check to make sure the action buffer is actually only showing the baked actions. It can be tricky and sometimes it doesn’t clear the action when you think it has.
In the action editor, click the “Browse action to be linked” button and make sure nothing has a zero in front of the action and that only the baked actions are there.
Try looking in blender Outliner panel and see if there is only one armature.
Hey sorry for my late answer,
I’ve been away for a week. Yes in blender is only one action and it has an F in front. My current problem is that in jme the action is there but its just empyt and the model is standing there doing nothing…