Пример #1
0
def render():
    # update scene
    bpy.context.scene.update()

    # Enable ambient occlusion
    utils.setAmbientOcclusion(samples=30)

    # Render scene
    utils.renderToFolder('rendering', 'funky_cover', 8.5 * 300, 11 * 300)
    for fcurve in targetObj.animation_data.action.fcurves:
        for keyframe in fcurve.keyframe_points:
            keyframe.interpolation = 'LINEAR'

    X, y, labels = load_iris()

    createScatter(X, y)
    createLabels(X, y, labels, cameraObj)

    # Create a grid
    bpy.ops.mesh.primitive_grid_add(radius=3,
                                    location=(0, 0, 0),
                                    x_subdivisions=15,
                                    y_subdivisions=15)

    grid = bpy.context.active_object

    # Create grid material
    gridMat = bpy.data.materials.new('GridMaterial')
    gridMat.type = 'WIRE'
    gridMat.use_transparency = True
    gridMat.alpha = 0.3

    grid.data.materials.append(gridMat)

    utils.renderToFolder('frames',
                         'fisher_iris_visualization',
                         500,
                         500,
                         animation=True)
Пример #3
0
    # Creata phyllotaxis flower
    blossom = PhyllotaxisFlower(bpy.context.scene)

    # Create camera and lamp
    utils.simpleScene((0, 0, -1.5), (-21.5, -21.5, 12.5), (-5, 5, 10))

    # Enable ambient occlusion
    utils.setAmbientOcclusion(samples=10)

    # Select colors
    palette = [(3, 101, 100), (205, 179, 128)]
    # Convert color and apply gamma correction
    palette = [
        tuple(pow(float(c) / 255, 2.2) for c in color) for color in palette
    ]

    # Set background color of scene
    bpy.context.scene.world.horizon_color = palette[0]

    # Set material for object
    mat = utils.falloffMaterial(palette[1])
    blossom.obj.data.materials.append(mat)

    # Render scene
    utils.renderToFolder('frames',
                         'phyllotaxis_flower',
                         500,
                         500,
                         animation=True,
                         frame_end=50)
Пример #4
0
    tuple(pow(float(c) / 255.0, 2.2) for c in color) for color in palette
]

# Set background color
bpy.context.scene.world.horizon_color = palette[0]

# Create material for the object
mat = bpy.data.materials.new('BumpMapMaterial')
mat.diffuse_color = palette[1]
mat.specular_intensity = 0
mat.emit = 0.1

# Add texture slot for material
slot = mat.texture_slots.add()
slot.texture = bumptex
# Texture mapping: https://docs.blender.org/manual/ko/dev/render/blender_render/textures/properties/mapping.html
slot.texture_coords = 'GLOBAL'
slot.use_map_color_diffuse = False
slot.use_map_normal = True

# Append material to object
obj.data.materials.append(mat)

# Render scene
utils.renderToFolder('frames_01',
                     'rugged_donut',
                     800,
                     800,
                     animation=True,
                     frame_end=num_frames)
Пример #5
0
    metaball.resolution = 0.2
    metaball.render_resolution = 0.05

    for i in range(n):
        location = Vector(origin) + Vector(
            random.uniform(-r0, r0) for i in range(3))

        element = metaball.elements.new()
        element.co = location
        element.radius = r1

    return metaball


if __name__ == '__main__':
    # Remove all elements
    utils.removeAll()

    # Create camera
    target = utils.target()
    camera = utils.camera((-10, -10, 10), target)

    # Create lamps
    utils.rainbowLights(10, 300, 3)

    # Create metaball
    metaball = createMetaball()

    # Render scene
    utils.renderToFolder('rendering', 'metaballs', 500, 500)
    obj.location = origin
    # Link object to scene
    bpy.context.scene.objects.link(obj)
    # Create mesh from given verts and faces
    mesh.from_pydata(verts, [], faces)
    #Update mesh with new data
    mesh.update(calc_edges=True)
    return obj


if __name__ == '__main__':
    # Remove all elements
    utils.removeAll()

    # Create camera
    target = utils.target()
    camera = utils.camera((-10, -10, 10), target)

    # Set cursor to (0, 0, 0)
    bpy.context.scene.cursor_location = (0, 0, 0)

    # Create lamps
    utils.rainbowLights(10, 300, 3)

    # Create object
    torus = createSurface(torusSurface(4, 2), 20, 20)
    utils.setSmooth(torus, 2)

    # Render scene
    utils.renderToFolder('rendering', 'parametric_torus', 500, 500)
    bpy.context.scene.objects.link(obj)
    bpy.context.scene.update()

    # Create and assign materials to object
    for color in colors:
        mat = bpy.data.materials.new('Material')
        mat.diffuse_color = convert_hsv(color)
        mat.diffuse_intensity = 0.9
        obj.data.materials.append(mat)


if __name__ == '__main__':
    print(__file__)

    # Remove all elements
    utils.removeAll()

    # Create object
    voronoi_landscape()

    # Create camera and lamp
    target = utils.target((0, 0, 3))
    utils.camera((-8, -12, 11), target, type='ORTHO', ortho_scale=5)
    utils.lamp((10, -10, 10), target=target, type='SUN')

    # Enable ambient occlusion
    utils.setAmbientOcclusion(samples=10)

    # Render scene
    utils.renderToFolder('rendering', 'vornoi_landscape', 500, 500)
Пример #8
0
    # Set ambient occlusion
    utils.setAmbientOcclusion()

    # Create camera and lamp
    utils.simpleScene((0, 0, 0), (6, 0, 0), (-5, 5, 10))

    # Color palette
    # http://www.colourlovers.com/palette/1189317/Rock_Mint_Splash
    palette = [(89, 91, 90), (20, 195, 162), (13, 229, 168), (124, 244, 154),
               (184, 253, 153)]
    palette = [utils.colorRGB_256(color) for color in palette]

    # Set background color of scene
    bpy.context.scene.world.horizon_color = palette[0]

    # Create Voronoi Sphere
    n, r = 2000, 2
    points = (np.random.random((n, 3)) - 0.5) * 2 * r
    bm = bmesh.new()
    VoronoiSphere(bm, points, r, numMaterials=len(palette) - 1)
    obj = utils.bmeshToObject(bm)

    # Apply materials to object
    for color in palette[1:]:
        mat = utils.simpleMaterial(color)
        obj.data.materials.append(mat)

    # Render scene
    utils.renderToFolder('rendering', 'voronoi_sphere', 500, 500)
Пример #9
0
    # Create obj and mesh from bmesh object
    me = bpy.data.meshes.new("TetrahedronMesh")
    bm.to_mesh(me)
    bm.free()
    obj = bpy.data.objects.new("Tetrahedron", me)
    bpy.context.scene.objects.link(obj)
    bpy.context.scene.update()


    # Create camera and lamp
    target = utils.target((0, 0, 1))
    utils.camera((-8, 10, 5), target, type='ORTHO', ortho_scale=10)
    utils.lamp((10, -10, 10), target=target, type='SUN')

    # Enable ambient occlusion
    utils.setAmbientOcclusion(samples=10)

    # Select colors
    palette = [(181,221,201), (218,122,61)]
    palette = [utils.colorRGB_256(color) for color in palette]  # Adjust color to Blender

    # Set background color of scene
    bpy.context.scene.world.horizon_color = palette[0]

    # Set material for object
    mat = utils.simpleMaterial(palette[1])
    obj.data.materials.append(mat)

    # Render scene
    utils.renderToFolder('rendering', 'tetrahedron_fractal', 500, 500)