bpy.ops.anim.keyframe_insert_menu(type='Location')
bullet.location = origin+Vector((0,30,0))
scn.frame_current = 251
bpy.ops.anim.keyframe_insert_menu(type='Location')
scn.frame_current = 1
action = bullet.animation_data.action
for fcu in action.fcurves:
fcu.extrapolation = 'LINEAR'
for kp in fcu.keyframe_points:
kp.interpolation = 'LINEAR'
# Система частиц Trail (след) для пули
bpy.ops.object.particle_system_add()
trail = bullet.particle_systems[0]
trail.name = 'Trail'
fset = trail.settings
# Эмиссия
fset.name = 'TrailSettings'
fset.count = 1000 fset.frame_start = 1
fset.frame_end = 250
fset.lifetime = 25
fset.emit_from = 'FACE'
fset.use_render_emitter = True
# Скорость
fset.normal_factor = 1.0
fset.factor_random = 0.5
# Физика
fset.physics_type = 'NEWTON'
fset.mass = 0
# Установка всех эффекторных весов в ноль
ew = fset.effector_weights
ew.gravity = 0.0
# Не рендерить
fset.draw_method = 'DOT'
fset.render_type = 'NONE'
# -------------- Шар
ball = addSphere('Ball', 1.0, origin)
ball.data.materials.append(red)
# Система частиц
bpy.ops.object.particle_system_add()
react = ball.particle_systems[0]
react.name = 'React'
fset = react.settings
# Эмиссия
fset.name = 'TrailSettings'
fset.count = 50
fset.frame_start = 47
fset.frame_end = 57
fset.lifetime = 250
fset.emit_from = 'FACE'
fset.use_render_emitter = True
# Скорость
fset.normal_factor = 5.0
fset.factor_random = 2.5
# Физика
fset.physics_type = 'NEWTON'
fset.mass = 1.0
# Не рендерить
fset.draw_method = 'CROSS'
fset.render_type = 'NONE'
# Модификатор Explode
mod = ball.modifiers.new(name='Explode', type='EXPLODE')
mod.use_edge_cut = True
mod.show_unborn = True
mod.show_alive = True
mod.show_dead = True
mod.use_size = False
# ---- Скрытый пол с модификатором collision (столкновения)
hidden = addFloor('Hidden', origin+Vector((0,0,-3.9)), True)
mod = hidden.modifiers.new(name='Collision', type='COLLISION')
mset = mod.settings
mset.permeability = 0.01
mset.stickness = 0.1
mset.use_particle_kill = False
mset.damping_factor = 0.6
mset.damping_random = 0.2
mset.friction_factor = 0.3
mset.friction_random = 0.1
addFloor('Floor', Vector((0,0,-4)), False)
return
if __name__ == "__main__":
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Камера, освещение
bpy.ops.object.camera_add(
location = Vector((12,-12,4)),
rotation = Vector((70,0,45))*math.pi/180)
cam = bpy.context.object.data
cam.lens = 35
bpy.ops.object.lamp_add(type='POINT',
location = Vector((11,-7,6)))
bpy.ops.object.lamp_add(type='POINT',
location =Vector((-7,-10,2)))
run(Vector((0,0,0)))