Exemplo n.º 1
0
    if matstatics[mat]["textures"]:
        for texname in matstatics[mat]["textures"]:
            matpath = "./blocks/" + texname + ".png"
            if os.path.exists(matpath) and texname not in textures:
                with open(matpath, "rb") as image_file:
                    textures[texname] = base64.b64encode(image_file.read())


for aobject in objects:
    tofind = (aobject['type'],aobject['meta'])
    if tofind in avgcolors:
        material = Material(color=avgcolors[tofind][0:3],alpha=avgcolors[tofind][3],blockid=(aobject['type'], aobject['meta']),name=aobject['name'].encode('ascii','ignore'), blandname=aobject['name'].encode('ascii','ignore'))
    else:
        print str(tofind) + ' not in there !'
        material = Material(blockid=(aobject['type'], aobject['meta']),name=aobject['name'].encode('ascii','ignore'), blandname=aobject['name'].encode('ascii','ignore'))

    materials.update({tofind:material.getDict()})

materials.update( material.addRest(materials) )

print "length of materials found on site: " + str(len(materials))

matsandtex = {"materials":materials,"textures":textures}

toformat = repr(matsandtex).replace("}", "}\n")



f.write(toformat)

print "Done !"