makehuman into blender tutorial

Here you can find the help you need to solve usage problems

Moderator: pistacja

Re: makehuman into blender tutorial

Postby x-men » Tue Jun 17, 2008 5:53 pm

Andy,
how can i select all verts listed under the bones material ?

thanks
x-men
 
Posts: 1
Joined: Tue Jun 17, 2008 5:10 pm

Re: makehuman into blender tutorial

Postby andyp » Wed Jun 18, 2008 4:45 am

so forgive me for not posting images i am at my dads house
and my blender pc is at my moms

so in edit mode go in to the edit tools menu
and in the window on the far right there should be one about materials
and it should have the material with the materials name and number
switch it to the one with bones
and then click select
with any luck the verts that are assigned to the bone materials should light up
andyp
 
Posts: 45
Joined: Fri Feb 15, 2008 8:35 pm

Re: makehuman into blender tutorial

Postby galdon » Mon Jun 30, 2008 3:59 am

I'm out of ideas.

I've followed this tutorial, experimented, made a whole new armature structure, I can't think of another form of manipulation i could do to it. the only thing that seems to stick are the fingers toes and the tongue. nothing else will assign to the bones. Am i going to need to manually apply the verticies to each bone or is there something glaringly obvious that I'm just not seeing?
galdon
 
Posts: 1
Joined: Mon Jun 30, 2008 2:45 am

Re: makehuman into blender tutorial

Postby andyp » Mon Jun 30, 2008 11:31 pm

i believe that i have this issued already covered in the tutorial
if not oh well

the explanation:
the colida import is not perfect, since the project was dropped a few years back
so when blender tries to import the colida format the armature does not always match the character mesh perfectly
thats why i suggest that you delete the bone verts after importing so the rigging the mesh via bone heat can work better.

try this:
view everything as a wire frame, and then move the armature to a better center of the character mesh and then try again,
this usually fixes the bug

if it does not work:
try the tut with another character,
if it still doesnt work reinstal blender, and get the latest version of python


hope that helps!
andyp
 
Posts: 45
Joined: Fri Feb 15, 2008 8:35 pm

Re: makehuman into blender tutorial

Postby Tindytim » Sun Jul 20, 2008 4:39 am

I cannot get bone heat to work at all.
The bones are centered, I've even moved them back, and away from center and tried. I keep getting the "Bone Heat Weighting: failed to find a solution for one or more bones" error. I have python 2.5.2 installed and Blender 2.46. I just unistalled and re-installed both. Still no help. I tried different models, and tried exporting from MakeHuman multiple times.

I did completely skip the texturing section, as I am not interested in using the MakeHuman textures. Is there something I am missing?

I do get this out of the prompt:
Code: Select all
FEEDBACK: Illusoft Collada 1.4 Plugin v0.3.159 started
[Object "joint0"]
scene.link(ob) deprecated!
        use scene.objects.link(ob) instead
FEEDBACK: FINISHED - time elapsed: 16.8
Tindytim
 
Posts: 7
Joined: Sun Jul 20, 2008 4:33 am

Re: makehuman into blender tutorial

Postby m.e » Mon Jul 28, 2008 3:36 pm

Here is a first cut of a script to run the first half of the tutorial automatically. You need to do the import first and select the mesh, then run the script. It should do everything to just before parenting the armature to the mesh (which I cannot get working). The script asks for (a) the directory with the makehuman texture files and (b) an optional prefix for the textures, in case you want to do this more than once.
Code: Select all
#!BPY
"""
Name: 'MakeHuman Fix'
Blender: 246
Group: 'Object'
Tooltip: 'Cleanup import fron MakeHuman as per andyp's tutorial'
"""
__author__ = 'Martin Ellison'
__version__ = '1.0 2008/07/28'
__url__ = []
__email__ = ["Martin Ellison, m.e:acm*org", "scripts"]
__bpydoc__ = """\
this automates part of a makehuman->blender import.
See http://www.makehuman.org/forum/viewtopic.php?f=6&t=167
1. Import human using collada 1.4 importer
2. select mesh
3. run this script
4. continue tutorial, starting with parenting armature to mesh
"""

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Martin Ellison
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------

from Blender import Window, sys, Texture, Image, Material, Draw, Mesh, Scene, Modifier

imageDir = '/home/martin/makehuman/rendering/'
prefix = 'lady3-'

def add_texture(name, fileName, index, materialName, mapTo):
        tex = Texture.New(prefix + name)
        tex.setType('Image')
        imageFile = imageDir + fileName
        img = Image.Load(imageFile)
        tex.image = img
       
        mat = Material.Get(materialName)
        mat.spec = 0
        mat.hard = 1
        mat.setTexture(index, tex)
        mtex = mat.getTextures()[index]
        mtex.texco = Texture.TexCo.UV
        mtex.mapping = Texture.Mappings.FLAT
        mtex.mapto = mapTo

