Blender exporter

454 views
Skip to first unread message

reat...@gmail.com

unread,
Jul 11, 2013, 6:56:15 PM7/11/13
to urh...@googlegroups.com
Hello,

I've written an exporter for Blender. It is a simpler alternative to, but not as complete nor stable as the Ogre exporter.
It can export meshes, armatures and actions (also "shapes/morphs" but not tested at all).
I'm still new to Blender APIs and Python, so expect some big bugs. Make backups and use it at your own risk.
Tested on Blender 2.66a (knowing Blender fast APIs changes it is going to break soon). Licensed as public domain.
It is based on "Export Inter-Quake Model" by Lee Salzman and "bXporter" by Luis F. Loureiro.

Some installation instructions:
> extract the folder 'io_mesh_urho' from the zip to the blender scripts/addons folder:
Windows 7 - C:\Users\%username%\AppData\Roaming\Blender Foundation\Blender\2.5x\scripts\addons
Windows XP - C:\Documents and Settings\%username%\Application Data\Blender Foundation\Blender\2.5x\scripts\addons
Linux - /home/$user/.config/blender/$version/scripts/addons

> start Blender

> enable the addon: menu File > User preferences > Addons > Import-Export > Urho3D export (tick the checkbox on the right)
> if you can't check the box, search the console for errors (menu Window > toggle System Console)

> you'll find a new panel in Render page (at the bottom) of the Properties window
I hope it is easy to use, I'll write a better guide.

To merge LODs, name LOD objects with the schema "<name> LOD <distance>", for example: head LOD 0.0, head LOD 10.0 ...

Keep the console open, if the script gets stuck or it is too slow, you can interrupt it by pressing Ctrl+C.

Suggestions, requests, bug reports are welcome.


io_mesh_urho.zip

Paweł Mogiła

unread,
Jul 12, 2013, 3:11:29 AM7/12/13
to urh...@googlegroups.com
Wow. that's really cool. Thanks.
I tested it with some object and... mesh, skeleton, multiple animations (saved as actions) works great.
The only thing I noticed is that exported animation played in urho looks different than in blender(2.67).
In urho animation is smoother than it should be, it affects vertices(associated to previous bone) that shouldn't be transformed.
But maybe I used the exporter incorrectly. Here is blender file, so you can try yourself
test.blend

reat...@gmail.com

unread,
Jul 12, 2013, 11:09:22 AM7/12/13
to urh...@googlegroups.com

Hello Pawel, thanks for testing it.

It seems your armature is not at the origin. Location and Rotation of the armature and mesh should be 0,0,0 (probably I should add a warning for this).
You can apply (reset) the location by doing this:
> in 'Object mode' select the armature
> Ctrl+A
> select Location
> repeat selecting the mesh
Hope this helps.
A note, your mesh is '-X' up, for now in the exporter you can't set the up axis, so you have to manually rotate it (if you do it in Blender remember to Apply the rotation).

Paweł Mogiła

unread,
Jul 13, 2013, 3:56:22 AM7/13/13
to urh...@googlegroups.com
Hi,
thanks for the blender trick with resetting location. Now skeleton animations play as expected.
I also tested the exporter for morphs but exporter failed because of:

Traceback (most recent call last):
"export_urho.py", line 116, in __init__
self.color = tVertex.color       
AttributeError: 'TMorphVertex' object has no attribute 'color'
location: <unknown location>:-1

Not sure if this was proper way to fix it but I just added color attribute into TMorphVertex and then it worked.
I loaded the exported model with shape keys in urho and it blends nicely between specified shapes when calling SetMorphWeight to some value between <0,1>. Thank you for such elegant and user friendly exporter, it's really cool. 
Here is the exporter with mentioned above one line modification:

io_mesh_urho.zip

Lasse Öörni

unread,
Jul 13, 2013, 8:10:24 AM7/13/13
to urh...@googlegroups.com
Seems like very nice work! Unfortunately I did not get it to work on Blender 2.67: I can activate the addon, but it doesn't show up in the File menu -> Export; Python console has error

File "C:\Program Files (x86)\Blender Foundation\Blender\2.67\scripts\addons\io_mesh_urho\__init__.py", line 567, in register listHandler.setFormatter(formatter)
NameError: global name 'formatter' is not defined

