Thanks!
Separator Out
is a switch for displaying the resulting data. It does not carry any mathematical operations, it is just an appeal to the fields of the Vec4
class. In the math node, I think it’s convenient.
I think this makes sense, I’ll leave it as it was.
Not really difficult. =)
- If it’s about mathematical operations, then they are partially similar to operations with vectors, and many have already been implemented in Kha. If you want to read on quaternions, then I recommend this article.
- If about the formation of nodes, then I will try to briefly describe, it may be useful. If you’re not interested, skip it.
It should be understood that the list (array) of input and output parameters can be changed at any time. There is only a problem with outputs
, which I wrote about here.
For example, to display the list of operations, EnumProperty
is used, which has the ability to specify the set
, get
functions (all Properties
have them). Thus, we get control over saving the results of the selection and displaying it, and over the event selected from the list. As a result:
def get_enum(self):
return self['property0'] # get the selected value
# Value – the order number in the items list
def set_enum(self, value):
select_current = self.get_enum_id_value(self, 'property0', value)
select_prev = self.property0
# Checking the choice of another operation, in case the same value was chosen, nothing changed
if select_prev != select_current:
# Examples of removing the last item in a list
self.inputs.remove(self.inputs.values()[-1])
self.outputs.remove(self.outputs.values()[-1])
# Checking which operation is selected
if (select_current == 'Lerp') or (select_current == 'Slerp'):
self.add_input('NodeSocketVector', 'From')
self.add_input('NodeSocketVector', 'To')
self.add_input('NodeSocketFloat', 'T')
if (select_current == 'FromAxisAngle'):
self.add_input('NodeSocketVector', 'Quaternion')
self.add_input('NodeSocketVector', 'Axis')
self.add_input('NodeSocketFloat', 'Angle')
self['property0'] = value # save select
property0: EnumProperty(
items = [('Add', 'Add', 'Add'),
('Subtract', 'Subtract', 'Subtract'),
('Lerp', 'Lerp', 'Lerp'),
('Slerp', 'Slerp', 'Slerp'),
('FromAxisAngle', 'From Axis Angle', 'From Axis Angle')],
name='', default='Add', set=set_enum, get=get_enum)
Function for deriving an identifier from the EnumProperty items:
@staticmethod
def get_enum_id_value(obj, prop_name, value):
return obj.bl_rna.properties[prop_name].enum_items[value].identifier
If you delete the parameters, then the connections disappear, so you can control this too. For example, if there was an Add
operation, but Subtract
was selected, and other nodes were connected to the parameters, then it is not necessary to delete inputs
.
Blender already renders the display of inputs
and outputs
.
I hope I explained clearly. 