def fix_human(mesh):
    try:
        print 'fixing mesh...'
        add_texture('head-colour', 'head_color.tx', 0, 'head', Texture.MapTo.COL | Texture.MapTo.CSP | Texture.MapTo.CMIR)
        add_texture('head-bump', 'head_bump.tx', 1, 'head', Texture.MapTo.NOR)
        add_texture('head-specular', 'head_specular.tx', 2, 'head', Texture.MapTo.SPEC)
        add_texture('body-colour', 'body_color.tx', 0, 'body', Texture.MapTo.COL | Texture.MapTo.CSP | Texture.MapTo.CMIR)
        add_texture('body-bump', 'body_bump.tx', 1, 'body', Texture.MapTo.NOR)
        add_texture('body-specular', 'body_specular.tx', 2, 'body', Texture.MapTo.SPEC)
        add_texture('eyes-reflection', 'eyes_reflection.tx', 0, 'eye', Texture.MapTo.REF)
        add_texture('eyes-colour', 'eyes_color.tx', 1, 'eye', Texture.MapTo.COL | Texture.MapTo.CSP | Texture.MapTo.CMIR)
        add_texture('eyebrows-alpha', 'eyebrows_alpha.tx', 0, 'eyebrows', Texture.MapTo.ALPHA)
        Material.Get('eyebrows').getTextures()[0].tex.imageFlags = Texture.ImageFlags.CALCALPHA | Texture.ImageFlags.CALCALPHA
        add_texture('eyebrows-colour', 'eyebrows_color.tx', 1, 'eyebrows', Texture.MapTo.COL | Texture.MapTo.CSP | Texture.MapTo.CMIR)
        Material.Get('eyebrows').mode |= Material.Modes.ZTRANSP | Material.Modes.SHADOWBUF | Material.Modes.TRACEABLE
        Material.Get('eyebrows').alpha = 0
        add_texture('eyelashes-colour', 'eyelashes_color.tx', 1, 'eyelashes', Texture.MapTo.COL | Texture.MapTo.CSP | Texture.MapTo.CMIR)
        Material.Get('eyelashes').mode |= Material.Modes.ZTRANSP | Material.Modes.SHADOWBUF | Material.Modes.TRACEABLE
        Material.Get('eyelashes').alpha = 0
       
        bonesMaterialIndex = -1
        for matIndex in range(len(mesh.materials)):
           if mesh.materials[matIndex].name.startswith('bones'):
              bones = []
              for face in mesh.faces:
                if face.mat == matIndex:
               for vert in face.verts:
                  bones += [vert]
              print 'bones material is #%d, deleting %d bones' % (matIndex, len(bones))
              mesh.verts.delete(bones)
        for face in mesh.faces: face.smooth = True
      
        print 'done'
    except:
        Draw.PupMenu("There was some problem ")
        raise      
         
def main():
    print '-----'
    Window.WaitCursor(1)
    t = sys.time()
   
    # Run the object editing function
    scn= Scene.GetCurrent()
    sel_object = scn.objects.active
    if sel_object == None or sel_object.getType()!='Mesh':
                result = Draw.PupMenu("You need to select a mesh")             
                return
               
    popup = []
    global imageDir
    global prefix
    imageDir = Draw.PupStrInput("Image directory: ", imageDir, 64)
    prefix = Draw.PupStrInput("Texture prefix: ", '')
    retval = Draw.PupMenu("Continue?%t|No|Yes")
    if not retval: return
    the_mesh = sel_object.getData(mesh=1)
    editmode = Window.EditMode()   
    if editmode: Window.EditMode(0) 
    fix_human(the_mesh)
      
    if editmode: Window.EditMode(1)
    Window.RedrawAll()
   # Timing the script is a good way to be aware on any speed hits when scripting
    print 'My Script finished in %.2f seconds' % (sys.time()-t)
    Window.WaitCursor(0)
   
   
# This lets you can import the script without running it
if __name__ == '__main__':
   main()
m.e
 
Posts: 51
Joined: Wed Jul 23, 2008 9:20 am
Location: Shenzhen/Hong Kong

Re: makehuman into blender tutorial

Postby Jeremy Ray » Mon Jul 28, 2008 4:19 pm

Thanks for the tutorial! That's an awesome way to rough things out quickly!
Jeremy Ray
 
Posts: 16
Joined: Mon Feb 18, 2008 6:41 am

Re: makehuman into blender tutorial

Postby Tindytim » Mon Jul 28, 2008 11:17 pm

So I'm not the only one having issues with Bone heat?
Tindytim
 
Posts: 7
Joined: Sun Jul 20, 2008 4:33 am

