armory/blender/arm/logicnode/scene/LN_spawn_collection.py

47 lines
1.8 KiB
Python
Raw Normal View History

2020-09-03 18:53:19 +02:00
import bpy
2020-09-08 23:21:41 +02:00
2020-09-03 18:53:19 +02:00
from arm.logicnode.arm_nodes import *
class SpawnCollectionNode(ArmLogicTreeNode):
2020-09-28 15:58:41 +02:00
"""
2020-10-05 19:55:56 +02:00
Spawns a new instance of the selected collection. Each spawned instance
has an empty owner object to control the instance as a whole (like Blender
uses it for collection instances).
2020-09-28 15:58:41 +02:00
@input In: activates the node.
@input Transform: the transformation of the instance that should be
spawned. Please note that the collection's instance offset is
also taken into account.
@output Out: activated when a collection instance was spawned. It is
not activated when no collection is selected.
@output Top-Level Objects: all objects in the last spawned
collection that are direct children of the owner object of the
collection's instance.
@output All Objects: all objects in the last spawned collection.
@output Owner Object: The owning object of the last spawned
collection's instance.
"""
2020-09-03 18:53:19 +02:00
bl_idname = 'LNSpawnCollectionNode'
bl_label = 'Spawn Collection'
arm_version = 1
2020-09-03 18:53:19 +02:00
property0: PointerProperty(name='Collection', type=bpy.types.Collection)
def init(self, context):
super(SpawnCollectionNode, self).init(context)
2020-09-08 21:49:02 +02:00
self.add_input('ArmNodeSocketAction', 'In')
self.add_input('NodeSocketShader', 'Transform')
2020-09-03 18:53:19 +02:00
2020-09-08 21:49:02 +02:00
self.add_output('ArmNodeSocketAction', 'Out')
self.add_output('ArmNodeSocketArray', 'Top-Level Objects')
self.add_output('ArmNodeSocketArray', 'All Objects')
self.add_output('ArmNodeSocketObject', 'Owner Object')
2020-09-03 18:53:19 +02:00
def draw_buttons(self, context, layout):
layout.prop_search(self, 'property0', bpy.data, 'collections', icon='NONE', text='')
add_node(SpawnCollectionNode, category=PKG_AS_CATEGORY, section='collection')