forked from LeenkxTeam/LNXSDK
55 lines
2.2 KiB
Python
55 lines
2.2 KiB
Python
from lnx.logicnode.lnx_nodes import *
|
|
|
|
class PoissonDiskNode(LnxLogicTreeNode):
|
|
"""
|
|
Generates an array of points with a poisson distribution.
|
|
|
|
SampleCube (Sample Rectangle):
|
|
topLeft: Minimum bounding corner position.
|
|
lowerRight: Maximum bounding corner position.
|
|
minimumDistance: Minimum required spatial distance between points.
|
|
pointsPerIteration: Candidate sample attempts per active point before rejection.
|
|
|
|
SampleSphere (Sample Circle):
|
|
center: Sphere center position vector.
|
|
radius: Bounding sphere radius.
|
|
minimumDistance: Minimum required spatial distance between points.
|
|
pointsPerIteration: Candidate sample attempts per active point before rejection.
|
|
"""
|
|
bl_idname = 'LNPoissonDiskNode'
|
|
bl_label = 'Poisson Disk Sampling'
|
|
lnx_section = 'generator'
|
|
lnx_version = 1
|
|
|
|
def remove_extra_inputs(self, context):
|
|
while len(self.inputs) > 3:
|
|
self.inputs.remove(self.inputs[-1])
|
|
if self.property0 in ('Sample Cube', 'Sample Rectangle'):
|
|
self.add_input('LnxVectorSocket', 'Top Left')
|
|
self.add_input('LnxVectorSocket', 'Lower Right')
|
|
else:
|
|
self.add_input('LnxVectorSocket', 'Center')
|
|
self.add_input('LnxFloatSocket', 'Radius')
|
|
|
|
property0: HaxeEnumProperty(
|
|
'property0',
|
|
items = [('Sample Cube', 'Sample Cube', 'Sample Cube'),
|
|
('Sample Sphere', 'Sample Sphere', 'Sample Sphere'),
|
|
('Sample Rectangle', 'Sample Rectangle', 'Sample Rectangle'),
|
|
('Sample Circle', 'Sample Circle', 'Sample Circle')],
|
|
name='', default='Sample Cube', update=remove_extra_inputs)
|
|
|
|
def lnx_init(self, context):
|
|
self.add_input('LnxNodeSocketAction', 'In')
|
|
self.add_input('LnxIntSocket', 'Points Per Iteration')
|
|
self.add_input('LnxFloatSocket', 'Minimum Distance')
|
|
self.add_input('LnxVectorSocket', 'Top Left')
|
|
self.add_input('LnxVectorSocket', 'Lower Right')
|
|
|
|
self.add_output('LnxNodeSocketAction', 'Out')
|
|
self.add_output('LnxNodeSocketArray', 'Points')
|
|
self.add_output('LnxIntSocket', 'Length')
|
|
|
|
def draw_buttons(self, context, layout):
|
|
layout.prop(self, 'property0')
|