Ejemplo n.º 1
0
def main(objName):
    obj = bpy.data.objects[objName]

    bpy.context.scene.objects.active = obj

    # deselect all other objects in the scene
    for ob in bpy.data.objects:
        print(obj.name)
        ob.select = False

    print('test the bakery')
    bake_config = {
        'filepath': '/tmp/textures/',
        'baked_texture': 'baked_image',
        'baked_texture_img': 'baked_image.png',
        'texture': 'baked_texture',
        'material': 'baked_material',
        'uv_map': 'baked_uv_map',
        'unwrap': 'lightmap_pack'
    }

    # set up the scenery to bake a texture to an object
    print('create the bakery')
    cBakery = createBakery()
    # get the object which should be baked
    #    obj = bpy.data.objects[objName]
    # bake the texture
    bakery.bake(obj, bake_config)
    # remove the scenery again
    print("clean up the bakery")
    del cBakery
Ejemplo n.º 2
0
    def bakeWarpper(self, obj):

        bpy.context.scene.objects.active = obj

        # deselect all objects
        for ob in bpy.data.objects:
            ob.select = False

        bake_config = {
            'filepath': '/tmp/textures/',
            'baked_texture': 'baked_image' + str(time()),
            'baked_texture_img': 'baked_image' + str(time()) + '.png',
            'texture': 'baked_texture_' + str(time()),
            'material': 'baked_material_' + str(time()),
            'uv_map': 'baked_uv_map_' + str(time()),
            'unwrap': 'lightmap_pack'
        }

        # set up the scenery to bake a texture to an object
        print('create the bakery')
        cBakery = createBakery()
        # bake the texture
        bakery.bake(obj, bake_config)
        # remove the scenery again
        print("clean up the bakery")
        del cBakery
Ejemplo n.º 3
0
def baked_image_from_abi(abi):
    image_url = abi.badge_instance.get('image')
    if image_url is not None:
        try:
            image = requests.get(image_url)

            unbake(image)
        except:
            pass
        else:
            return image

    try:
        image_url = abi.badge.get('image')
        unbaked_image = ContentFile(
            requests.get(image_url)._content, "unbaked_image.png"
        )

        unbaked_image.open()
        baked_image = bake(
            unbaked_image, json.dumps(dict(abi.badge_instance), indent=2)
        )
    except requests.exceptions.SSLError as e:
        raise ValidationError("SSL failure retrieving image " + image_url)
    except Exception as e:
        raise e
    else:
        return baked_image
Ejemplo n.º 4
0
    def save(self, *args, **kwargs):
        if self.pk is None:
            self.json['recipient']['salt'] = salt = self.get_new_slug()
            self.json['recipient']['identity'] = generate_sha256_hashstring(self.email, salt)

            self.created_at = datetime.datetime.now()
            self.json['issuedOn'] = self.created_at.isoformat()

            with open(self.badgeclass.image.file.name) as imageFile:
                self.image = bake(imageFile, json.dumps(self.json, indent=2))

            self.image.open()

        if self.revoked is False:
            self.revocation_reason = None

        # TODO: If we don't want AutoSlugField to ensure uniqueness, configure it
        super(BadgeInstance, self).save(*args, **kwargs)
Ejemplo n.º 5
0
    def save(self, *args, **kwargs):
        if self.pk is None:
            self.json['recipient']['salt'] = salt = self.get_new_slug()
            self.json['recipient']['identity'] = generate_sha256_hashstring(
                self.email, salt)

            self.created_at = datetime.datetime.now()
            self.json['issuedOn'] = self.created_at.isoformat()

            imageFile = default_storage.open(self.badgeclass.image.file.name)
            self.image = bake(imageFile, json.dumps(self.json, indent=2))

            self.image.open()

        if self.revoked is False:
            self.revocation_reason = None

        # TODO: If we don't want AutoSlugField to ensure uniqueness, configure it
        super(BadgeInstance, self).save(*args, **kwargs)
Ejemplo n.º 6
0
import bakery
import bpy
import imp

imp.reload(bakery)

config = {
    'filepath': './textures/',
    'image_name': 'bakery_image',
    'baked_image': 'baked_image',
    'texture': 'baked_texture',
    'material': 'baked_material',
    'uv_map': 'baked_uv_map',
    'unwrap': 'lightmap_pack'
}

obj = bpy.data.objects["Cube"]

bakery.bake(obj, config)