Skip to content
Snippets Groups Projects
Select Git revision
  • 83b98d6070ef19a47543e4e760ff71c4427b483c
  • main default protected
  • v0.11
  • live
  • unifiedsse
  • 2.0.0.post4 protected
  • 2.0.0.post3 protected
  • 2.0.0.post2 protected
  • 2.0.0.post1 protected
  • 2.0.0 protected
  • 2.0.0a7 protected
  • 2.0.0a6 protected
  • 2.0.0a5 protected
  • 2.0.0a4 protected
  • 2.0.0a3 protected
  • 2.0.0a1 protected
  • 0.15.0a2 protected
  • 0.15.0a1 protected
  • 0.14.2 protected
  • 0.14.1 protected
  • 0.14.0 protected
  • 0.13.6 protected
  • 0.13.5 protected
  • 0.13.4 protected
  • 0.13.3 protected
25 results

_version.py

Blame
  • spray_movie_temporal_2.py 5.02 KiB
    import bpy
    
    from mathutils import Vector
    
    bpy.ops.object.delete(use_global=False)
    
    bpy.data.objects['Lamp'].select = True
    bpy.ops.object.delete(use_global=False)
    bpy.context.scene.render.engine = 'CYCLES'
    
    mat = bpy.data.materials.new('BWG')
    mat.use_nodes = True
    
    nodes = {
    'Texture Coordinate': ['ShaderNodeTexCoord', (-220.0, 510.0)],
    'Image Texture': ['ShaderNodeTexImage', (-20.0, 510.0)],
    'Emission': ['ShaderNodeEmission', (190.0, 450.0)],
    'Material Output': ['ShaderNodeOutputMaterial', (400.0, 450.0)]
    }
    
    for k, v in nodes.items():
        location = Vector(v[1])
        if not k in mat.node_tree.nodes:
            cur_node = mat.node_tree.nodes.new(v[0])
            cur_node.location = location
        else:
            mat.node_tree.nodes[k].location = location
    
    link00 = ['Texture Coordinate','Generated','Image Texture','Vector']
    link01 = ['Image Texture','Color','Emission','Color']
    link02 = ['Emission','Emission','Material Output','Surface']
    
    links = [link00, link01, link02]
    for link in links:
        from_node = mat.node_tree.nodes[link[0]]
        output_socket = from_node.outputs[link[1]]
        to_node = mat.node_tree.nodes[link[2]]
        input_socket = to_node.inputs[link[3]]
        mat.node_tree.links.new(output_socket, input_socket)
    
    mat.node_tree.nodes["Emission"].inputs['Strength'].default_value = 3.0
    
    img = bpy.data.images.load('back.png')
    mat.node_tree.nodes['Image Texture'].image = img
    
    bpy.ops.mesh.primitive_plane_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
    plane = bpy.data.objects['Plane']
    bpy.ops.object.shade_smooth()
    plane.location[0] = 1
    plane.location[1] = 4
    plane.location[2] = 0
    plane.rotation_euler[0] = 1.5708
    plane.rotation_euler[1] = 0
    plane.rotation_euler[2] = 0
    
    plane.scale[0] = 7
    plane.scale[1] = 5
    plane.scale[2] = 1
    
    plane.data.materials.append(mat)
    plane.select = False
    
    camera = bpy.data.objects['Camera']
    camera.select = True
    camera.location[0] = 4.0
    camera.location[1] = -5.4
    camera.location[2] = 1.0
    camera.rotation_euler[0] = 1.39626
    camera.rotation_euler[1] = 0.0
    camera.rotation_euler[2] = 0.258553
    camera.select = False
    
    bpy.ops.object.lamp_add(type='SUN', view_align=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
    sun = bpy.data.objects['Sun']
    sun.location[0] = 0
    sun.location[1] = -5
    sun.location[2] = 4
    sun.rotation_euler[0] = 0.911987
    sun.rotation_euler[1] = -0.259932
    sun.rotation_euler[2] = 0
    sun.select = False
    
    mat = bpy.data.materials.new('Injector')
    mat.use_nodes = True
    
    nodes = {
    'Diffuse BSDF': ['ShaderNodeBsdfDiffuse', (-220.0, 510.0)],
    'Material Output': ['ShaderNodeOutputMaterial', (-20.0, 510.0)],
    }
    
    for k, v in nodes.items():
        location = Vector(v[1])
        if not k in mat.node_tree.nodes:
            cur_node = mat.node_tree.nodes.new(v[0])
            cur_node.location = location
        else:
            mat.node_tree.nodes[k].location = location
    
    from_node = mat.node_tree.nodes['Diffuse BSDF']
    output_socket = from_node.outputs['BSDF']
    to_node = mat.node_tree.nodes['Material Output']
    input_socket = to_node.inputs['Surface']
    mat.node_tree.links.new(output_socket, input_socket)
    
    mat.node_tree.nodes["Diffuse BSDF"].inputs['Color'].default_value = (0.024,0,0.8,1)
    
    mat = bpy.data.materials.new('Fluid')
    mat.use_nodes = True
    
    nodes = {
    'Glass BSDF': ['ShaderNodeBsdfGlass', (-220.0, 510.0)],
    'Material Output': ['ShaderNodeOutputMaterial', (-20.0, 510.0)],
    }
    
    for k, v in nodes.items():
        location = Vector(v[1])
        if not k in mat.node_tree.nodes:
            cur_node = mat.node_tree.nodes.new(v[0])
            cur_node.location = location
        else:
            mat.node_tree.nodes[k].location = location
    
    from_node = mat.node_tree.nodes['Glass BSDF']
    output_socket = from_node.outputs['BSDF']
    to_node = mat.node_tree.nodes['Material Output']
    input_socket = to_node.inputs['Surface']
    mat.node_tree.links.new(output_socket, input_socket)
    
    mat.node_tree.nodes["Glass BSDF"].inputs['Color'].default_value = (1,1,1,1)
    mat.node_tree.nodes["Glass BSDF"].inputs['IOR'].default_value = 1.333
    
    bpy.context.scene.render.resolution_percentage = 100
    
    for i in range(1600,1774):
        fnin = ("F_We3000_%4.4d.stl" % i)
        spname = ("F_We3000_%4.4d.stl" % i)
        obname = ("F We3000 %4.4d" % i)
        spdir = ("")
        fnout = ("pics/F_We3000_%4.4d.png" % i)
        bpy.ops.import_mesh.stl(filepath=fnin, filter_glob="*.stl", files=[{"name":spname, "name":spname}], directory=spdir)
        spray = bpy.data.objects[obname]
        bpy.ops.object.shade_smooth()
        spray.scale[0] = 0.6
        spray.scale[1] = 0.6
        spray.scale[2] = 0.6
        spray.rotation_euler[0] = 1.5708
        spray.location[0] = 2.7
        spray.location[1] = -0.0
        spray.location[2] = 0.1
        spray.data.materials.append(mat)
        spray.select = False
        bpy.context.scene.render.filepath = fnout
        bpy.ops.render.render(write_still = True)
        spray.select = True
        bpy.ops.object.delete(use_global=False)