Convert to j3o doesn't include animations anymore

Hi,

I’v always relied on the same code to convert my models from xml to j3o. (code at bottom)
But now it has stopped working… I only get the mesh, no animations are able to run. It leaves no error when trying to run an animation either.
I know it’s only this model thats causing the problem because I still have the old character.j3o left and it works if I use that one instead of the new one.

I recently started using blender 2.6 instead of 2.49 and I just got the export OGRE working. I looked into the character.mesh.xml and character.skeleton.xml and found no defects. They look as they’ve always looked as far as I can see. It does however export two more files: character.mesh and character.skeleton (no xml in the end).

Here is my convert code:

[java]
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.jme3.app.SimpleApplication;
import com.jme3.asset.plugins.FileLocator;
import com.jme3.export.binary.BinaryExporter;
import com.jme3.scene.Spatial;

public class MainClass extends SimpleApplication{

public static void main(String[] args){
	new MainClass().start();
}

public MainClass(){
	Logger.getLogger("").setLevel(Level.OFF);
	this.showSettings = false;
}

private static String source = "C:/Users/Andreas/Desktop/EXPORT/";
File folder = new File(source);


private static String name = "character"; 

@Override
public void simpleInitApp() {
	assetManager.registerLocator(MainClass.source, FileLocator.class.getName());
	if (name != null){
		Spatial model = assetManager.loadModel(name+".mesh.xml");
		BinaryExporter ex = BinaryExporter.getInstance();
		File f = new File(source+name+".j3o");
		try {
			ex.save(model, f);
			System.out.println("------------------------------------");
			System.out.println("File "+name+" was successfully converted to j3o.");
			System.out.println("Path to j3o: "+source+name+".j3o");
			System.out.println("------------------------------------");
			this.stop();
		} catch (IOException e) {
			e.printStackTrace();
		}
	} else {
		String[] list = getContent();
		for (String name : list) {
			if (name != null) {
				
				try {
					Spatial model = assetManager.loadModel(name);
					BinaryExporter ex = BinaryExporter.getInstance();
					File f = new File(source+name+".j3o");
					ex.save(model, f);
					System.out.println("------------------------------------");
					System.out.println("File "+name+" was successfully converted to j3o.");
					System.out.println("Path to j3o: "+source+name+".j3o");
					System.out.println("------------------------------------");
					this.stop();
				} catch (IOException e) {
					System.out.println("------------------------------------");
					System.out.println("File "+name+" was NOT converted to j3o.");
					System.out.println("Path to file: "+source+name);
					System.out.println("------------------------------------");
				}
			}
		}
	}
	
}


public String[] getContent(){
	File[] listOfFiles = folder.listFiles();
	String[] list = new String[listOfFiles.length];
	for (int i = 0; i < listOfFiles.length; i++) {
	      if (listOfFiles[i].isFile()) {
	    	if (listOfFiles[i].getName().endsWith(".mesh.xml")) {
	    		 System.out.println("File " + listOfFiles[i].getName());
			        list[i] = listOfFiles[i].getName();
	    	} else {
	    		System.out.println("NOT mesh.xml File " + listOfFiles[i].getName());
	    		list[i] = null;
	    	}
	       
	      } else if (listOfFiles[i].isDirectory()) {
	        System.out.println("Directory " + listOfFiles[i].getName());
	        list[i] = null;
	      }
	    }
	return list;
}

}[/java]

All help appreciated.

not exactly your problem, but have you tried to load the blend file directly, i found the blender importer to work generally more reliable.

Never tried that… It works with android aswell?
I could try that incase I can’t fix this…

It’s recommended to use j3o files. In fact unless you tweak the build some other file types aren’t even included…

Yes load the blend similar to the ogre.xl and save the resulting j3o, at least for my models the animations work.

as long as your not using Blender’s plethora of constraints, the blender importer should work

Well, now I’v manage to export the models with animations using OGRE.
Problem is, the animation length is wrong. Walk animation is double the length of run animation and I don’t know how to fix that…
I used to be able to add each animation by themselves and set their resp. time limit. Now I can’t even see the animations that I’m exporting… Anyone else use 2.6 that knows more about this matter?

i use blender 2.6 with this script https://bitbucket.org/MindCalamity/blender2ogre-exporter/src and it works pretty well.
You have to make sure your NLA tracks are correctly setup though. There must be one track for each animation and no overlap between animations.
Here is how I setup my tracks an it works fine

1 Like

Nice, now the animations sort of work.
I’m still using ogre, but I got the run and stand animation to work. Except when you “stand” one frame in each cycle it glitches over to another animation. I believe it jumps straight into one frame in the run animation but im not sure. All I know is that the character lags, sort of change pose drasticly for a millisecond.
Heres my setup:

The marked extrapol field I marked in paint because I’v disabled it for some of the animations but it didn’t solve the glitching.

Any ideas why this glitching occures?

don’t leave any frame between the animation in the NLA track.
for example, if my fist anim ends at frame 30 then next one starts at frame 31. Don’t leave any gaps

2 Likes

Thanks man! :smiley: Now it works without the glitching!
Thanks alot! :slight_smile: