Last active
May 17, 2017 17:47
-
-
Save jazzyjackson/ed7dcb351d9ee5f60fb01fe0188a2961 to your computer and use it in GitHub Desktop.
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, 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