I can’t get animations to work…
so heres what my rubbish blender file looks like: (its supposed to be a zombie)
its got a armature with 2 animations "walk and “standing”
this is my test code:
[xml]package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
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.Spatial;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.LoopMode;
import com.jme3.input.controls.ActionListener;
public class Main extends SimpleApplication implements ActionListener, AnimEventListener {
private AnimChannel channel;
private AnimControl control;
public Spatial Zombie;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(100);
//scene
Spatial floor = assetManager.loadModel(“Models/floor/floor.blend”);
floor.setMaterial(assetManager.loadMaterial(“Materials/testmat.j3m”));
floor.setLocalScale(10, 2, 10);
rootNode.attachChild(floor);
//light
DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
rootNode.addLight(sun);
//keys
inputManager.addMapping(“Run”, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, “Run”);
//zombieAnim
Zombie = assetManager.loadModel(“Models/Zombies/MAN.j3o”);
Zombie.setMaterial(assetManager.loadMaterial(“Materials/ZombieMatNorm.j3m”));
Zombie.setLocalTranslation(0,5f, 0f);
rootNode.attachChild(Zombie);
control = Zombie.getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
channel.setAnim(“walk”);
channel.setLoopMode(LoopMode.Loop);
}
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
//unused
}
public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {
//unused
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
public void onAction(String binding, boolean value, float tpf) {
}
} [/xml]
When i run this it wont start and i get this:
http://i1005.photobucket.com/albums/af179/SmallishSteve/Untitled.png
not sure if its a problem with my blender model or my code.
(I also tried converting the model to j3m)
also in the helloworld tutorials i got pretty confused by the line
“player = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);”
The Model is being imported as a node?
help whould be much appreciated
