Lack in MC

MakeHuman python API, python plugins, etc

Moderator: joepal

Lack in MC

Postby Marco_105 » Sat Jan 14, 2017 5:20 am

Makeclothes script doesn't put normalTexture in .mhmat file (when exist in BL materials) but instead puts a textureBump which is not exactly same things :mrgreen:
Could you correct it ?
User avatar
Marco_105
 
Posts: 212
Joined: Sat Mar 08, 2014 3:52 pm

Re: Lack in MC

Postby RobBaer » Sat Jan 14, 2017 8:21 am

I have added this to the issue tracker
http://bugtracker.makehumancommunity.org/issues/1100
User avatar
RobBaer
 
Posts: 1208
Joined: Sat Jul 13, 2013 3:30 pm
Location: Kirksville, MO USA

Re: Lack in MC

Postby Marco_105 » Sat Jan 14, 2017 3:35 pm

I made the corrective in my own script for normal map in and it work fine may I bring it somewhere ?
User avatar
Marco_105
 
Posts: 212
Joined: Sat Mar 08, 2014 3:52 pm

Re: Lack in MC

Postby RobBaer » Sat Jan 14, 2017 3:58 pm

Well, if you are programming savvy, you could issue a pull request at: https://bitbucket.org/MakeHuman/makehuman

Otherwise, if its small enough, you could perhaps attach it here. This would be useful as we look into this issue, and could speed getting changes integrated into development versions.
User avatar
RobBaer
 
Posts: 1208
Joined: Sat Jul 13, 2013 3:30 pm
Location: Kirksville, MO USA

Re: Lack in MC

Postby Marco_105 » Sat Jan 14, 2017 5:08 pm

I bring the code there, but you have just to find and implement the line with comment:
# some change is there **********
Code: Select all
def writeMaterialFile(fp, mat, name, outdir):
    """
    Write a material (.mhmat) file in the output folder.
    Also copies all textures to the output folder
    """

    fp.write(
        '# MakeHuman Material definition\n' +
        '\n' +
        'name %sMaterial\n' % name +
        '\n' +
        '// Color shading attributes\n'
        'diffuseColor  %.4g %.4g %.4g\n' % tuple(mat.diffuse_intensity * mat.diffuse_color) +
        'specularColor  %.4g %.4g %.4g\n' % tuple(mat.specular_intensity * mat.specular_color) +
        'shininess %.4g\n' % max(0, min(mat.specular_hardness/255, 1)) +
        'opacity %.4g\n' % mat.alpha +
        '\n' +
        '// Textures and properties\n')

    useDiffuse = useSpecular = useBump = useNormal = useDisplacement = "false"
    for slotNo,mtex in enumerate(mat.texture_slots):
        if mtex is None or not mat.use_textures[slotNo]:
            continue
        tex = mtex.texture
        if (tex.type != 'IMAGE' or
            tex.image is None):
            continue
        if tex.image.filepath == "":
            raise MHError("Texture %s image must be saved first" % tex.name)
        srcpath = tex.image.filepath
        texpath = os.path.basename(srcpath).replace(" ","_")

        if mtex.use_map_color_diffuse:
            fp.write('diffuseTexture %s\n' % texpath)
            useDiffuse = "true"
        if mtex.use_map_alpha:
            useAlpha = "true"
        if mtex.use_map_specular:
            fp.write('specularTexture %s\n' % texpath)
            useSpecular = "true"

        #some change is there **********
        if mtex.use_map_normal:
            if tex.use_normal_map:
                fp.write('normalmapTexture %s\n' % texpath)
                useNormal = "true"
            else:
                fp.write('bumpTexture %s\n' % texpath)
                useBump = "true"
               
        if mtex.use_map_displacement:
            fp.write('displacementTexture %s\n' % texpath)
            useDisplacement = "true"

        trgpath = os.path.join(outdir, texpath)
        print("Copy texture %s => %s" % (srcpath, trgpath))
        try:
            shutil.copy(srcpath, trgpath)
        except FileNotFoundError:
            addWarning("Texture\n \"%s\" \nnot found\n" % srcpath)
User avatar
Marco_105
 
Posts: 212
Joined: Sat Mar 08, 2014 3:52 pm

Re: Lack in MC

Postby Marco_105 » Sat Jan 14, 2017 6:50 pm

MC script don't write the ambientColor line in the .mhmat so simple color from BL look not contrasted in MH.

This works fine for me:
Code: Select all
    fp.write(
        '# MakeHuman Material definition\n' +
        '\n' +
        'name %sMaterial\n' % name +
        '\n' +
        '// Color shading attributes\n'
        'diffuseColor  %.4g %.4g %.4g\n' % tuple(mat.diffuse_intensity * mat.diffuse_color) +
        'specularColor  %.4g %.4g %.4g\n' % tuple(mat.specular_intensity * mat.specular_color) +
        'shininess %.4g\n' % max(0, min(mat.specular_hardness/255, 1)) +
        'opacity %.4g\n' % mat.alpha +
        'ambientColor 0.1000 0.1000 0.1000' +
        '\n' +
        '// Textures and properties\n')

User avatar
Marco_105
 
Posts: 212
Joined: Sat Mar 08, 2014 3:52 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron