Blender jme exporter in the making

EDIT: As of jME cvs version from august 18, 2007, the xml format is no longer supported by jME. Your options:


  • use another format to get from blender to jME. You can really use any format jME supports for static (not animated) models, including collada and obj.
    Morph target animation might work with md2,
    skeletal animation could work with a collada patch by fungi.

  • Convert your model to the new binary format using old jME libraries. It is unsure how long the binary format will be downwards compatible for a specific kind of scene element, so there's some risk to that. If you don't have any older jme jars and binaries, email me, I can send you a model converter complete with all required libraries included.





Hello everybody, i just started making a jme xml exporter for blender. Right now, it supports exporting multiple selected Blender Mesh Objects as separate jME Nodes, with vertex colors, and materials(with problems, see below). UV coords is not yet ready, but getting close.  (I am unsure at the moment which way to go dealing with non-shared uv-coords, i don't quite figure if i have to make different vertices for them, or if (and how) i can assign multiple TextureStates to  just one TriMesh in jMe.)
One thing that would speed up my work greatly would be a complete jme xml format specification, does such a thing exist?
Also, i would like to know if someone even cares about the blender->jme material conversion. I am not sure if i have everything right by now (jme's 'shiny' material parameter, for example: what's its range? Could it be 0.0 to 100.0, as i guess?)
Obviously, it would be quite useless to put work into figuring out the details of  proper material conversion, if nobody's ever going to use it... which might very well happen in a game engine, where mostly textures and uvcoords are all you need.

The shiny value coorresponds to GL_SHININESS in OpenGL. Which can be [0, 128].



Actually, I think material is very important for games (especially those that want dynamic lighting). Materials provide a high level of realism for models.

Ok, I must have mistaken the MaterialState’s effect on rendering textured surfaces. I thought those wouldn’t be affected at all… which is apparently wrong. So I’ll investigate further in proper material conversion. I would try Badmi’s Scene Editor, under Third Party Apps on the website, but unfortunately i keep getting a broken zip archive… and tGiant’s Scene Editor seems to dislike frequent material setting changes (crashes now and then…)

Hi



Im very excited to hear your working on a blender -> jme converter,

as we are a group working on a game, and we do all our modeling in

blender and want to use jME as the graphics engine. The material

converter would be usefull to us too :slight_smile:



If you need someone to help test the converter on some models,

then i would be more than willing to help.



Gof

Ok, I uploaded a very early version to http://wwwhomes.uni-bielefeld.de/krabien/jmestuff/. Sadly, uv coords are still not working right. The script can be run in blender either via loading it into a text window and pressing alt-p in the text window, or by copying it to blender’s scripts directory and choosing File->Export->jME XML (or Scripts->Export->jME XML, while in a script window).

Comments appreciated, remember though that this is currently a very early version.

Thx a lot.



Ive run a small test on 1 of our blender models.



It seems to work pretty well, except for the need to convert

all faces to at most 3 vertices, isn’t it possible to export those with 4

as well?

As blender seems to use those a lot if you just work with it.



Besides from that i could convert my model and load it into jME 8-O



I will continue to test it at more models, and im really looking forward to

UV support, as we use it alot.



Gof



PS: Tell me if there is something in particular you want tested :slight_smile:

I’ve updated the files (see link above), UV is apparently working now (for per-face-uvs, which are the default uv coords in Blender, as opposed to per-vertex-uvs, alsoe referred to as “sticky” texturecoords in Blender).

For materials with a valid image texture in the first texture slot, jME TextureStates will be generated. For every Material a MaterialState will be generated, unsupported Blender Objects will be exported as empty jME Nodes.

Thanks for trying it out, Gof! I am afraid I will not support quad faces anytime soon, as the faces have to be converted to triangles anyway (I don’t think jME supports quads, correct me if I’m wrong here). As triangulation in Blender is a matter of pressing “ctrl-t” in editmode, which should be easy enough to do “by hand”, I will focus on other things at the moment. The big goal is skeletal animation support, and I feel it will be a long way to go there… And one more feature very next on the list is parent-child-relations mirrored in jME as node hierarchies. So I guess those, and the bugs you probably will find during testing, will keep me busy enough right now.

At last !

Seems, the time has come for me to take a look at skeletal animation in blender :slight_smile:

"hevee" wrote:
I am afraid I will not support quad faces anytime soon, as the faces have to be converted to triangles anyway (I don't think jME supports quads, correct me if I'm wrong here).

You might want to look into com.jme.scene.CompositeMesh for quad support. It supports most of the "other" types of OpenGL geometry, including Quad and Triangle Ranges and Strips, as well as Triangle Fans.

Thanks, I’ll have a look at that soon.

Right now, I’m working at morph target animation (mta), because I have some problems with the jme JointMesh class loading from xml (look here: http://www.jmonkeyengine.com/jmeforum/viewtopic.php?p=11869, if you want to). Mta will look better, anyway, because I think jme currently doesn’t support weighted bone influences, and mta is not restricted to bones, but can handle any mesh deformation. Probably, the performance in jme will also be better, having the vertex positions precomputed for the keyframes, plus morph target animation supports vertex color and uv coords animation, as well.

Anyway, I’ve uploaded the new exporter script, check http://wwwhomes.uni-bielefeld.de/krabien/jmestuff/. The keyframes are currently auto generated every 10 frames from animation start to animation end, speed is calculated from the [Fr/sec] parameter (all in Blender’s render window buttons). An updated .blend file is there, too.

BTW, could anybody send me some decent animated blender models to test mta with? Armature deformated, vertex key animated, anything you can come up with will be appreciated. Thank you. My email: hevee at gmx dot DE

A complete list of currently availiable features follows:

Supported:

All Blender Objects can be exported to jMe Nodes with their location, rotation, and size properties and their names.

Meshes (tri- and quad faces, subSurfs) can have:

    * deformed vertex positions,
    * Materials,
    * UV-coordinates (not sticky),
    * morph target animation (by vertex keys, armature... whatever)[/list:u]
    Planned:
    hierarchies, lights, cameras, spline paths, object level animation (loc, rot, size).
    Known issues:
    Currently, animations do not loop correctly in jME. See http://www.jmonkeyengine.com/jmeforum/viewtopic.php?p=11960 for information on progress here.
    The link from my previous posts holds the updated script, plus an explanatory .blend file, as usual. Please, tell me what you think, and how it works for you!

So you like it? :smiley: Thank you for the comment! Still, I would greatly appreciate comments on output quality, and usability. Has anybody tried it yet? Please, feel free to email me, if you have any issues, comments or requests which you feel shouldn’tbe discussed here. The address is hevee at gmx dot de, and can also be found in the in-blender-help for the script (put script in blender’s scripts directory, start up blender, and go to Help->Scripts Help->jme XML).

By the way, another update: Meshes with multiple materials are supported now, as well as twosided faces, though animation does not entirely work for them right now. I am just fixing the issue, however, so by the time you read this it might be done.

Check http://wwwhomes.uni-bielefeld.de/krabien/jmestuff/.

I tried exporting the Blendo arm without bones, that one used for the Blendo tutorials. Blender fails to export the model and alerts me with this message on console:



starting export to JME XML file format...


Traceback (most recent call last):
  File "<string>" line 535, in main
  File "<string>" line 281, in writeObject
  File "<string>" line 314, in writeMesh
  File "<string>" line 161, in __init__
AttributeError: 'NoneType' object has no attribute 'getAmb'



Then I tryed a more simple mesh... a cube ;) and averythig worked.

Anyway, great job! Today I was looking for a JME XML exporter all around the Internet, till i came to JME Forum and I find it ;).