Re: makehuman into blender tutorial

Postby andyp » Tue Jul 29, 2008 6:14 pm

the bone heat issues are issues with in blender, that are still getting worked on by the blender developers
it is a new feature so it does have some bugs in it
most of the time with the bone heat the issues come from the part where the make human mesh is not perfect to the armature, you have to remember, the make human mesh changes, sometimes a lot from the default, where as the armature does not change so much
i have had issues with the bone heat not working too, i've had to do it a couple of times and then the third time of doing it in the same session, it works with out me doing any thing differently
for the people who are having issues with the bone heat, try doing a different character, or even the default mh character and then see if it works

also @tindytim, you have been trying to use a custom head with your characters, i suggest that you first try rigging the regular charaters before you start modifying them, other wise you will get odd rigging issues
andyp
 
Posts: 45
Joined: Fri Feb 15, 2008 8:35 pm

Script to fix bone heat problem (please test)

Postby m.e » Wed Jul 30, 2008 8:23 am

I have written a script that fixed the bone heat problem for me; you might want to try it and tell us your results:
Code: Select all
#!BPY

# """
# Name: 'Re-align Armature'
# Blender: 246
# Group: 'Mesh'
# Tooltip: '(Re)Attach an armature to a mesh and ensure that they have the same object centres.'
# """

import Blender
from Blender import Window, Draw, Scene, Object, Mesh

__author__ = 'Martin Ellison'
__version__ = '1.0 2008/07/30'
__url__ = []
__email__ = ["Martin Ellison, m.e:acm*org", "scripts"]
__bpydoc__ = """\
From the popup, select one armature and one mesh.

"""

# ***** BEGIN GPL LICENSE BLOCK *****
#
# Script copyright (C) Martin Ellison
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender
from Blender import Window, Scene, Geometry, Mathutils, Object, Armature, Mesh, Draw
from Blender.Mathutils import Vector

def alignArmature(armatureObject, meshObject):
        armatureLoc = Vector(armatureObject.loc)
        armature = armatureObject.getData()
        meshLoc = Vector(meshObject.loc)
        diff = armatureLoc - meshLoc
        armature.makeEditable()
        for bone in armature.bones.values():
                bone.head -= diff
                bone.tail -= diff
        armature.update()
        armatureObject.setLocation(meshObject.loc)

def main():
        print '-----'
        scn = Scene.GetCurrent()
        sel_object = scn.objects.active
        popup = []
        armatures = []
        meshes = []
        for obj in scn.getChildren():
                if obj.type == 'Armature':
                        tog = Blender.Draw.Create(0)
                        popup.append((obj.name + ' (arm)', tog)) 
                        armatures.append((tog, obj.name))
                if obj.type == 'Mesh':
                        tog = Blender.Draw.Create(0)
                        popup.append((obj.name + ' (mesh)', tog)) 
                        meshes.append((tog, obj.name))
        if not Blender.Draw.PupBlock("Attach mesh to armature? ", popup): return
        armatureName = ''
        for tog, name in armatures:
                if tog.val:
                        if armatureName != '': Draw.PupMenu("Duplicate armature")   
                        armatureName = name
        meshName = ''
        for tog, name in meshes:
                if tog.val:
                        if meshName != '': Draw.PupMenu("Duplicate mesh")   
                        meshName = name

        mesh_object = Object.Get(meshName)
        armature_object = Object.Get(armatureName)
        if mesh_object.getType()!='Mesh':
                result = Draw.PupMenu("You need a mesh")             
                return
        the_mesh = mesh_object.getData(mesh=1)
        print 'the mesh is at ', mesh_object.loc
        if armature_object.getType()!='Armature':
                result = Draw.PupMenu("You need an armature")             
                return
        the_armature = armature_object.getData()
        print 'the armature is at ', armature_object.loc

        editmode = Window.EditMode()   
        if editmode: Window.EditMode(0)   
        Window.WaitCursor(1) 

        if mesh_object.parent != None: mesh_object.clrParent()
        alignArmature(armature_object, mesh_object)
        armature_object.makeParentDeform([mesh_object])   
               
        if editmode: Window.EditMode(1)
        Window.WaitCursor(0)
        Window.RedrawAll()
 
           
if __name__ == '__main__':
   main()

I have only tried it on one model so far.

Hopefully it is clear how to use it, but basically it pops up a list of all the meshes and armatures in the current scene, and you pick one of each and click OK. Then you can try the bone heat thing.
Last edited by m.e on Wed Jul 30, 2008 9:03 am, edited 1 time in total.
m.e
 
Posts: 51
Joined: Wed Jul 23, 2008 9:20 am
Location: Shenzhen/Hong Kong

PreviousNext

Return to Newbies

Who is online

Users browsing this forum: No registered users and 1 guest