Can't import keyframed model from blender

I've been using the Blender exporter to shift my model to XML format and then importing it into JMe. Having established that I could do that I moved on to try and make the model a bit better ( and knock it down from approximately 100000000000 triangles to something more manageable ) which I've now done. Unfortunately I was foolish enough to download a more recent version of the blender exporter and when I tried to load my new, more economical, model, I got this:


java.lang.NullPointerException
        at com.jmex.model.animation.KeyframeController.setKeyframe(Unknown Source)
        at com.jmex.model.XMLparser.JmeBinaryReader.readEnd(Unknown Source)
        at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
        at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
        at jmetest.Main.simpleInitGame(Main.java:71)
        at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
        at com.jme.app.BaseGame.start(Unknown Source)
        at jmetest.Main.main(Main.java:45)

I thought maybe the problem was that having been working elsewhere for a few months, I might need a newer jme so I put myself through a few hours of version hell trying to get the latest binary version of jme working with the latest binary version of lwjgl. At the end of it I still had the same error.

The code I'm using looks like this:


     FileInputStream myFile=new FileInputStream("charwalk.xml");
      BufferedInputStream buff=new BufferedInputStream(myFile);
      XMLtoBinary bin =new XMLtoBinary();
      ByteArrayOutputStream binOut = new ByteArrayOutputStream();
      bin.sendXMLtoBinary(buff, binOut);
      JmeBinaryReader jbr=new JmeBinaryReader();
      Node mychar=jbr.loadBinaryFormat(new ByteArrayInputStream(binOut.toByteArray()));


The error is falling in the last line there.

Any wisdom?

use BinaryImporter instead

Hmmmm.


Main.java:21: package com.jme.util.export.binary does not exist

Which Jar file should it be in?

I should, of course, have read the documentation.



Unfortunately that does leave me with a new problem in that my models appear to load (except the keyframed one, which suggests a loader problem rather than an importer one, but who knows?) but then the whole thing does this:


java.lang.NullPointerException
        at com.jme.renderer.lwjgl.LWJGLRenderer.draw(Unknown Source)
        at com.jme.scene.TriMesh.draw(Unknown Source)
        at com.jme.scene.Spatial.onDraw(Unknown Source)
        at com.jme.scene.Node.draw(Unknown Source)
        at com.jme.scene.Spatial.onDraw(Unknown Source)
        at com.jme.scene.Node.draw(Unknown Source)
        at com.jme.scene.Spatial.onDraw(Unknown Source)
        at com.jme.scene.Node.draw(Unknown Source)
        at com.jme.scene.Spatial.onDraw(Unknown Source)
        at com.jme.renderer.lwjgl.LWJGLRenderer.draw(Unknown Source)
        at com.jme.app.SimpleGame.render(Unknown Source)
        at com.jme.app.BaseGame.start(Unknown Source)
        at jmetest.Main.main(Main.java:47)


I'm pretty sure everything I've got is current now...

Any guesses what this is? Is the Blender exporter badly broken? What model format should I be using instead?

I don't know about any current bugs in the blender exporter preventing keyframe animation. Could you send me the .blend file, and maybe the exported .xml too? Maybe that will help me identify your problem. I don't know of any other formats blender exports with keyframe or skeletal animation that jME supports out of the box right now. There is some effort going on with cal3d, and md5, but I am not quite sure if any of those is usable yet without some major tweaking. Blender's collada exporter still doesn't support animations, AFAIK, otherwise that would probably be the best option, with mojo currently developing and maintaining the jME collada module.

Thanks for this, I'll send them through (although they are a little bit chunky, maybe I'll just put them somewhere you can download them easily and post you a link) - the models were working with the old approach to loading them in on the previous version of jME, so it may be something about the way the new file importers work that is causing the problem rather than the exporter.

(PM sent)

I found the source of your problem. You have two material groups in your model, yet one of them is not assigned to any vertices/faces in the mesh. So the xml exporter creates an empty mesh from it, and the old binary loader crashes with an npe, because the vertex buffer of the target mesh is not existing.

You can work around this special issue by not having different material groups in your model. However, that pointed me to a larger problem. It is, with the current architecture of the exporter, not possible to have more than one material group at all in your model when exporting animations. Thus I linked to this post from the original blender exporter thread, to make this some kind of "official" known bug report. I seriously have no idea how to fix this in a reasonable amount of time, so for now, I'll just put up a warning message instead.

@mcbeth



I thought the BinaryImporter is not working with XML yet? And you have to use the old BinaryRader, haven't you?

Avayxn, you are perfectly right. Sorry for not pointing that out earlier. See http://www.jmonkeyengine.com/jmeforum/index.php?topic=3928.msg31531#msg31531 for details.

I found the source of your problem. You have two material groups in your model, yet one of them is not assigned to any vertices/faces in the mesh.

I do? Right, I'll sort that out.

How confusing of me...
I thought the BinaryImporter is not working with XML yet? And you have to use the old BinaryRader, haven't you?

I do? Right, I'll sort that out too...

Thanks for the help guys, it's really appreciated. I'll try and pay it forward when I stop being such a total nub...
Avayxn said:

@mcbeth

I thought the BinaryImporter is not working with XML yet? And you have to use the old BinaryRader, haven't you?


sorry dont do much with xml...............yet anyway sorry for the misinform.

brrn thinking about spitting a waterfall out of blender with that but multi- materials seems a big issue ........hmmm :? :'(

Got it working! I've even got the keyframe animation and the texture on there.



The animation is hella-slow, though- any ideas how I can make it run through those keyframes any quicker…



(edit: Fixed it, I just went through the xml file and just changed time="20" to time="0.2" and so on for each keyframe and that seems to have done the trick)



Interestingly, if I look at the model that was exported without animation it is oriented differently to the one that was exported with animation. The one imported with animation is oriented correctly (for what I want) although whether I made the model the wrong way up I honestly couldn't say!