Paweł Mogiła

unread,
Jul 13, 2013, 8:40:36 AM7/13/13
to urh...@googlegroups.com
it shows up for me (blender 2.67) not in file->export but under render tab http://wiki.blender.org/uploads/c/ce/Extensions-Render-picogen-render_tab.png

reat...@gmail.com

unread,
Jul 13, 2013, 11:26:43 AM7/13/13
to urh...@googlegroups.com
Thanks Pawel for the patch, that should fix it.

Lasse, I cannot reproduce your error, but maybe adding:
    global formatter
    global consoleFilter

at lines 549 and 550 of __init__.py can help. I'm puzzled, not assigned variables should be global, even if used as parameters, maybe it is related to register() called in another scope.. Please wait, I'll investigate it.
I really ashamed to not have credited you in the urho script, it is a messed up copy of the OgreImporter. So unforgivable of me, it'll be surely done in the next version.

I've just discovered I cannot edit my first post (as a newsgroup this makes sense). The script is a WIP undocumented and not fully tested, so when it becomes stable I'll do another post with a production ready script.

I've to make some clarifications:
- if you use LODs objects, when you put the distance in the name keep the same number of digits using leading zeros;
- when exporting armatures the important thing is that the origin (orange dot) of the mesh and the origin of the armature have the same location and rotation,
it is not necessary to be at 0,0,0 if you use the option "Origin=Local", but then again, it surely helps to avoid bugs.

reat...@gmail.com

unread,
Jul 13, 2013, 6:47:28 PM7/13/13
to urh...@googlegroups.com

Lasse, I was able to catch it. The first time you click the checkbox to enable the addon you see the error, but clicking again you should read "Urho exporter register" with no errors following, now the addon panel should be visible, if you haven't changed the Blender start-up file try scrolling down the bottom-right window.

Sinan

unread,
Jul 15, 2013, 11:55:02 AM7/15/13
to urh...@googlegroups.com
I can confirm that this plug-in works for Blender 2.68 RC1. I have only tested model exporting so far, no animation testing done.

Mike Nelson

unread,
Jul 15, 2013, 5:46:03 PM7/15/13
to urh...@googlegroups.com
I tried the exporter on a test model. The mesh is a mess, fractured into many individual quads. Am I doing something wrong?

WHAT.blend
WHAT.png

Paweł Mogiła

unread,
Jul 16, 2013, 11:02:30 AM7/16/13
to urh...@googlegroups.com
Looks like I found some issue with the most basic things - materials and textures which aren't exported.

in exporter there is a check:
if not material.name or not material.imageName:
and material.imageName i always None. I tried to investigate more and looks like problem is located in decompose.py in material section, where faceUv.image.name is also None. Is there maybe other way to get texture name?

reat...@gmail.com

unread,
Jul 16, 2013, 3:10:43 PM7/16/13
to urh...@googlegroups.com

Mike, I tried exporting only the geometry without skeleton and the mesh looked ok for me, but with the skeleton there was a big offset from the origin. I removed the armature modifier and applied it in the old way: with armature in rest pose, hold shift, select mesh then armature, Ctrl+P, select "Armature deform with automatic weights". Keeping the skeleton in "Rest position" (but this is a problem for me to solve) I exported the mesh+skeleton and it was ok. Next for the animations, to make them works I had to parent the neck and shoulders bones to the torso bone (again this needs a check).

Pawel, does this problem persist if you save your image as a file?

Paweł Mogiła

unread,
Jul 16, 2013, 4:34:57 PM7/16/13
to urh...@googlegroups.com
yes, texture is saved as file.
I don't know why but material export worked when I unwrapped mesh via smart UV project. Simple unwrap doesn't work with no seam specified (with one seam works). In all cases mesh renders correctly in blender. Another thing is that material exported values e.g. specular value always "0.0 0.0 0.0 1.0", no normal map export etc. But these are not so important things since I can just edit the material manually. The most important are geometry, animations and morphs, which works flawlessly

Chris Friesen

unread,
Sep 1, 2013, 8:23:09 PM9/1/13
to urh...@googlegroups.com
This plugin is pretty cool.  It isn't worked with blenders grouped objects. 