Thank you hevee :D

I have just tried another test, with a model of mine, and my opinion is: GREAT, GREAT, GREAT!!!



For now you script is exactly the thing I need. My work is at a very initial testing state so I need only mesh and material loading, but I’m sure other features are well supported and when I will try them i will be happy :wink: .



Just few minutes before to find your plugin I thought to write an exporter for Cinema 4D in COFFEE, because I don’t know Python language. Maybe I will do it! But for now yours is the right!



Really great job!



Thaks!



Bye, bye

I’m so sad I got to this late. If there’s any help you need with the XML format contact me directly via email or PM on the board. I thought I made it somewhat intuitivive, and the fact that you were actually able to use it for blender is very wonderful. That’s exactly the purpose of the XML format.



Keep it up, and let me know if you need any help.

Thanks for the feedback, everybody. I am just back from a vacation trip, and it’s nice to see that somebody has bothered to test the exporter in the meantime. Cep, nevermind for being late. I like the xml loading stuff, and yes, it is intuitive enough, but it would be just a little more comfortable to just look all the working stuff up, and find out what’s not yet there the same way, rather than trying it out by myself. If you don’t mind, please take a look at the threads http://www.jmonkeyengine.com/jmeforum/viewtopic.php?p=11960#11960 and http://www.jmonkeyengine.com/jmeforum/viewtopic.php?p=11869#11869.

Ender, could you specify where you got that arm from? Iwould like to try that out by myself.

And kam, could you send me your .blend scene, or your .xml file, so I can have a look at them? That would be a great help fixing your issue. my email can be found right below this post, in the mail button.

Hi there.

Can you please make the exporter, export to the .jme file format,

because I don,t always want to manually convert the format?

The .jme format is fast as well, and I’m sure others will agree with

me!

Thank you.

The .jme is a binary version of the XML file. It’s very java specific, and very difficult to export directly too. But being binary is why it loads so fast. Converting to it from any outside app is near imposible. The only suggestion would be to add a way to script a convert to jme call after the XML is loaded. Is there conversion from XML -> jME via the command line like there is for 3ds->jme and the others? If not, that shouldn’t be difficult to add.

Per’s drag and drop converter gui also converts xml http://pethu001.thg.se/FormatConverter.zip

Thanks for the suggestion. Cep is right, of course, saying that it would be very difficult (near impossible?) to do a .jme exporter directly in python, so I would have to run the command line converter, as he suggests. I probably won’t integrate this very soon, though, because I want the interface to be as comprehensible as possible, and I fear adding the opportunity to run external tools might confuse users. Also, I am quite busy in Real Life right now, so there’s not too much time left for this project. Currently, my plan is to leave the exporter alone until somebody finds some bugs to fix, or states that they need one of the planned features right now (hierarchies, lights, cameras, spline paths, object level animation).