Шрифт:
cset.structural_stiffness = 0.5
cset.bending_stiffness = 0.05
cset.spring_damping = 0
cset.air_damping = 0.3
cset.use_pin_cloth = True
cset.vertex_group_mass = 'Pole'
#Веса эффектора
ew = cset.effector_weights
ew.gravity = 0.1
ew.wind = 1.0 return
def addWindEffector(origin):
# Добавление эффектора ветра
bpy.ops.object.effector_add(
type='WIND',
location=origin,
rotation=(pi/2,0,0))
wind = bpy.context.object
fset = wind.field
fset.strength = -2.0
fset.noise = 10.0
fset.flow = 0.8
fset.shape = 'PLANE'
return
def addFlagMaterial(name, ob, color1, color2):
# Текстура флага
tex = bpy.data.textures.new('Flag', type = 'WOOD')
tex.noise_basis_2 = 'TRI'
tex.wood_type = 'RINGS'
# Создание материала
mat = bpy.data.materials.new(name)
mat.diffuse_color = color1
# Добавление текстурного слота для текстуры цвета
mtex = mat.texture_slots.add
mtex.texture = tex
mtex.
texture_coords = 'ORCO'
mtex.use_map_color_diffuse = True
mtex.color = color2
# Добавление материала к флагу
ob.data.materials.append(mat)
return mat
def createDisplacementTexture(mat):
tex = bpy.data.textures.new('Flag', type = 'WOOD')
tex.noise_basis_2 = 'SIN'
tex.wood_type = 'BANDNOISE'
tex.noise_type = 'SOFT_NOISE'
tex.noise_scale = 0.576
tex.turbulence = 9.0
# Сохранение текстуры в материале для легкого доступа. Не необходимо на самом деле.
mtex = mat.texture_slots.add
mtex.texture = tex
mat.use_textures[1] = False
return tex
def addDisplacementModifier(ob, tex, vgrp, empty):
mod = ob.modifiers.new('Displace', 'DISPLACE')
mod.texture = tex
mod.vertex_group = vgrp
mod.direction = 'NORMAL'
mod.texture_coords = 'OBJECT'
mod.texture_coords_object = empty
mod.mid_level = 0.0
mod.strength = 0.1
print("'%s' '%s'" % (vgrp, mod.vertex_group))
mod.vertex_group = vgrp
print("'%s' '%s'" % (vgrp, mod.vertex_group))
return mod
def createAndAnimateEmpty(origin):
bpy.ops.object.add(type='EMPTY', location=origin)
empty = bpy.context.object
scn = bpy.context.scene
scn.frame_current = 1
bpy.ops.anim.keyframe_insert_menu(type='Location')
scn.frame_current = 26
bpy.ops.transform.translate(value=(1,0,1))
bpy.ops.anim.keyframe_insert_menu(type='Location')
scn.frame_current = 1
for fcu in empty.animation_data.action.fcurves: