Importing Blender models using ANT

My project has a number of Blender models which need to be converted to J3O files and moved to assets/Models every time I build the project from scratch. Currently I do these individually, using the SDK. This is tedious and error-prone.

I imagine there must be a way to automate the import of Blender models using an Ant build file. How could I set up such automation?

Why not right-click the mesh.xml file > convert to j3o and be done with it?

@t0neg0d: That’s more or less what I’m doing currently, though it’s a 3-step process for me, not a 1-step process. The reason is that, in accord with best practices, my Blender files are in assets/Textures, so there’s also a cut-and-paste operation to relocate the imported J3O file to assets/Models.

Because I’m developing a game, I’m never “done with it”. I redo the process every time the model changes and every time I rebuild the project from scratch. On a redo I also have to delete the old J3O file, making it a 4-step process.

My game project currently has 29 Blender models, and I expect to add many more before it’s complete.

Every time I do the 3-step process 29 times in succession, I wonder if I could automate it.

Write yourself a compiler, using the binaryexporter and a headless jme application.

load blend
do whatever for textures ect
export with binary exporter

1 Like

Your blender files don’t need to be in the Textures folder, just the textures when you apply them in blender. So that the paths are right in the blender file too. Then, when you converted your model the 3.0 SDK should pick up changes in the blend file as well and be able to re-import at least the mesh changes. So in the worst case it should just be one right-click operation on the blend file, in the best case just pressing “OK” once.

That sounds doable.

And since it would be custom Java code, it could loop over my project’s files, avoiding the need to customize the Ant build file.

Thank you, Phoenix!

@normen: the wiki seems to indicate that original models should be stored under assets/Textures. Do you know the reason for this?

@sgold said: @normen: the wiki seems to indicate that original models should be stored under assets/Textures. Do you know the reason for this?
It should say "import" really, fixed that. That applies when you *import* models incl. textures, so that the textures get imported to the "Textures" folder. You can move the created .j3o file into the "Models" or another folder after importing. When you create the model from scratch and already have the textures in the "Textures" folder everything is fine and you can place the .blend file anywhere you want the final j3o to be.

When you export OgreXML files from an editor or example the exporters will always put the textures in a folder along with the model. When importing these the AssetManager really only knows about the relative location and will put it in the same relative location in the project. So when you import into the “Models” folder it will put the textures there.

1 Like

Okay, normen, that makes sense. I’ll relocate my Blender models and see if the SDK re-imports them on update as advertised.