Wrong Animation in j3o File

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);
        }
    }
  };

  
}

Is this a model you imported using the SDK import button?

You can try and see if you missed something by following this

https://jmonkeyengine.github.io/wiki/jme3/external/blender.html#animations

and using the checklist that follows it.

It seems like I dont have a sceleton… I added

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)

If memory serves me right, this means you are using the importer and haven’t baked your actions.

https://jmonkeyengine.github.io/wiki/jme3/advanced/mixamo.html#action-baking

I haven’t used the importer for awhile so I may be wrong but its worth a shot.

I have baked my Actions but now the charakter does not even rotate backwards… Instead it is just standing there and doing nothing…

Are you using the SDK?

If so, edit in SceneComposer and see if you have a AnimControl and SkeletonControl.

If so, do you see your animation under AnimControl.

I have a skeletonControl and two AnimControl. One of them is in the same subFolder as the SkeltonControl but empty…

And no I dont have the Animation there neither

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.

https://jmonkeyengine.github.io/wiki/jme3/advanced/3d_models.html#blender-buffer-clearing

Memory must of failed me but not having the animation in the AnimControl is caused by not baking when using the importer I could of sworn.

Does the second AnimControl have any animations in it?

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…

Id suggest you use the mixamo tutorial to learn how to make a NLA strip and export using Ogre.

You can skip the parts about mixamo.

The importer in the SDK is hard to get right. It requires baking your actions and adds extra bones for some reason. Ogre gives you more flexibility.