Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import bpy, numpy
from mathutils import *
radius = 20
n_samples = 25
samples = numpy.random.multivariate_normal([-0.5, -0.5], [[radius, 0],[0, radius]], n_samples)
for point in range(0, len(samples)):
locX = samples[point][0]
locY = samples[point][1]
bpy.ops.mesh.primitive_cube_add(location=(locX,locY,0))
if(numpy.random.sample() > 0.5):
thisSphere = bpy.data.objects[point]
thisSphere.keyframe_insert('location',frame=0)
thisSphere.location += Vector((0,0,10))
thisSphere.keyframe_insert('location',frame=25)
thisSphere.location += Vector((0,0,-10))
thisSphere.keyframe_insert('location',frame=50)
bpy.ops.wm.save_as_mainfile(filepath="./randomCubesAnim.blend")
bpy.ops.export_scene.fbx(filepath="./randomCubesAnim.fbx",
object_types={'MESH','ARMATURE'},
bake_anim_use_nla_strips=False,
bake_anim_use_all_actions=False) # following recommendations from SketchFab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.