Ogre animation problem

Hi.

I’m loading ogre models with animations and after that I’m loading other ogre model without animation. All my models without materials. Here my application throws exception

[java]

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.NullPointerException

at com.jme3.animation.AnimControl.resetToBind(AnimControl.java:304)

at com.jme3.animation.AnimControl.reset(AnimControl.java:293)

at com.jme3.animation.AnimControl.(AnimControl.java:122)

at com.jme3.scene.plugins.ogre.MeshLoader.compileModel(MeshLoader.java:712)

at com.jme3.scene.plugins.ogre.MeshLoader.load(MeshLoader.java:758)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:233)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:355)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:365)

at initial.MyAnimationTest.simpleInitApp(MyAnimationTest.java:33)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:187)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:134)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:183)

at java.lang.Thread.run(Unknown Source)



[/java]

but when I load animated models in the end, everything goes fine. I think it shouldn’t be like this. Did I do something wrong?

Take a print screen in the moment of exportation and upload here. Do do :



show your class’s source code and your mesh.xml’s source code for us to see.

If you are exporting meshes with textures i advise you to export them already with its materials, because the mesh’s uv texturemap need of the material’s informations.

Source code

[java]

package initial;



import com.jme3.animation.AnimChannel;

import com.jme3.animation.AnimControl;

import com.jme3.animation.AnimEventListener;

import com.jme3.app.SimpleApplication;

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;



public class MyAnimationTest extends SimpleApplication implements AnimEventListener{



AnimChannel channel;

AnimControl control;



public MyAnimationTest(){}



public void simpleInitApp(){

Spatial headModel = assetManager.loadModel(“refs/barrel.mesh.xml”); //animated model

Spatial bodyModel = assetManager.loadModel(“refs/body.mesh.xml”);//not animated model



Node node = new Node(“node”);

node.attachChild(headModel);

node.attachChild(bodyModel);

rootNode.attachChild(node);



rootNode.attachChild(barrelModel);



control = headModel.getControl(AnimControl.class);

control.addListener(this);

channel = control.createChannel();

channel.setAnim(“stand”);



DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(1, 0, -2).normalizeLocal());

sun.setColor(ColorRGBA.White);

rootNode.addLight(sun);

}



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



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



public static void main(String args[]){

new MyAnimationTest().start();

}

}

[/java]

barrel mesh

[xml]







































































































































































































































































































[/xml]

Hmmm…

I think forum can’t view xml files. Where can I upload my ogre file?

If you are using bones for the mesh’s animation, must be as shown.

I did the same as did here, except that i didn’t export material.

I just didn’t got it why you wrote this line :

rootNode.attachChild(barrelModel);

at line 29.

well, but it doesn’t matter. Do you can open your mesh.xml with the notepad and show me the animation’s lines?

Oh, skip 29th line.

I copy-paste code 7 posts before, but this forum can’t show it.

I’ll try an image.

Guy, the problem is that your Mesh Animation’s Name’s “Action” and not “stand”, see yourself at line :



set it to “stand” :slight_smile: .

And i know the cause of can’t to post the mesh’s surce code. The problem is that the words can’t be between “< >”. :slight_smile:

sorry, between the signals of major and minor. :slight_smile:

Actually my app stops at line 22, it doesn’t go further. x )

Sorry, I had to say it before. But if I swap lines 22 and 21 it works (assuming that line 34 is channel.setAnim(“Action”);). The problem in the order if this two lines.

It sounds like a bug in the importer. Could you please provide the OgreXML model files that cause this issue?

I don’t know how should I send it to you.

I’ve tried models from testdata and got the same error.

[java]

import com.jme3.app.SimpleApplication;

import com.jme3.light.DirectionalLight;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Spatial;



public class MyAnimationTest extends SimpleApplication{



public MyAnimationTest(){}



public void simpleInitApp(){

Spatial oto = assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);

Spatial head = assetManager.loadModel(“Models/MonkeyHead/MonkeyHead.mesh.xml”);



rootNode.attachChild(oto);

head.move(0, 5f, 0);

rootNode.attachChild(head);



DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(1, 0, -2).normalizeLocal());

sun.setColor(ColorRGBA.White);

rootNode.addLight(sun);

}



public static void main(String args[]){

new MyAnimationTest().start();

}

}



[/java]

Guy, do you are using Eclipse OK? I don’t like eclipse, because i found many bugs on it. Why don’t you use the JMonkey Plataform or the Netbeans Plataform?

Greetings.

You mean, you found bugs on eclipse itself or bugs related to jME3 on eclipse? I haven’t found any bugs yet in eclipse.

I tried Netbeans some years ago, it’s wasn’t better than eclipse. Eclipse is more usual for me. x )