jME and Blender: The age-old question

I know this question has been asked many times, as I've been checking this site and searching for the past year or so, but a lot has changed since then…I've reread the same threads and tried examples with the deprecated loader multiple times (I can't remember the class name anymore).  Now that I'm looking at some very good examples from cvs with what it seems has what I need, I can't seem to find out how to get from Blender to jME properly!



My main showstopper for quite a while has been getting my animated models from Blender to jME, and I really don't have a preference on any single format, but I have been reading about md5 and Collada around here.  It looks like Collada would be the way to go, from what I've seen in the example in jmetest, but getting the model+anim from Blender properly is the issue.  I basically want to be able to create a bunch of animations for models (walking, jumping, for example) and export, and call when needed.



I hope this isn't so redundant, but if it is, can someone please point me to the proper resource/thread?  Thank you very much!

Alrighty…

have you seen this? http://www.jmonkeyengine.com/wiki/doku.php?id=exporting_animated_.md5_models_from_blender

Yes, but I was unsure as to if that was the best way, and if anyone has successfully gone Blender->Collada->jME with animations yet.



Thank you for that tutorial, by the way!  I'm actually seeing about using it right now.

With the tutorial, you should specify that you have to "add both kproject-md5/src  and  kproject-md5/src-jme".  I checked the source out to the repo and it doesn't compile by default: there is a usage error in MD5JmeAnimation's update() method, calling for the batch index of the "setVertexBuffer" method being called.  I specified it as 0 on my local copy to simply get it compiled.



When the test runs, nothing is displayed.  To fix this I had to add in the "kproject-md5/data" folder, and then edit the build path for the folder to simply be called "data" (probably arises because I use different folders for source and binary files, and my Eclipse executes from the root of the project path).





EDIT:  I hope you don't mind, but I went ahead and modified the tutorial to include my above issues.

the ColladaImporter only does boneanimations, is that all you need?

Just a quick overview of the information shattered across the board:



  • The blender collada exporter does not export skeletal animations, nor vertex animations. Also, it's development seems to have stopped some time last year.
    md5 is probably closest to the architecture you desire, with the concept of having different "animations" to choose from.

  • the blender -> jme xml exporter uses the deprecated xml format, which still works, and probably won't break anytime soon. It can only export morph target (vertex) animation ala Quake(1-3), no bones. In my experience, it is the easiest way to go blender->jme with animations, but that might be just me, because I made the exporter the way I wanted it.

  • I guess unless somebody feels like reviving the cal3d loader, that format can be ruled out, because it apparently has been cancelled by it's creator. Also, cal3d blender exporers all suffer from different quirks.

  • from the blender point of view, md5 is definitely the way to go. The md5 exporter is by the jugement of most people involved in blender export plugin development the best exporter that has been made so far.



hth

i was unsatisfied with md5 and their node, animation and bone api(being that it is all non standard with jme) so i've been working on collada and ColladaImporter for that last few months off and on, their are still somethings i need to work out but if i avoid those issues i can export and import a bone animation properly.



The changes are really very minor, finding them was the problem, considering i don't know python or blender's api.

Wow, that's great news!

Awesome. Could you post the details, or an example, on how to get it working somewhere? (Wiki?)

Export options: I use “triangle”, “bake matrices”, “sample animations”, “disable physics”, “only current scene”, “use relative paths”, and “use UV image”, thats all the available options except “only export selection” and “polygons”.



The Blender Plug-in nor BoneAnimation support Breizer curve interpolations so use the option “sample animation”



Don’t use a number at the beginning of the bone name, and don’t use “.” in the name, their may be other naming frailties too.



make sure that if you use rotation ipo curves for a bone that you also make translation ipo curves for that bone.

Without the translation curves the import uses zeros in the transformation matrix, so your translation vector would be 0,0,0.





ColladaImporter:

http://myfreefilehosting.com/f/76c4a6b295_0.13MB



Translator.py

http://myfreefilehosting.com/f/ff5b0141fc_0.12MB

Collada.py

http://myfreefilehosting.com/f/70f2ed2db6_0.11MB



rename the existing files so that you can easily switch back to them if you need them

replace the existing files with these files

the python files should go in C:Program FilesBlender FoundationBlender.blenderscriptsbpymodulescolladaImEx

Colladaimporter can go anywhere in your project, it doesn’t have to go in the com.jmex.model.collada package

What ColladaImporter changes did you have to make? If you can provide me with a diff I should be able to merge it into the head.

there are still lots of debugging outputs all over it, when i'm finished i'll give you the changes

Excellent stuff :slight_smile:



On the exporter side, have you been in touch with blender/illusoft people to get the changes into the official exporter?

no.

i've been reporting all the bugs i've found to illusoft's bugtracker but i haven't posted any of my changes.

Awesome.  I created a simple test model in Blender with an animation, exported, and plugged it into the existing test without any problems.



Now I need to figure out how that test works (and more on jME's workings, of course) to be able to use it.  So far I assume I need to extend the MD5JmeAnimation class and override the update method…or just create my own Controller that deals with a model with multiple animations on one model.



Very cool!  Glad to be up and running!  :smiley:



Thanks again!  I'll be around.

Revisiting this, it seems that the exporter may be adding extra vertices, so be aware of that possibility if you use it.  My model should only have a 868 vertices, but has (amusingly) 3,456.  The number of triangles is correct, but there are 2,588 extra vertices!



Not sure…need to figure it out, because it will be a problem when I add more than just one model to the scene…



Anyone else with the same problem?

It seems that this has to do with not having smooth normals and not having a continuous UVMap.



Be sure to Wkey->Set Smooth, and when you UVMap make it continuous, or else extra vertices are added.  It doesn't seem to affect the quality of the model, but sure could affect performance with extra vertices.  Just setting smooth lowered my vertices to 1166 vs 868, as opposed to 3456 vs 868!

collada exporter or md5?

der_ton's MD5 exporter.

Illusoft has released an update to their blender plug-in.

http://colladablender.illusoft.com/cms/content/blogcategory/25/29/

However their are still problems, so the SVN version is the best bit on the most up to date fixes(which their were a few after I tested their code)

Bad news is that it still wont work with jme since it doesn’t export interpolated animation data, nor sampled animation data.

nightst4r has been working very hard on fixing a lot of those bug reports that were stacking up in the Bug Tracker.



Note: even when they get lack of animation data fixed the modified ColladaImporter will still be needed.