Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


26. February 2014

 

Last month I wrote about creating and exporting a model from Blender to LIbGDX.  Part of the process involved exporting to FBX then running fbx-conv.  Wouldn’t it be nice if you could export directly from Blender?  Thankfully you can!  A week or so back @Dancovich told me about his Blender plugin on Twitter.  I intended to check it out right away, but truth told, recent experience had made me pretty sick of Blender, so I’ve taken my time.  Today we are going to look at that plugin.

 

First, download it from Github (direct zip download here)

Copy the folder io_scene_g3d to your Blender plugins folder.

image

In my case on my Windows 8 install, the plugin directory is: C:\Program Files\Blender Foundation\Blender\2.69\scripts\addons, like so:

image

Your location will depend on the operating system you use and how you chose to install Blender.  The github page linked above has more details.

 

Now fire up Blender 2.69 ( note, the plugin currently only supports Blender 2.69!

Select File->User Preferences

image

Then select the Addons tab

image

Now scroll down and locate Import-Export: LibGDX G3D Exporter and check it.

image

 

 

Now you are able to export directly from Blender to FBX.

 

Select File->Export->LibGDX G3D text format.

image

 

As you can see, currently there is no binary support.  During development I tend to stick with g3dj anyway.

 

Here is the scene from Blender:

image

 

And now that I run it in LibGDX?

image

 

Ahhh, crap.  It’s an easy enough problem though.  The exporter saved my texture as an absolute path, I instead want a relative path.  Opening up the generated g3dj file, I see:

image

Change that to:

image

And you are good to go.  You can probably change Blender to work in relative paths and avoid this problem all together.  If not, altering the script to strip the paths should be a no brainer.  Now with that change we run it and:

image

Hmmmm… that’s not what you were expecting is it?  What’s going on here?

 

Well, fbx-conv automatically flips the axis from Blender Z up to LibGDX Y up.  This exporter does not.  You can easily perform the same thing in code by rotating –90 degrees about the X axis, like:

modelInstance.transform.rotate(1, 0, 0, -90);

 

Then run the code and:

 

image

 

Woot, identical to Blender!

 

I havent got the chance to test the exporter all that extensively, Ive not really done any work with Blender in the last week or so, so I cant really tell you how well it performs with animations.  That said, especially during development, this could be a huge time saver for quick iterations.  The developer is actively looking for people to try it out and report bugs back.  So if you fancy exporting from Blender to LibGDX directly try it out and let @Dancovich on Twitter know if you encounter any bugs.

Programming, Art , ,

blog comments powered by Disqus

Month List

Popular Comments