Jmonkey blender animation sample

tags: .blend, .j3o, blender import, chanel, null pointer exception

package sample;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

 * Load and animate blender model jmonkey
 * @author Padaboo I.B. Aleksandrov

public class BlenderModelSample extends SimpleApplication {
    //animation channel
    private AnimChannel channel;
    //animation control
    private AnimControl control;
    public static void main(String[] args) {
    	BlenderModelSample app = new BlenderModelSample();
    public void simpleInitApp() {
        //add light
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
        dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
        //load spatial
        Spatial player = (Spatial) assetManager.loadModel("Models/human.j3o");
        //attach to root node
        player.setMaterial( assetManager.loadMaterial("Materials/humanmaterial.j3m"));
        //add player to child node

        //cast to node
        Node playerNode = (Node)player;
        //get child (model scene mesh)
        //tree: human.j3o -> armature -> Plane
        control = playerNode.getChild("Plane").getControl(AnimControl.class);
        //create chanel
        channel = control.createChannel();
        //set animation walk

Please provide some log .

I guess the null pointer is at control:

Make sure Node “Plane” has AnimControl on it.

In below example if i want to get control i need to get it from node “Kachujin”. if i get it from other node it will cause null error.


can you upload your model “golova.j3o” to somewhere so i take a look at it ?

ok assets


Please rename golova.j3o to human.j3o in your code.

Fixed. :smile: