Created
December 1, 2023 11:33
-
-
Save santolucito/2007891422e15f45c712416b344b9f0d to your computer and use it in GitHub Desktop.
Flippy donut in blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://youtu.be/9nT23gPfEb8 | |
import bpy | |
import math | |
#delete all objects | |
bpy.ops.object.select_all(action='SELECT') | |
bpy.ops.object.delete() | |
#delete all materials | |
for m in bpy.data.materials: | |
bpy.data.materials.remove(m) | |
bpy.data.materials.new(name="red") | |
bpy.data.materials['red'].diffuse_color = (1, 0, 0, 1) | |
bpy.ops.mesh.primitive_torus_add() | |
myDonut = bpy.context.active_object | |
myDonut.data.materials.append(bpy.data.materials["red"]) | |
myDonut.keyframe_insert("rotation_euler", frame=1) | |
myDonut.rotation_euler[0] = math.pi | |
myDonut.keyframe_insert("rotation_euler", frame=15) | |
myDonut.rotation_euler[1] = math.pi | |
myDonut.keyframe_insert("rotation_euler", frame=30) | |
bpy.ops.object.camera_add(location=(15,15,15)) | |
myCam = bpy.context.active_object | |
bpy.ops.object.constraint_add(type='TRACK_TO') | |
myCam.constraints["Track To"].target = myDonut | |
bpy.ops.object.light_add(type='SPOT', location=(1, 3, 5), scale=(1, 1, 1)) | |
myLight = bpy.context.active_object | |
bpy.ops.object.constraint_add(type='TRACK_TO') | |
myLight.constraints["Track To"].target = myDonut | |
myLight.data.energy = 1000 | |
bpy.context.scene.frame_end = 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment