用如下代码可以自动在Blender中生成AnimationNodes动画。视频效果如下
。
bpy.ops.mesh.primitive_monkey_add(location=(0,4,10))
msource = bpy.context.object
if len(mssource.particle_systems) == 0:
bpy.context.view_layer.objects.active = mssource
mssource.modifiers.new("part", type='PARTICLE_SYSTEM')
part = mssource.particle_systems[0]
settings = part.settings
settings.count=200
settings.frame_end=120
settings.lifetime=100
settings.effector_weights.gravity=0
bpy.data.node_groups.new("NodeTree","an_AnimationNodeTree")
bpy.data.node_groups['NodeTree'].name='MyNodeTree'
ng = bpy.data.node_groups['MyNodeTree']
particleSystemsFromObject = ng.nodes.new("an_ParticleSystemsFromObjectNode")
particleSystemsFromObject.location=(-600,0)
particleSystemsFromObject.inputs[0].object=mssource
particleSystemParticlesData = ng.nodes.new("an_ParticleSystemParticlesDataNode")
particleSystemParticlesData.location=(-400,0)