Blender 2.8, Python. Es wird gesagt, dass der Würfel gekippt und vergrößert wurde. Als ich es in eine dünne Form kippte, sah es aus wie ein Smartphone. Bisher haben wir Würfelplatzierung, Materialzuordnung, Kamerabewegung und Beleuchtungsbewegung erreicht. (Zukünftige Probleme umfassen Kamerawinkel, Blick auf bestimmte Koordinaten der Kamera, Bewegung entlang des Pfades beim Bewegen eines Objekts usw.)
Video gepostet auf Twitter Blender 2.8, Python Blender 2.8, Python. Video 1 Sekunde. Neigung des Würfels ...
#bpy_nh12 Würfelvergrößerung / -verkleinerung, Neigungsaddition. (Kamera bewegen. 4 Lichter bewegen)
import bpy
#Vorhandenes Netz, light, camera,Alles löschen
for item in bpy.data.objects:
bpy.data.objects.remove(item)
#Kubisches Originalskript---- http://tips.hecomi.com/entry/20120818/1345307205
#Vergrößertes Referenzmaterial tatsuruM Qiita https://qiita.com/tatsuruM/items/9d4222c6c7d96b4c5b3c
START = 0
END = 100
N = 4
# Add color cubes
for x in range(0, N):
for y in range(0, N):
for z in range(0, N):
# Add a color cube
bpy.ops.mesh.primitive_cube_add( location=(x*3, y*3, z*3),size = (1.2) )
bpy.ops.transform.resize(value=(0.8, 0.1, 2.0))
bpy.ops.transform.rotate(value= -3.1415/6 ,orient_axis='X')
#obj = bpy.context.scene.objects.active #(old blender2.7script)
obj = bpy.context.view_layer.objects.active
#mat.diffuse_color = (x/N, y/N, z/N)#(old blender2.7script)
mat = bpy.data.materials.new('Cube')
mat.diffuse_color = (x/N, y/N, z/N, 0)
#mat.use_transparency = True #(Diese Zeile ist 2.Nicht versucht in 8)
#mat.alpha = 0.6 #(Diese Zeile ist 2.Nicht versucht in 8)
obj.data.materials.append(mat)
# new camera
bpy.ops.object.add(radius=1.0, type='CAMERA', enter_editmode=False, align='WORLD', location=(20.0, -6.0, 8.0), rotation=(1.4, 0.0, 1.2))
# =========== camera movement
bpy.data.objects['Camera'].select_set(True)
cdnow = bpy.context.scene.objects["Camera"] # get ACTIVE object
bpy.context.scene.frame_current = 1 # set frame to 1
cdnow.location = (20.0, -6.0, 8.0) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 10 # set frame to 10
cdnow.location = (20.0, -4.0, 9.0) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 20 # set frame to 20
cdnow.location = (22.0, -4.0, 10.0)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 30 # set frame to 30
cdnow.location = (20.0, -6.0, 8.0)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.data.objects['Camera'].select_set(False)
# ==================
#Neue Lampen (Überlauf des Quellstapels Können Sie mit Python eine Lichtquelle in den Mixer einfügen?)
# =============="light_spot3"
# create light datablock, set attributes
light_data = bpy.data.lights.new(name="light_spot3", type='SPOT')
light_data.energy = 2000
# create new object with our light datablock
light_object = bpy.data.objects.new(name="light_spot3", object_data=light_data)
# link light object
bpy.context.collection.objects.link(light_object)
# make it active
bpy.context.view_layer.objects.active = light_object
#change location
light_object.location = (2, -2, 3)
light_object.delta_rotation_euler = (1.6, 0, 0) #Schauen Sie direkt auf Null Null Null.
# update scene, if needed
dg = bpy.context.evaluated_depsgraph_get()
dg.update()
# =============="light_spot2"
# create light datablock, set attributes
light_data = bpy.data.lights.new(name="light_spot2", type='SPOT')
light_data.energy = 2000
# create new object with our light datablock
light_object = bpy.data.objects.new(name="light_spot2", object_data=light_data)
# link light object
bpy.context.collection.objects.link(light_object)
# make it active
bpy.context.view_layer.objects.active = light_object
#change location
light_object.location = (2, -4, 10)
light_object.delta_rotation_euler = (1.5, 0, 0) #Schauen Sie direkt auf Null Null Null.
# update scene, if needed
dg = bpy.context.evaluated_depsgraph_get()
dg.update()
# ============== "light_spot1"
# create light datablock, set attributes
light_data = bpy.data.lights.new(name="light_spot1", type='SPOT')
light_data.energy = 3000
# create new object with our light datablock
light_object1 = bpy.data.objects.new(name="light_spot1", object_data=light_data)
# link light object
bpy.context.collection.objects.link(light_object1)
# make it active
bpy.context.view_layer.objects.active = light_object1
#change location
light_object1.location = (5, -5, 10)
light_object1.delta_rotation_euler = (1.3, 0, -0.3) #Schauen Sie direkt auf Null Null Null.
# update scene, if needed
dg = bpy.context.evaluated_depsgraph_get()
dg.update()
# ================
#BEWEGEN SIE EIN SPOT LIGHT Spotbeleuchtungsbewegung"light_spot1"
bpy.context.scene.frame_start = 1
bpy.context.scene.frame_end = 30
bpy.context.scene.frame_current = 10
# make light ACTIVE
bpy.context.scene.objects["light_spot3"].select_set(False) # ----- deselect
bpy.context.scene.objects["light_spot2"].select_set(False) # ----- deselect
bpy.context.scene.objects["light_spot1"].select_set(True) #---- select
cdnow = bpy.context.object # get ACTIVE object
bpy.context.scene.frame_current = 1 # set frame to 1
cdnow.location = (5, -6, 8) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 10 # set frame to 10
cdnow.location = (5, -6, 10) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 20 # set frame to 20
cdnow.location = (2, -6, 10)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 30 # set frame to 30
cdnow.location = (5, -6, 8)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
# ================
#BEWEGEN Sie ein LIGHT-Netz mit KEY FRAME Spot 2 Moving Light_spot2
bpy.context.scene.frame_start = 1
bpy.context.scene.frame_end = 30
bpy.context.scene.frame_current = 10
# make POINT light ACTIVE
bpy.context.scene.objects["light_spot3"].select_set(False) # ----- deselect
bpy.context.scene.objects["light_spot1"].select_set(False) # ----- deselect
bpy.context.scene.objects["light_spot2"].select_set(True) #---- select
#cdnow = bpy.context.object # get ACTIVE object
cdnow = bpy.context.scene.objects["light_spot2"] # get ACTIVE object
bpy.context.scene.frame_current = 1 # set frame to 1
cdnow.location = (1,-4,1) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 10 # set frame to 10
cdnow.location = (1,-4,3) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 20 # set frame to 20
cdnow.location = (4,-4,3)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 30 # set frame to 30
cdnow.location = (1,-4,1)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
# ==================
#Bewegen Sie ein Lichtnetz mit KEY FRAME Spot 3 Moving Light_spot3
bpy.context.scene.frame_start = 1
bpy.context.scene.frame_end = 30
bpy.context.scene.frame_current = 10
# make POINT light ACTIVE
bpy.context.scene.objects["light_spot2"].select_set(False) # ----- deselect
bpy.context.scene.objects["light_spot1"].select_set(False) # ----- deselect
bpy.context.scene.objects["light_spot3"].select_set(True) #---- select
#cdnow = bpy.context.object # get ACTIVE object
cdnow = bpy.context.scene.objects["light_spot3"] # get ACTIVE object
bpy.context.scene.frame_current = 1 # set frame to 1
cdnow.location = (5,-6,1) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 10 # set frame to 10
cdnow.location = (9,-6,1) # set the location
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 20 # set frame to 20
cdnow.location = (9,-6,5)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
bpy.context.scene.frame_current = 30 # set frame to 30
cdnow.location = (5,-6,1)
bpy.ops.anim.keyframe_insert_menu(type='Location') # KEY FRAME
# ==================
# world - surface - background (Hintergrund)
bpy.data.worlds["World"].node_tree.nodes["Background"].inputs[0].default_value = (0.01, 0.15, 0.25, 1)
bpy.data.worlds["World"].node_tree.nodes["Background"].inputs[1].default_value = 0.7
#=====
Recommended Posts