Created
December 5, 2024 14:52
-
-
Save heytulsiprasad/6fae6cf45cc9e27ae9c87beaf0297e31 to your computer and use it in GitHub Desktop.
Demo grid POV synthwave animation 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
import bpy | |
import math | |
# Clear existing objects | |
bpy.ops.object.select_all(action='SELECT') | |
bpy.ops.object.delete(use_global=False) | |
# Create a series of wireframe cubes | |
num_cubes = 20 # Number of cubes | |
spacing = 2.0 # Distance between cubes | |
for i in range(num_cubes): | |
# Add a cube | |
bpy.ops.mesh.primitive_cube_add(size=2.0, location=(0, 0, -i * spacing)) | |
cube = bpy.context.object | |
# Add wireframe modifier | |
wireframe_modifier = cube.modifiers.new(name="Wireframe", type='WIREFRAME') | |
wireframe_modifier.thickness = 0.05 | |
# Add a camera | |
bpy.ops.object.camera_add(location=(0, 0, 5)) | |
camera = bpy.context.object | |
bpy.context.scene.camera = camera | |
# Animate the camera to move through the cubes | |
frame_start = 1 | |
frame_end = 240 # Adjust for longer/shorter animations | |
bpy.context.scene.frame_start = frame_start | |
bpy.context.scene.frame_end = frame_end | |
# Keyframe camera at starting position | |
camera.location.z = 5 | |
camera.keyframe_insert(data_path="location", frame=frame_start) | |
# Keyframe camera at ending position | |
camera.location.z = -spacing * num_cubes | |
camera.keyframe_insert(data_path="location", frame=frame_end) | |
# Set linear interpolation for smooth motion | |
for fcurve in camera.animation_data.action.fcurves: | |
for keyframe in fcurve.keyframe_points: | |
keyframe.interpolation = 'LINEAR' | |
print("Tunnel animation created successfully!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment