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

2021/7/27 11:06:14

本文主要是介绍在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])

 



这篇关于在Blender中用程式化生成Animation_Nodes动画01的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程