在Blender中用程式化生成Animation_Nodes动画01

用如下代码可以自动在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)

    
    findClosePoints = ng.nodes.new("an_FindClosePointsNode")
    findClosePoints.location=(-200,0)
    
    
    splinesFromEdges = ng.nodes.new("an_SplinesFromEdgesNode")
    splinesFromEdges.location=(100,0)   
    splinesFromEdges.algorithmType='BRANCH'
    
    
    curveObjectOutput= ng.nodes.new("an_CurveObjectOutputNode")
    curveObjectOutput.location=(400,0)  
    curveObjectOutput.inputs[1].isUsed=True
    curveObjectOutput.inputs[2].isUsed=True
    curveObjectOutput.inputs[0].createObject()
    curveObjectOutput.inputs[2].value=0.5
    #add link
    ng.links.new(particleSystemsFromObject.outputs[0],particleSystemParticlesData.inputs[0])
    ng.links.new(particleSystemParticlesData.outputs[0],findClosePoints.inputs[0])
    #ng.links.new(particleSystemParticlesData.outputs[0],combineMesh.inputs[0])
    ng.links.new(findClosePoints.outputs[0],splinesFromEdges.inputs[1])
    ng.links.new(particleSystemParticlesData.outputs[0],splinesFromEdges.inputs[0])
    ng.links.new(splinesFromEdges.outputs[0],curveObjectOutput.inputs[1])

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值