Animation is Null

Hello, i have made a model, it has animation, but when ever i run this :

[java]public class MainAnimationClass {



private Spatial player;

private AnimChannel channel;

private AnimControl control;

private ControlClass controller;



public MainAnimationClass(Room rm, String path, Node node, float[] coord) {

player = rm.getMainClass().getAssetManager().loadModel(path);

player.setLocalTranslation(new Vector3f(0,0,0));

player.setLocalScale(0.5f);

player.setUserData(“ID”, coord[4]);

node.attachChild(player);



controller = new ControlClass();



control = player.getControl(AnimControl.class);

control.addListener(controller);

channel = control.createChannel();

channel.setAnim(“Stand”);

}



private MainAnimationClass() {

}



public void setLocation(Vector3f vector3f) {

player.setLocalTranslation(vector3f);

}



private class ControlClass implements AnimEventListener {







public void onAnimCycleDone(AnimControl con, AnimChannel cha, String animName) {

cha.setAnim(animName, 0.50f);

channel.setLoopMode(LoopMode.Loop);

}



public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {



}

}

}[/java] It set “control” to null. This is my model : Blender Ogre or J3O

Thanks.

[java]player.getControl(AnimControl.class);[/java]

Looks like this ^ is where the control is set to null. Consequently the AnimControl class for the player spatial doesn’t exist for some reason. (If you open Spatial.java in jmonkey you’ll also see why). It could be a problem with the mesh, it could also be that you need to add a control first before being able to use it.

EDIT: you can try .getNumControls() to see if you have ANY controls attached to your spatial - if that value is zero you have no controls on it. Just to see if they exist in the first place, you know?

How to i add a controller?

You need to call the constructor of course:

[java]AnimControl t = new AnimControl(Skeleton sk);[/java]

or

[java]AnimControl t = new AnimControl();[/java]

the skeleton on the former constructor requires a skeleton type, which seem to be the equivalent to the rag doll (armature?) in blender.



I’ve never worked with Animations in jME before but I think you could make use of the following methods in AnimControl class to set up your animation:

.addAnim(Animation a)

.setSpatial(Spatial s)

Ok but how to make it control the player anim?

Ok now i have another problem : by following this tutorial : http://www.youtube.com/watch?v=NdjC9sCRV0s&feature=related

Now my models and everythng works but i can’t set the animation because it says there is no such animation, but i know there is :

[java]control = new AnimControl();

player.addControl(control);

control.addListener(controller);

channel = control.createChannel();

System.out.println(channel.getAnimationName());

channel.setAnim(“Stand”);

System.out.println(channel.getAnimationName());[/java]

This is my model : J3O or Blender

I believe if the animation loaded properly then you shouldn’t have to add your own control. However, it may not be on the node you think… you might have to search the children.



I also don’t know how well the blender loader works with animation right now. I know it’s been problematic in the past. You may want to try the ogre export route.

Ok my animation works fine, but the textures are messed up, only my pants is loaded :frowning:

Is there a way to put textures on part of a model within jMonkey?

Ok fixed, but my hands seem they arent animated. They stay at the same position when i make my character walk