http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Objects/Groups_and_Parenting#Grouping_objects

Thanks,
Chris

reat...@gmail.com

unread,
Sep 2, 2013, 2:27:56 PM9/2/13
to urh...@googlegroups.com

Hello Chris, what don't work ? Is it a python error ? Can you post a .blend file ?

Chris Friesen

unread,
Sep 2, 2013, 7:32:29 PM9/2/13
to urh...@googlegroups.com
I had a miscommunication with the person i am working with.  I don't know if it falls under the responisbility of the plugin.  I think making a seperate plugin for a scene export is a better fit.  Sorry for rasing the flag.  Getting the first 80% of the progress in blender for scene composition would be a nice workflow for us.  I will probably take a stab at something in the coming months.

Thanks,
Chris

reat...@gmail.com

unread,
Sep 5, 2013, 12:55:29 PM9/5/13
to urh...@googlegroups.com
This is version 0.3 of the exporter. I have done some cleanup, fixed the bugs in the addon registration and the indices sequence optimization is faster.
io_mesh_urho_v0.3.zip

Chris Friesen

unread,
Sep 5, 2013, 1:07:59 PM9/5/13
to urh...@googlegroups.com
I love this plugin.  Thanks for sharing!

Lasse Öörni

unread,
Sep 5, 2013, 3:39:10 PM9/5/13
to urh...@googlegroups.com
This is sweet, this version installed flawlessly to Blender 2.67. I could add this to Urho SVN repository Extras folder, would that be OK?

reat...@gmail.com

unread,
Sep 6, 2013, 2:58:03 PM9/6/13
to urh...@googlegroups.com
Thanks.
Sure it is ok, you can add it. I hope it is good and stable enough. I'm still working on it, like working more on animation and trying UV2.
Feedback is always welcome!

Chris Friesen

unread,
Sep 7, 2013, 4:05:00 AM9/7/13
to urh...@googlegroups.com
I may have found a bug.  

Using Blender 2.68a 64bit Windows

The armature loads well.  The mesh loads well.  It looks like the weights are kind of funny.  I don't think there is anything too out of the ordinary.  The work is mostly clean, simple, and minimal; being said don't worry about telling me i am dumb.

Here is a pic.  I have also attached a blend file.  You can see that the arms are mutaliated and the left foot isn't quite following the  bones.
 

Thanks,
Chris
soldier.blend

reat...@gmail.com

unread,
Sep 7, 2013, 8:43:07 AM9/7/13
to urh...@googlegroups.com

I get different results (Blender 2.68a 32bits): if I try to export the model with weights, I get this obscure message:
  "Incompatible vertex element mask in object jacket.002 (038B AND 008B = 008B)"
This means some vertices don't have weights (which have bit mask 0300... not user friendly I guess), so the weight elements are removed from every vertex, and this is no good.
To resolve this kind of issues I added the option 'Force missing elements', but obviously it is bugged. There is a stupid error easily fixable, but I'd better review the whole thing.

Rotating the 'spine' bone I've seen the vertices not weighted: the right eye of the soldier (which has inverted normals, I think) and an arc in the back of the head. I've paint weighted them to the 'head' bone. Exported model+skeleton+weights and the walking animation (so slow...), and everything was good in the Urho editor (I'm still using the old 1.23 editor, but I don't think it matters... probably).

Your screenshot displays a different problem. What settings are you using in the exporter?

Raster Ron

unread,
Sep 19, 2013, 9:17:04 AM9/19/13
to urh...@googlegroups.com

I have tried this one as well and I'm getting inconsistent results with different meshes, particularly the material file output. Currently I'm using the blender2ogre exporter plugin.

The interface and setup looks great though, keep it up and thanks for this!

reat...@gmail.com

unread,
Sep 19, 2013, 2:29:01 PM9/19/13
to urh...@googlegroups.com

Sorry but the material export is fake (I have to change that name), it is only useful to check if the UVs are correct. It creates a material XML with: Diff.xml technique, a texture (the first in Blender) in the diffuse channel and specuralirity to zero. Once you have the XML file you have to tweak it manually based on the shaders you are using, not on the Blender ones.
Reply all
Reply to author
Forward
0 new messages