Update Files
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class ProbabilisticOutputNode(LnxLogicTreeNode):
|
||||
"""This system activates an output based on probabilistic values,
|
||||
ensuring that the total sum of the probabilities equals 1.
|
||||
If the probabilities do not sum to 1, they will be adjusted
|
||||
accordingly to guarantee a total sum of 1. Only one output will be
|
||||
triggered at a time.
|
||||
|
||||
@input prob: probability of output.
|
||||
@output output: output.
|
||||
|
||||
"""
|
||||
|
||||
bl_idname = 'LNProbabilisticOutputNode'
|
||||
bl_label = 'Probabilistic Output'
|
||||
lnx_section = 'logic'
|
||||
lnx_version = 1
|
||||
|
||||
num_choices: IntProperty(default=0, min=0)
|
||||
|
||||
def __init__(self):
|
||||
array_nodes[str(id(self))] = self
|
||||
|
||||
def lnx_init(self, context):
|
||||
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
row = layout.row(align=True)
|
||||
|
||||
op = row.operator('lnx.node_call_func', text='New', icon='PLUS', emboss=True)
|
||||
op.node_index = str(id(self))
|
||||
op.callback_name = 'add_func'
|
||||
op2 = row.operator('lnx.node_call_func', text='', icon='X', emboss=True)
|
||||
op2.node_index = str(id(self))
|
||||
op2.callback_name = 'remove_func'
|
||||
|
||||
def add_func(self):
|
||||
self.add_input('LnxFloatSocket', f'Prob {self.num_choices}')
|
||||
self.add_output('LnxNodeSocketAction', f'Output {self.num_choices}')
|
||||
self.num_choices += 1
|
||||
|
||||
def remove_func(self):
|
||||
if len(self.inputs) > 1:
|
||||
self.inputs.remove(self.inputs[-1])
|
||||
self.outputs.remove(self.outputs[-1])
|
||||
self.num_choices -= 1
|
||||
|
||||
def draw_label(self) -> str:
|
||||
if self.num_choices == 0:
|
||||
return self.bl_label
|
||||
|
||||
return f'{self.bl_label}: [{self.num_choices}]'
|
||||
|
11
leenkx/blender/lnx/logicnode/random/LN_random_boolean.py
Normal file
11
leenkx/blender/lnx/logicnode/random/LN_random_boolean.py
Normal file
@ -0,0 +1,11 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomBooleanNode(LnxLogicTreeNode):
|
||||
"""Generates a random boolean."""
|
||||
bl_idname = 'LNRandomBooleanNode'
|
||||
bl_label = 'Random Boolean'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxBoolSocket', 'Bool')
|
13
leenkx/blender/lnx/logicnode/random/LN_random_choice.py
Normal file
13
leenkx/blender/lnx/logicnode/random/LN_random_choice.py
Normal file
@ -0,0 +1,13 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomChoiceNode(LnxLogicTreeNode):
|
||||
"""Choose a random value from a given array."""
|
||||
bl_idname = 'LNRandomChoiceNode'
|
||||
bl_label = 'Random Choice'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
|
||||
self.add_input('LnxNodeSocketArray', 'Array')
|
||||
self.add_output('LnxDynamicSocket', 'Value')
|
11
leenkx/blender/lnx/logicnode/random/LN_random_color.py
Normal file
11
leenkx/blender/lnx/logicnode/random/LN_random_color.py
Normal file
@ -0,0 +1,11 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomColorNode(LnxLogicTreeNode):
|
||||
"""Generates a random color."""
|
||||
bl_idname = 'LNRandomColorNode'
|
||||
bl_label = 'Random Color'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_output('LnxColorSocket', 'Color')
|
14
leenkx/blender/lnx/logicnode/random/LN_random_float.py
Normal file
14
leenkx/blender/lnx/logicnode/random/LN_random_float.py
Normal file
@ -0,0 +1,14 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomFloatNode(LnxLogicTreeNode):
|
||||
"""Generates a random float."""
|
||||
bl_idname = 'LNRandomFloatNode'
|
||||
bl_label = 'Random Float'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxFloatSocket', 'Min')
|
||||
self.add_input('LnxFloatSocket', 'Max', default_value=1.0)
|
||||
# self.add_input('LnxIntSocket', 'Seed')
|
||||
self.add_output('LnxFloatSocket', 'Float')
|
13
leenkx/blender/lnx/logicnode/random/LN_random_integer.py
Normal file
13
leenkx/blender/lnx/logicnode/random/LN_random_integer.py
Normal file
@ -0,0 +1,13 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomIntegerNode(LnxLogicTreeNode):
|
||||
"""Generates a random integer."""
|
||||
bl_idname = 'LNRandomIntegerNode'
|
||||
bl_label = 'Random Integer'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxIntSocket', 'Min')
|
||||
self.add_input('LnxIntSocket', 'Max', default_value=2)
|
||||
self.add_output('LnxIntSocket', 'Int')
|
25
leenkx/blender/lnx/logicnode/random/LN_random_output.py
Normal file
25
leenkx/blender/lnx/logicnode/random/LN_random_output.py
Normal file
@ -0,0 +1,25 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomOutputNode(LnxLogicTreeNode):
|
||||
"""Activate a random output when the input is activated."""
|
||||
bl_idname = 'LNRandomOutputNode'
|
||||
bl_label = 'Random Output'
|
||||
lnx_section = 'logic'
|
||||
lnx_version = 1
|
||||
|
||||
def __init__(self):
|
||||
array_nodes[str(id(self))] = self
|
||||
|
||||
def lnx_init(self, context):
|
||||
|
||||
self.add_input('LnxNodeSocketAction', 'In')
|
||||
|
||||
def draw_buttons(self, context, layout):
|
||||
row = layout.row(align=True)
|
||||
|
||||
op = row.operator('lnx.node_add_output', text='New', icon='PLUS', emboss=True)
|
||||
op.node_index = str(id(self))
|
||||
op.socket_type = 'LnxNodeSocketAction'
|
||||
op2 = row.operator('lnx.node_remove_output', text='', icon='X', emboss=True)
|
||||
op2.node_index = str(id(self))
|
25
leenkx/blender/lnx/logicnode/random/LN_random_string.py
Normal file
25
leenkx/blender/lnx/logicnode/random/LN_random_string.py
Normal file
@ -0,0 +1,25 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomStringNode(LnxLogicTreeNode):
|
||||
"""Generate a random string based on a provided characters list.
|
||||
|
||||
@input Length: The length of the string to generate. If the length is
|
||||
0 or negative, an empty string is returned.
|
||||
@input Characters: A string containing the characters from which the
|
||||
random generator can choose. For each letter in the output, the
|
||||
generator randomly samples a character in the input string, so
|
||||
the more often a character occurs in the input, the higher is
|
||||
its chance of appearance in each letter of the result.
|
||||
For example, if you provide `aaab` as a character string,
|
||||
approximately 75% percent of the characters in all generated
|
||||
strings are `a`, the remaining 25% are `b`.
|
||||
"""
|
||||
bl_idname = 'LNRandomStringNode'
|
||||
bl_label = 'Random String'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxIntSocket', 'Length')
|
||||
self.add_input('LnxStringSocket', 'Characters')
|
||||
self.add_output('LnxStringSocket', 'String')
|
13
leenkx/blender/lnx/logicnode/random/LN_random_vector.py
Normal file
13
leenkx/blender/lnx/logicnode/random/LN_random_vector.py
Normal file
@ -0,0 +1,13 @@
|
||||
from lnx.logicnode.lnx_nodes import *
|
||||
|
||||
|
||||
class RandomVectorNode(LnxLogicTreeNode):
|
||||
"""Generates a random vector."""
|
||||
bl_idname = 'LNRandomVectorNode'
|
||||
bl_label = 'Random Vector'
|
||||
lnx_version = 1
|
||||
|
||||
def lnx_init(self, context):
|
||||
self.add_input('LnxVectorSocket', 'Min', default_value=[-1.0, -1.0, -1.0])
|
||||
self.add_input('LnxVectorSocket', 'Max', default_value=[1.0, 1.0, 1.0])
|
||||
self.add_output('LnxVectorSocket', 'Vector')
|
0
leenkx/blender/lnx/logicnode/random/__init__.py
Normal file
0
leenkx/blender/lnx/logicnode/random/__init__.py
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user