Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import random
- #Toutes les variables
- #le calcul des points des lamps
- xl=10
- yl=10
- zl=10
- x=0
- y=0
- z=0
- meshgr=[]
- g=0.1
- #tripatouillage avec le world
- #je fais ca apres
- #efface quelques elements
- #bpy.data.objects['Cube'].select_set(True)
- #bpy.data.objects['Light'].select_set(True)
- #bpy.ops.object.delete()
- #l'ensemble des def
- def addLamp(loc):
- bpy.ops.object.add(radius=1.0, type='LIGHT', enter_editmode=False, align='WORLD', location=loc, rotation=(0.0, 0.0, 0.0))
- bpy.context.object.data.type = 'SUN'
- bpy.context.object.data.energy = 50
- def makeplanet(loc, si):
- bpy.ops.mesh.primitive_uv_sphere_add(segments=64, ring_count=32, radius=si, calc_uvs=True, enter_editmode=False, align='WORLD', location=loc, rotation=(0.0, 0.0, 0.0))
- bpy.ops.object.shade_smooth()
- obj=bpy.ops.object
- ma = random.randint(0,5)
- mat = bpy.data.materials[ma]
- bpy.context.object.data.materials.append(mat)
- #nombre de repetition de la boucle
- def bouclePlanet(loc2):
- (x,y,z)=loc2
- i=0
- g=0.1
- r = random.randint(1,10)
- while i < r:
- t=random.uniform(-1.0,1.0)
- t2=random.uniform(-1.0,1.0)
- t3=random.uniform(-1.0,1.0)
- makeplanet((x,y,z), (g))
- meshgr.append(bpy.context.object)
- x=t3+x
- y=t+y
- z=t2+z
- g=g+0.1
- i=i+1
- return x,y,z,g
- addLamp((xl,yl,zl))
- addLamp((-xl,-yl,zl))
- addLamp((-xl,yl,-zl))
- addLamp((xl,-yl,-zl))
- bouclePlanet((x,y,z))
- print(x,y,z,g)
- bouclePlanet((x,y,z))
- print(x,y,z,g)
- bouclePlanet((x,y,z))
- print(x,y,z,g)
- bouclePlanet((x,y,z))
- print(x,y,z,g)
- obj=bpy.data.objects
- for i in range (12, len(obj)-1):
- bpy.ops.object.select_all(action='DESELECT')
- obj[i].select_set(True)
- obj[i+1].select_set(True)
- bpy.context.view_layer.objects.active = obj[i]
- bpy.ops.object.parent_set()
- for iframe in range (1, 600,100):
- for gritika in meshgr:
- bpy.ops.object.select_all(action='SELECT')
- bpy.ops.anim.keyframe_insert_menu(type='Rotation')
- bpy.ops.object.select_all(action='DESELECT')
- rer=random.uniform(-15.0,15.0)
- rer2=random.uniform(-15.0,15.0)
- rer3=random.uniform(-15.0,15.0)
- gritika.rotation_euler=((rer2, rer3, rer))
- bpy.data.scenes['Scene'].frame_set(iframe+100, subframe=0)
- bpy.ops.object.select_all(action='SELECT')
- bpy.ops.anim.keyframe_insert_menu(type='Rotation')
- bpy.ops.object.select_all(action='DESELECT')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement