Skip to content

Instantly share code, notes, and snippets.

@behreajj
behreajj / distorted_suzie_02.py
Last active May 19, 2021 16:51
Distorted Suzanne with Texture and Displace Modifier
import bpy
import bmesh
# Create a Suzanne (monkey head).
bm = bmesh.new()
bmesh.ops.create_monkey(bm)
mesh_data = bpy.data.meshes.new("Suzanne")
bm.to_mesh(mesh_data)
bm.free()
@behreajj
behreajj / distorted_suzie.py
Created May 19, 2021 07:53
Distorted Suzanne
import bpy
import bmesh
from mathutils import noise, Vector
from math import cos, pi, tau
# Create a Suzanne (monkey head).
bm = bmesh.new()
bmesh.ops.create_monkey(bm)
mesh_data = bpy.data.meshes.new("Suzanne")
bm.to_mesh(mesh_data)
@behreajj
behreajj / modified_cube.py
Created May 14, 2021 08:23
Modified Cube
import bpy
import bmesh
# Create a cube.
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=1.0)
mesh_data = bpy.data.meshes.new("Cube")
mesh_data.use_auto_smooth = True
bm.to_mesh(mesh_data)
bm.free()
@behreajj
behreajj / driven_cube.py
Created May 13, 2021 06:17
Driven Cube
import bpy
import bmesh
orbit = 2.0
x_expr = "{0:.2f} * cos(tau * ({1} - {2}) / ({3} - {2} + 1))"
y_expr = "{0:.2f} * sin(tau * ({1} - {2}) / ({3} - {2} + 1))"
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=1.0)
mesh_data = bpy.data.meshes.new("Cube")
@behreajj
behreajj / rotating_cubes.py
Created May 10, 2021 06:10
Rotating Cubes
import bpy
import bmesh
from math import cos, sin, pi, tau
from mathutils import Color, Euler, Quaternion, Vector
rotation_modes = [
'QUATERNION',
'AXIS_ANGLE',
'XYZ', 'XZY', 'YXZ',
@behreajj
behreajj / translating_cubes.py
Last active May 13, 2021 07:10
Translating Cubes
import bpy
import bmesh
import colorsys
frame_rate = 30
sz_cube = 1.0
pts = [
(-8.0, -8.0, 0.0),
(5.0, -5.0, 0.0),
(8.0, 8.0, 0.0),
@behreajj
behreajj / cube_grid_wave_03.py
Created May 10, 2021 05:54
Cube Grid Wave Pt. 3
for mesh_obj in mesh_objs:
anim_data = mesh_obj.animation_data
action = anim_data.action
fcurves = action.fcurves
for fcurve in fcurves:
fcurve.extrapolation = 'LINEAR'
key_frames = fcurve.keyframe_points
for key_frame in key_frames:
@behreajj
behreajj / cube_grid_wave_02.py
Last active May 13, 2021 06:46
Cube Grid Wave Pt. 2
frame_rate = 30
key_frames = 15
kf_to_prc = 1.0 / (key_frames - 1)
scene = bpy.context.scene
frame_start = scene.frame_start
frame_end = scene.frame_end
scene.render.fps = frame_rate
lin_range_3 = range(0, count_sq * key_frames, 1)
@behreajj
behreajj / cube_grid_wave_01.py
Last active May 25, 2021 18:59
Cube Grid Wave Pt. 1
import bpy
import bmesh
import colorsys
from math import sin, sqrt, pi, tau
# Number of cubes.
count = 16
# Size of grid.
extents = 8.0
@behreajj
behreajj / cube_sphere_refactored.py
Created May 10, 2021 05:44
Cube Sphere Refactored
import bpy
from math import cos, sin, sqrt, pi, tau
import bmesh
import colorsys
x_center = 0.0
y_center = 0.0
z_center = 0.0
scale = 8.0