Created
May 16, 2013 05:59
-
-
Save cecyurbina/5589679 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 random | |
import bpy#blender libreria | |
from math import pi | |
bpy.ops.object.delete() | |
add_cube = bpy.ops.mesh.primitive_cube_add | |
mylayers = [False]*20 | |
mylayers[0] = True | |
obj = bpy.data.objects['Camera'] | |
obj.location.x = 0.0 | |
obj.location.y = 80 | |
obj.location.z = 0.0 | |
obj.rotation_euler[0] = 4.71 | |
obj.rotation_euler[1] = 0 | |
obj.rotation_euler[2] = 0 | |
obj.keyframe_insert(data_path="location", frame=0.0) | |
def izquierda(obj,f_i, f_f,v): | |
"""movimiento a la izquierda | |
""" | |
obj.keyframe_insert(data_path="location", frame=f_i, index=0) | |
obj.location[0] = obj.location[0] + v | |
x = obj.location[0] | |
y = obj.location[1] | |
z = obj.location[2] | |
obj.keyframe_insert(data_path="location", frame=f_f, index=0) | |
def derecha(obj,f_i, f_f,v): | |
"""movimiento a la derecha | |
""" | |
obj.keyframe_insert(data_path="location", frame=f_i, index=0) | |
obj.location[0] = obj.location[0] - v | |
obj.keyframe_insert(data_path="location", frame=f_f, index=0) | |
def abajo(obj,f_i, f_f,v): | |
"""movimiento hacia abajo | |
""" | |
obj.keyframe_insert(data_path="location", frame=f_i, index=-1) | |
obj.location[2] = obj.location[2] - v | |
obj.keyframe_insert(data_path="location", frame=f_f, index=-1) | |
def arriba(obj,f_i, f_f,v): | |
"""movimiento hacia arriba | |
""" | |
obj.keyframe_insert(data_path="location", frame=f_i, index=-1) | |
#obj.location[2] = random.random()*10 | |
obj.location[2] = obj.location[2] + v | |
obj.keyframe_insert(data_path="location", frame=f_f, index=-1) | |
def acercar(obj,f_i, f_f,v): | |
"""acercar el objeto | |
""" | |
obj.keyframe_insert(data_path="location", frame=f_i, index=-1) | |
obj.location[1] = obj.location[1] - v | |
obj.keyframe_insert(data_path="location", frame=f_f, index=-1) | |
def alejar(obj,f_i, f_f,v): | |
"""alejar el objeto | |
""" | |
obj.keyframe_insert(data_path="location", frame=f_i, index=-1) | |
obj.location[1] = obj.location[1] + v | |
obj.keyframe_insert(data_path="location", frame=f_f, index=-1) | |
for index in range(0, 3): | |
if index >=1: | |
add_cube(location=(index*6, 0, 0), layers=mylayers) | |
else: | |
bpy.ops.mesh.primitive_uv_sphere_add(location=(index*3,0,0)) | |
obj = bpy.context.object | |
f_i= 2 | |
f_f = 5 | |
for i in range(10): | |
eleccion = random.randint(1,6) | |
v = random.randint(2,4) | |
if eleccion == 1: | |
alejar(obj, f_i, f_f,v) | |
elif eleccion == 2: | |
acercar(obj, f_i, f_f,v) | |
elif eleccion == 3: | |
izquierda(obj, f_i, f_f,v) | |
elif eleccion == 4: | |
derecha(obj,f_i, f_f,v) | |
elif eleccion == 5: | |
arriba(obj,f_i, f_f,v) | |
else: | |
abajo(obj,f_i, f_f,v) | |
f_i = f_f + 1 | |
f_f = f_i + 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment