Wednesday, February 10, 2010

MHX for Blender 2.5, with hair

This morning I released the first working exporter for Blender 2.5.

Blender 2.5 is the radically new Blender version which aims at taking over the world. The software is still in alpha stage, but things have started to become rather stable over the last few weeks, and those not overly concerned about occational program crashes can now import MHX files into it.

The python API has undergone a complete overhaul in Blender 2.5. The new API is much better (much more regular and complete) than the old one, but it is different, and the old MHX importer does not work. Moreover, the MHX format itself reflects Blender's python interface. To take full advantage of Blender 2.5's capabilities, I have therefore invented a modified MHX format which can be imported into the new Blender. The old format can still be imported into Blender 2.49, of course.

First of all we must grab an up-to-date Blender build from http://www.graphicall.org/builds/. Note that the Blender alpha is seriously outdated. Even a build from the last weekend won't do, because the Blender devs have changed the name of some python variables since then; more precisely, Material.textures has changed to Materials.texture_slots.

When we export a character called foo from MakeHuman, two MHX files appear in the exports directory: foo-24.mhx and foo-classic-25.mhx. foo-24 can be imported into Blender 2.49 as before, and foo-classic-25 can be imported into Blender 2.5. Trying to import a file into the wrong Blender version results in an error message.

To import this file into Blender, open the file importers/mhx/blender25x/import_scene_mhx.py in a Blender text editor. Scroll down to the bottom of the file and change to the adequate file name. You can also control what features are imported by modifying the variable toggle just above the call to readMhxFile(). I have tried to make a user interface, but it currently messes up the code.



The mesh should now come into Blender without materials. There is a non-neglible risk that Blender should crash during import; if so, just try again. On my system, more than 80% of the crashes occurred when I was importing materials or textures, which is why I disabled them. Apart from materials, most things are as in the 2.49 version. Also on my system, the armature is hidden and the display objects appear on layer 1, but this may be a Blender bug.

Drivers (driven shape keys and FK/IK switch) have not yet been implemented. Drivers work quite differently in 2.5 than in 2.49. However, the facial shape keys are there, although you have to access them in the panel to the right.

Did you notice the things on her head? Could it be...

Yes!



For the time being, I made a quick test hair with 10 parent strands and lots of children and put it into the template file. It should be replaced by the selected MakeHuman hair soon.

Jose or maybe Marc: How do I access the hair object?

3 comments:

  1. The mesh is accessible as self.app.scene3d.selectedHuman.hairObj from any gui object, see hair.py.

    ReplyDelete
  2. Thanks for putting a Mesh width control on the Hair gui; for somebody who used SoftBodies in Blender, that is more than enough for most animations.

    ReplyDelete
  3. this is currently broken since blender 252 rev 27115 - see this thread

    http://blenderartists.org/forum/showthread.php?p=1576365

    error is


    File "c:/makehuman/importers/mhx/blender25x\import_scene_mhx.py", line 674, in createObject
    ob = bpy.data.objects.new(name, typ)
    TypeError: MainObjects.new(): error with argument 2, "object_data" - expected a ID type

    ReplyDelete

© MHteam 2001-2010