Advertisement
yacuken

visualizer blender

Apr 13th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. import bpy
  2.  
  3. rows = 7
  4. columns = 7
  5.  
  6. r = 0
  7. c = 0
  8.  
  9. def spiral(X, Y):
  10.     x = y = 0
  11.     dx = 0
  12.     dy = -1
  13.     for i in range(max(X, Y)**2):
  14.         if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
  15.             bpy.ops.mesh.primitive_cube_add(location = (x, y, 0))
  16.             bpy.ops.view3d.assign_material(matname="Material")
  17.             bpy.context.scene.cursor_location = bpy.context.active_object.location
  18.             bpy.context.scene.cursor_location.z -= 1
  19.             bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
  20.             ###
  21.             bpy.context.active_object.scale.x = 0.5
  22.             bpy.context.active_object.scale.y = 0.5
  23.             bpy.context.active_object.scale.z = 5
  24.             bpy.ops.object.transform_apply(scale=True)
  25.            
  26.             bpy.ops.anim.keyframe_insert_menu(type='Scaling')
  27.             bpy.context.active_object.animation_data.action.fcurves[0].lock = True
  28.             bpy.context.active_object.animation_data.action.fcurves[1].lock = True
  29.            
  30.             bpy.context.area.type = 'GRAPH_EDITOR'
  31.            
  32.             step = 20000/(rows*columns)
  33.             if bpy.ops.graph.sound_bake.poll():
  34.        
  35.                 bpy.ops.graph.sound_bake(filepath="/home/nikita/blends/audiovisual/01 sad robot.mp3", low=i*step, high=i*step+step)
  36.    
  37.             bpy.context.active_object.animation_data.action.fcurves[2].lock = True
  38.         if x == y or (x < 0 and x == -y) or (x > 0 and x == 1-y):
  39.             dx, dy = -dy, dx
  40.         x, y = x+dx, y+dy
  41.        
  42. spiral(rows, columns)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement