import bpy
import math as m
#Determine the final frame
end_frame = 100
#Create a function for particles
def particle_road(p_count = 50000,p_end = end_frame,p_lifetime = end_frame,p_normal_factor = 0,p_gravity = 0):
#Add a particle system
bpy.ops.object.particle_system_add()
#Make various settings
p_s = bpy.context.active_object.particle_systems[0].settings
#Total number of particles
p_s.count = p_count
#Particle end frame
p_s.frame_end = p_end
#Particle duration
p_s.lifetime = p_lifetime
#Particle velocity
p_s.normal_factor = p_normal_factor
#Gravity on particles
p_s.effector_weights.gravity = p_gravity
#Add an emitter
bpy.ops.mesh.primitive_cube_add()
obj = bpy.data.objects["Cube"]
frame_num = 0
bpy.context.scene.frame_end = end_frame
x = 0
y = 0
for i in range(0,end_frame):
bpy.context.scene.frame_set(frame_num)
x += 1
y += 1
obj.location = (x,y,0)
obj.keyframe_insert(data_path = "location",index = -1)
frame_num += 1
#Use the defined function
particle_road()
import bpy
import math as m
end_frame = 300
def particle_road(p_count = 50000,p_end = end_frame,p_lifetime = end_frame,p_normal_factor = 0,p_gravity = 0):
bpy.ops.object.particle_system_add()
p_s = bpy.context.active_object.particle_systems[0].settings
p_s.count = p_count
p_s.frame_end = p_end
p_s.lifetime = p_lifetime
p_s.normal_factor = p_normal_factor
p_s.effector_weights.gravity = p_gravity
bpy.ops.mesh.primitive_cube_add()
obj = bpy.data.objects["Cube"]
frame_num = 0
bpy.context.scene.frame_end = end_frame
#Radius of spiral
r = 30
#How to divide the circumference into equal parts
detail = 24
for i in range(0,end_frame):
rad = 2 * m.pi * i/detail
x = m.cos(rad) * r
y = m.sin(rad) * r
z = i/2
bpy.context.scene.frame_set(frame_num)
obj.location = (x,y,z)
obj.keyframe_insert(data_path = "location",index = -1)
frame_num += 1
particle_road()
import bpy
import math as m
end_frame = 700
def particle_road(p_count = 300000,p_end = end_frame,p_lifetime = end_frame,p_normal_factor = 0,p_gravity = 0):
bpy.ops.object.particle_system_add()
p_s = bpy.context.active_object.particle_systems[0].settings
p_s.count = p_count
p_s.frame_end = p_end
p_s.lifetime = p_lifetime
p_s.normal_factor = p_normal_factor
p_s.effector_weights.gravity = p_gravity
bpy.ops.mesh.primitive_uv_sphere_add()
obj = bpy.data.objects["Sphere"]
frame_num = 0
bpy.context.scene.frame_end = end_frame
#Radius of spiral
r = 1
z = 0
z_speed = 3
detail = 24
for i in range(0,end_frame):
rad = 2 * m.pi * i/detail
x = m.cos(rad) * r
y = m.sin(rad) * r
z += z_speed
if(z > 100 or z < 0):
#Reverse the direction of z
z_speed *= -1
#Expand the radius
r += 10
bpy.context.scene.frame_set(frame_num)
obj.location = (x,y,z)
obj.keyframe_insert(data_path = "location",index = -1)
frame_num += 1
particle_road()
import bpy
import math as m
end_frame = 700
def particle_road(p_count = 50000,p_end = end_frame,p_lifetime = end_frame,p_normal_factor = 0,p_gravity = 0):
bpy.ops.object.particle_system_add()
p_s = bpy.context.active_object.particle_systems[0].settings
p_s.count = p_count
p_s.frame_end = p_end
p_s.lifetime = p_lifetime
p_s.normal_factor = p_normal_factor
p_s.effector_weights.gravity = p_gravity
bpy.ops.mesh.primitive_uv_sphere_add()
obj = bpy.data.objects["Sphere"]
frame_num = 0
bpy.context.scene.frame_end = end_frame
r = 10
z = 0
z_speed = 3
detail = 24
for i in range(0,end_frame):
rad = 2 * m.pi * i/detail
x = (r * i)/30 * m.cos(rad)
y = (r * i)/30 * m.sin(rad)
z = i
bpy.context.scene.frame_set(frame_num)
obj.location = (x,y,z)
obj.keyframe_insert(data_path = "location",index = -1)
frame_num += 1
particle_road()
import bpy
import math as m
end_frame = 500
bpy.ops.mesh.primitive_cube_add()
def particle_road(p_count = 500,p_end = end_frame,p_lifetime = end_frame,p_normal_factor = 0,p_gravity = 0):
bpy.ops.object.particle_system_add()
p_s = bpy.context.active_object.particle_systems[0].settings
p_s.count = p_count
p_s.frame_end = p_end
p_s.lifetime = p_lifetime
p_s.normal_factor = p_normal_factor
p_s.effector_weights.gravity = p_gravity
#Instantiate an object
p_s.render_type = 'OBJECT'
#Instantiate Cube
p_s.instance_object = bpy.data.objects["Cube"]
#Determine the size
p_s.particle_size = 10
#How to adapt random to size
p_s.size_random = 1
bpy.ops.mesh.primitive_uv_sphere_add()
obj = bpy.data.objects["Sphere"]
frame_num = 0
bpy.context.scene.frame_end = end_frame
r = 70
detail = 24
for i in range(0,end_frame):
rad = 2 * m.pi * i/detail
x = m.cos(rad) * r
y = m.sin(rad) * r
z = i * 3
bpy.context.scene.frame_set(frame_num)
obj.location = (x,y,z)
obj.keyframe_insert(data_path = "location",index = -1)
frame_num += 1
particle_road()
import bpy
from random import randint
end_frame = 5000
def particle_road(p_count = 500000,p_end = end_frame,p_lifetime = end_frame,p_normal_factor = 0,p_gravity = 0):
bpy.ops.object.particle_system_add()
p_s = bpy.context.active_object.particle_systems[0].settings
p_s.count = p_count
p_s.frame_end = p_end
p_s.lifetime = p_lifetime
p_s.normal_factor = p_normal_factor
p_s.effector_weights.gravity = p_gravity
bpy.ops.mesh.primitive_cube_add()
obj = bpy.data.objects["Cube"]
frame_num = 0
bpy.context.scene.frame_end = end_frame
x = 0
y = 0
z = 0
for i in range(0,end_frame):
#Randomly select an integer from the range from the first argument to the second argument
m = randint(-20,20)
#If the number of frames divided by 3 is 0
if(i%3 == 0):
x += m
#If the number of frames divided by 3 is 1
elif(i%3 == 1):
y += m
#Otherwise
else:
z += m
bpy.context.scene.frame_set(frame_num)
obj.location = (x,y,z)
obj.keyframe_insert(data_path = "location",index = -1)
frame_num += 1
particle_road()
Recommended Posts