What spiega is about
- Knowledge sharing
- Portfolio
blender animation
The importance of owning the infrastructure
Table of Contents
blender animations
Videos convey a powerful message and 3d animations are an effective way to represent complex processes. Here we develop animations with blender by running simple operations on svg files. Most of the svg files are mermaid diagrams as per implementation diagram.
blender mcp
We want to use the recent mcp capabilities to get support from coding assistants while we work with blender
We need first to run the blender mcp server. There are two addons ahujasid and deshmukh
blender-mcp --host 127.0.0.1 --port 8001 --ollama-url http://localhost:11434 --ollama-model llama3.2
blender-mcp: komando ne trovita
(setq org-adapt-indentation nil)
Blender tasks
chairs
Make a low-poly chair with a wooden material and soft studio lighting.
import bpy
bpy.ops.object.select_all(action='SELECT') bpy.ops.object.delete(use_global=False)
chair = bpy.data.objects.new("Chair", bpy.data.meshes.new("ChairMesh")) bpy.context.collection.objects.link(chair) chair.location = (0, 0, 0)
vertices = [ (-1, -1, 0), # Vertex 0 (1, -1, 0), # Vertex 1 (1, 1, 0),
(-1, 1, 0), # Vertex 3 (-1, -1, -1), # Vertex 4 (1, -1, -1), # Vertex 5 (1, 1, -1), # Vertex 6 (-1, 1, -1) # Vertex 7 ]
edges = [ (0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 7), (7, 4), (0, 4), (1, 5), (2, 6), (3, 7) ]
faces = [ (0, 1, 2, 3), (4, 5, 6, 7), (0, 1, 5, 4), (1, 2, 6, 5), (2, 3, 7, 6), (3, 0, 4, 7) ]
chair_mesh = chair.data chair_mesh.from_pydata(vertices, edges, faces) chair_mesh.update()
wood_material = bpy.data.materials.new(name="WoodMaterial") wood_material.diffuse_color = (0.8, 0.54, 0.35, 1) # Slightly reddish-brown color
if chair.data.materials: chair.data.materials[0] = wood_material else: chair.data.materials.append(wood_material)
bpy.ops.object.light_add(type='POINT', location=(5, 5, 3)) bpy.ops.object.light_add(type='POINT', location=(-5, -5, 3)) bpy.ops.object.light_add(type='POINT', location=(0, 0, 10))
bpy.context.scene.render.resolution_x = 800 bpy.context.scene.render.resolution_y = 600 bpy.context.scene.render.engine = 'BLENDER_EEVEE' bpy.context.scene.eevee.shadow_method = 'NONE' bpy.context.scene.cycles.samples = 12
camera = bpy.data.objects['Camera'] camera.location = (0, 0, 3) camera.rotation_euler = (pi/4, 0, pi/4)
bpy.ops.render.render(write_still=True, filepath="low_poly_chair.png")
blender 2d animations
2d animation is a separate workflow in blender added recently. The main difference is to have a sheet where you can keyframe your drawings.