misc_nodes_ui.py 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. import bpy
  2. from bpy.types import Node
  3. from .base_definitions import MantisUINode, get_signature_from_edited_tree
  4. from .utilities import (prRed, prGreen, prPurple, prWhite,
  5. prOrange,
  6. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  7. wrapOrange,)
  8. def TellClasses():
  9. return [ InputFloatNode,
  10. InputIntNode,
  11. InputVectorNode,
  12. InputBooleanNode,
  13. InputBooleanThreeTupleNode,
  14. InputRotationOrderNode,
  15. InputTransformSpaceNode,
  16. InputStringNode,
  17. InputMatrixNode,
  18. # InputGeometryNode,
  19. InputExistingGeometryObjectNode,
  20. InputExistingGeometryDataNode,
  21. UtilityGeometryOfXForm,
  22. UtilityNameOfXForm,
  23. # ComposeMatrixNode,
  24. MetaRigMatrixNode,
  25. UtilityPointFromCurve,
  26. UtilityMatrixFromCurve,
  27. UtilityMatricesFromCurve,
  28. UtilityNumberOfCurveSegments,
  29. UtilityMatrixFromCurveSegment,
  30. UtilityKDChoosePoint,
  31. UtilityKDChooseXForm,
  32. # ScaleBoneLengthNode,
  33. UtilityMetaRigNode,
  34. UtilityBonePropertiesNode,
  35. UtilityDriverVariableNode,
  36. UtilityFCurveNode,
  37. UtilityDriverNode,
  38. UtilitySwitchNode,
  39. UtilityKeyframe,
  40. UtilityCombineThreeBoolNode,
  41. UtilityCombineVectorNode,
  42. UtilitySeparateVector,
  43. UtilityCatStringsNode,
  44. UtilityGetBoneLength,
  45. UtilityPointFromBoneMatrix,
  46. UtilitySetBoneLength,
  47. UtilityMatrixSetLocation,
  48. UtilityMatrixGetLocation,
  49. UtilityMatrixFromXForm,
  50. UtilityAxesFromMatrix,
  51. UtilityBoneMatrixHeadTailFlip,
  52. UtilityMatrixTransform,
  53. UtilityTransformationMatrix,
  54. UtilitySetBoneMatrixTail,
  55. UtilityIntToString,
  56. UtilityArrayGet,
  57. UtilityArrayLength,
  58. #
  59. UtilityCompare,
  60. UtilityChoose,
  61. # for testing
  62. UtilityPrint,
  63. ]
  64. def default_traverse(self,socket):
  65. return None
  66. class InputFloatNode(Node, MantisUINode):
  67. '''A node representing inheritance'''
  68. bl_idname = 'InputFloatNode'
  69. bl_label = "Float"
  70. bl_icon = 'NODE'
  71. initialized : bpy.props.BoolProperty(default = False)
  72. mantis_node_class_name=bl_idname[:-4]
  73. def init(self, context):
  74. self.outputs.new('FloatSocket', "Float Input").input = True
  75. self.initialized = True
  76. class InputIntNode(Node, MantisUINode):
  77. '''A node representing inheritance'''
  78. bl_idname = 'InputIntNode'
  79. bl_label = "Integer"
  80. bl_icon = 'NODE'
  81. initialized : bpy.props.BoolProperty(default = False)
  82. mantis_node_class_name=bl_idname
  83. def init(self, context):
  84. self.outputs.new('IntSocket', "Integer").input = True
  85. self.initialized = True
  86. class InputVectorNode(Node, MantisUINode):
  87. '''A node representing inheritance'''
  88. bl_idname = 'InputVectorNode'
  89. bl_label = "Vector"
  90. bl_icon = 'NODE'
  91. initialized : bpy.props.BoolProperty(default = False)
  92. mantis_node_class_name=bl_idname[:-4]
  93. def init(self, context):
  94. self.outputs.new('VectorSocket', "").input = True
  95. self.initialized = True
  96. class InputBooleanNode(Node, MantisUINode):
  97. '''A node representing inheritance'''
  98. bl_idname = 'InputBooleanNode'
  99. bl_label = "Boolean"
  100. bl_icon = 'NODE'
  101. initialized : bpy.props.BoolProperty(default = False)
  102. mantis_node_class_name=bl_idname[:-4]
  103. def init(self, context):
  104. self.outputs.new('BooleanSocket', "").input = True
  105. self.initialized = True
  106. class InputBooleanThreeTupleNode(Node, MantisUINode):
  107. '''A node representing inheritance'''
  108. bl_idname = 'InputBooleanThreeTupleNode'
  109. bl_label = "Boolean Vector"
  110. bl_icon = 'NODE'
  111. initialized : bpy.props.BoolProperty(default = False)
  112. mantis_node_class_name=bl_idname[:-4]
  113. def init(self, context):
  114. self.outputs.new('BooleanThreeTupleSocket', "")
  115. self.initialized = True
  116. class InputRotationOrderNode(Node, MantisUINode):
  117. '''A node representing inheritance'''
  118. bl_idname = 'InputRotationOrderNode'
  119. bl_label = "Rotation Order"
  120. bl_icon = 'NODE'
  121. initialized : bpy.props.BoolProperty(default = False)
  122. mantis_node_class_name=bl_idname[:-4]
  123. def init(self, context):
  124. self.outputs.new('RotationOrderSocket', "").input = True
  125. self.initialized = True
  126. class InputTransformSpaceNode(Node, MantisUINode):
  127. '''A node representing inheritance'''
  128. bl_idname = 'InputTransformSpaceNode'
  129. bl_label = "Transform Space"
  130. bl_icon = 'NODE'
  131. initialized : bpy.props.BoolProperty(default = False)
  132. mantis_node_class_name=bl_idname[:-4]
  133. def init(self, context):
  134. self.outputs.new('TransformSpaceSocket', "").input = True
  135. self.initialized = True
  136. class InputStringNode(Node, MantisUINode):
  137. '''A node representing inheritance'''
  138. bl_idname = 'InputStringNode'
  139. bl_label = "String"
  140. bl_icon = 'NODE'
  141. initialized : bpy.props.BoolProperty(default = False)
  142. mantis_node_class_name=bl_idname[:-4]
  143. def init(self, context):
  144. self.outputs.new('StringSocket', "").input = True
  145. self.initialized = True
  146. class InputMatrixNode(Node, MantisUINode):
  147. '''A node representing inheritance'''
  148. bl_idname = 'InputMatrixNode'
  149. bl_label = "Matrix"
  150. bl_icon = 'NODE'
  151. first_row : bpy.props.FloatVectorProperty(name="", size=4, default = (1.0, 0.0, 0.0, 0.0,))
  152. second_row : bpy.props.FloatVectorProperty(name="", size=4, default = (0.0, 1.0, 0.0, 0.0,))
  153. third_row : bpy.props.FloatVectorProperty(name="", size=4, default = (0.0, 0.0, 1.0, 0.0,))
  154. fourth_row : bpy.props.FloatVectorProperty(name="", size=4, default = (0.0, 0.0, 0.0, 1.0,))
  155. initialized : bpy.props.BoolProperty(default = False)
  156. mantis_node_class_name=bl_idname[:-4]
  157. def set_matrix(self):
  158. return (self.first_row[ 0], self.first_row[ 1], self.first_row[ 2], self.first_row[ 3],
  159. self.second_row[0], self.second_row[1], self.second_row[2], self.second_row[3],
  160. self.third_row[ 0], self.third_row[ 1], self.third_row[ 2], self.third_row[ 3],
  161. self.fourth_row[0], self.fourth_row[1], self.fourth_row[2], self.fourth_row[3],)
  162. def init(self, context):
  163. self.outputs.new('MatrixSocket', "Matrix")
  164. self.initialized = True
  165. def draw_buttons(self, context, layout):
  166. # return
  167. layout.prop(self, "first_row")
  168. layout.prop(self, "second_row")
  169. layout.prop(self, "third_row")
  170. layout.prop(self, "fourth_row")
  171. def update(self):
  172. mat_sock = self.outputs[0]
  173. mat_sock.default_value = self.set_matrix()
  174. class ScaleBoneLengthNode(Node, MantisUINode):
  175. '''Scale Bone Length'''
  176. bl_idname = 'ScaleBoneLength'
  177. bl_label = "Scale Bone Length"
  178. bl_icon = 'NODE'
  179. initialized : bpy.props.BoolProperty(default = False)
  180. # === Optional Functions ===
  181. def init(self, context):
  182. self.inputs.new('MatrixSocket', "In Matrix")
  183. self.inputs.new('FloatSocket', "Factor")
  184. self.outputs.new('MatrixSocket', "Out Matrix")
  185. self.initialized = True
  186. class MetaRigMatrixNode(Node, MantisUINode):
  187. # Identical to the above, except
  188. '''A node representing a bone's matrix'''
  189. bl_idname = 'MetaRigMatrixNode'
  190. bl_label = "Matrix"
  191. bl_icon = 'NODE'
  192. first_row : bpy.props.FloatVectorProperty(name="", size=4, default = (1.0, 0.0, 0.0, 0.0,))
  193. second_row : bpy.props.FloatVectorProperty(name="", size=4, default = (0.0, 1.0, 0.0, 0.0,))
  194. third_row : bpy.props.FloatVectorProperty(name="", size=4, default = (0.0, 0.0, 1.0, 0.0,))
  195. fourth_row : bpy.props.FloatVectorProperty(name="", size=4, default = (0.0, 0.0, 0.0, 1.0,))
  196. initialized : bpy.props.BoolProperty(default = False)
  197. mantis_node_class_name="UtilityMetaRig"
  198. def set_matrix(self):
  199. return (self.first_row[ 0], self.first_row[ 1], self.first_row[ 2], self.first_row[ 3],
  200. self.second_row[0], self.second_row[1], self.second_row[2], self.second_row[3],
  201. self.third_row[ 0], self.third_row[ 1], self.third_row[ 2], self.third_row[ 3],
  202. self.fourth_row[0], self.fourth_row[1], self.fourth_row[2], self.fourth_row[3],)
  203. def init(self, context):
  204. self.outputs.new('MatrixSocket', "Matrix")
  205. self.initialized = True
  206. def update(self):
  207. mat_sock = self.outputs[0]
  208. mat_sock.default_value = self.set_matrix()
  209. class UtilityMatrixFromCurve(Node, MantisUINode):
  210. """Gets a matrix from a curve."""
  211. bl_idname = "UtilityMatrixFromCurve"
  212. bl_label = "Matrix from Curve"
  213. bl_icon = "NODE"
  214. initialized : bpy.props.BoolProperty(default = False)
  215. mantis_node_class_name=bl_idname
  216. def init(self, context):
  217. curv = self.inputs.new("EnumCurveSocket", "Curve")
  218. self.inputs.new('IntSocket', 'Total Divisions')
  219. self.inputs.new('IntSocket', 'Matrix Index')
  220. self.outputs.new("MatrixSocket", "Matrix")
  221. self.initialized = True
  222. class UtilityPointFromCurve(Node, MantisUINode):
  223. """Gets a point from a curve."""
  224. bl_idname = "UtilityPointFromCurve"
  225. bl_label = "Point from Curve"
  226. bl_icon = "NODE"
  227. initialized : bpy.props.BoolProperty(default = False)
  228. mantis_node_class_name=bl_idname
  229. def init(self, context):
  230. curv = self.inputs.new("EnumCurveSocket", "Curve")
  231. self.inputs.new('FloatFactorSocket', 'Factor')
  232. self.outputs.new("VectorSocket", "Point")
  233. self.initialized = True
  234. class UtilityNumberOfCurveSegments(Node, MantisUINode):
  235. """Tells the number of segments in a curve."""
  236. bl_idname = "UtilityNumberOfCurveSegments"
  237. bl_label = "Number of Curve Segments"
  238. bl_icon = "NODE"
  239. initialized : bpy.props.BoolProperty(default = False)
  240. mantis_node_class_name=bl_idname
  241. def init(self, context):
  242. self.inputs.new("EnumCurveSocket", "Curve")
  243. self.inputs.new('UnsignedIntSocket', 'Spline Index')
  244. self.outputs.new("UnsignedIntSocket", "Number of Segments")
  245. self.initialized = True
  246. class UtilityMatrixFromCurveSegment(Node, MantisUINode):
  247. """Gets a matrix from a curve segment."""
  248. bl_idname = "UtilityMatrixFromCurveSegment"
  249. bl_label = "Matrix from Curve Segment"
  250. bl_icon = "NODE"
  251. initialized : bpy.props.BoolProperty(default = False)
  252. mantis_node_class_name=bl_idname
  253. def init(self, context):
  254. self.inputs.new("EnumCurveSocket", "Curve")
  255. self.inputs.new('UnsignedIntSocket', 'Spline Index')
  256. self.inputs.new('UnsignedIntSocket', 'Segment Index')
  257. self.outputs.new("MatrixSocket", "Matrix")
  258. self.initialized = True
  259. class UtilityMatricesFromCurve(Node, MantisUINode):
  260. """Gets a matrix from a curve."""
  261. bl_idname = "UtilityMatricesFromCurve"
  262. bl_label = "Matrices from Curve"
  263. bl_icon = "NODE"
  264. initialized : bpy.props.BoolProperty(default = False)
  265. mantis_node_class_name=bl_idname
  266. def init(self, context):
  267. curv = self.inputs.new("EnumCurveSocket", "Curve")
  268. curv.icon = "OUTLINER_OB_CURVE"
  269. self.inputs.new('IntSocket', 'Total Divisions')
  270. o = self.outputs.new("MatrixSocket", "Matrices")
  271. o.display_shape = 'SQUARE_DOT'
  272. self.initialized = True
  273. def display_update_choose_nearest(self, parsed_tree, context):
  274. number_of_points = self.inputs['Number to Find'].default_value
  275. if self.inputs["Number to Find"].is_linked:
  276. mantis_node = parsed_tree.get(get_signature_from_edited_tree(self, context))
  277. number_of_points = mantis_node.evaluate_input("Number to Find")
  278. elif number_of_points == 0:
  279. self.inputs['Number to Find'].default_value=1
  280. if number_of_points > 1:
  281. # then we need to make it an array out
  282. self.outputs.display_shape = 'SQUARE_DOT'
  283. else:
  284. self.outputs.display_shape = 'CIRCLE'
  285. class UtilityKDChoosePoint(Node, MantisUINode):
  286. """Chooses the nearest point with a KD Tree."""
  287. bl_idname = "UtilityKDChoosePoint"
  288. bl_label = "Choose Nearest Point"
  289. bl_icon = "NODE"
  290. initialized : bpy.props.BoolProperty(default = False)
  291. mantis_node_class_name=bl_idname
  292. def init(self, context):
  293. self.inputs.new("VectorSocket", "Reference Point")
  294. a = self.inputs.new('VectorSocket', 'Points', use_multi_input=True)
  295. a.display_shape='SQUARE_DOT'
  296. s = self.inputs.new("UnsignedIntSocket", "Number to Find")
  297. s.default_value=1
  298. self.outputs.new("VectorSocket", "Result Point")
  299. self.outputs.new("UnsignedIntSocket", "Result Index")
  300. self.outputs.new("FloatSocket", "Result Distance")
  301. self.initialized = True
  302. def display_update(self, parsed_tree, context):
  303. display_update_choose_nearest(self, parsed_tree, context)
  304. class UtilityKDChooseXForm(Node, MantisUINode):
  305. """Chooses the nearest xForm with a KD Tree."""
  306. bl_idname = "UtilityKDChooseXForm"
  307. bl_label = "Choose Nearest xForm"
  308. bl_icon = "NODE"
  309. initialized : bpy.props.BoolProperty(default = False)
  310. mantis_node_class_name=bl_idname
  311. def init(self, context):
  312. self.inputs.new("VectorSocket", "Reference Point")
  313. self.inputs.new('xFormSocket', 'xForm Nodes', use_multi_input=True)
  314. self.inputs.new("FloatFactorSocket", "Get Point Head/Tail")
  315. s = self.inputs.new("UnsignedIntSocket", "Number to Find")
  316. s.default_value=1
  317. self.outputs.new("xFormSocket", "Result xForm")
  318. self.outputs.new("UnsignedIntSocket", "Result Index")
  319. self.outputs.new("FloatSocket", "Result Distance")
  320. self.initialized = True
  321. def display_update(self, parsed_tree, context):
  322. display_update_choose_nearest(self, parsed_tree, context)
  323. class UtilityMetaRigNode(Node, MantisUINode):
  324. """Gets a matrix from a meta-rig bone."""
  325. bl_idname = "UtilityMetaRig"
  326. bl_label = "Meta-Rig"
  327. bl_icon = "NODE"
  328. armature:bpy.props.StringProperty()
  329. pose_bone:bpy.props.StringProperty()
  330. initialized : bpy.props.BoolProperty(default = False)
  331. mantis_node_class_name=bl_idname
  332. def init(self, context):
  333. armt = self.inputs.new("EnumMetaRigSocket", "Meta-Armature")
  334. bone = self.inputs.new("EnumMetaBoneSocket", "Meta-Bone")
  335. bone.hide=True
  336. self.outputs.new("MatrixSocket", "Matrix")
  337. self.initialized = True
  338. def display_update(self, parsed_tree, context):
  339. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  340. if nc:
  341. self.armature= nc.evaluate_input("Meta-Armature")
  342. self.pose_bone= nc.evaluate_input("Meta-Bone")
  343. if not self.armature:
  344. self.inputs["Meta-Bone"].hide=True
  345. else:
  346. self.inputs["Meta-Bone"].hide=False
  347. if self.inputs["Meta-Armature"].is_linked:
  348. self.inputs["Meta-Armature"].search_prop = None
  349. if self.inputs["Meta-Bone"].is_linked:
  350. self.inputs["Meta-Bone"].search_prop = None
  351. class UtilityBonePropertiesNode(Node, MantisUINode):
  352. """Provides as sockets strings identifying bone transform properties."""
  353. bl_idname = "UtilityBoneProperties"
  354. bl_label = "Bone Properties"
  355. bl_icon = "NODE"
  356. #bl_width_default = 250
  357. initialized : bpy.props.BoolProperty(default = False)
  358. mantis_node_class_name=bl_idname
  359. def init(self, context):
  360. self.outputs.new("StringSocket", "matrix")
  361. self.outputs.new("StringSocket", "matrix_local")
  362. self.outputs.new("StringSocket", "matrix_basis")
  363. self.outputs.new("StringSocket", "head")
  364. self.outputs.new("StringSocket", "tail")
  365. self.outputs.new("StringSocket", "length")
  366. self.outputs.new("StringSocket", "rotation")
  367. self.outputs.new("StringSocket", "location")
  368. self.outputs.new("StringSocket", "scale")
  369. self.initialized = True
  370. class UtilityDriverVariableNode(Node, MantisUINode):
  371. """Creates a variable for use in a driver."""
  372. bl_idname = "UtilityDriverVariable"
  373. bl_label = "Driver Variable"
  374. bl_icon = "NODE"
  375. initialized : bpy.props.BoolProperty(default = False)
  376. mantis_node_class_name=bl_idname
  377. def init(self, context):
  378. self.inputs.new("EnumDriverVariableType", "Variable Type") # 0
  379. self.inputs.new("ParameterStringSocket", "Property") # 1
  380. self.inputs.new("IntSocket", "Property Index") # 2
  381. self.inputs.new("EnumDriverVariableEvaluationSpace", "Evaluation Space") # 3
  382. self.inputs.new("EnumDriverRotationMode", "Rotation Mode") # 4
  383. self.inputs.new("xFormSocket", "xForm 1") # 5
  384. self.inputs.new("xFormSocket", "xForm 2") # 6
  385. self.outputs.new("DriverVariableSocket", "Driver Variable")
  386. self.inputs[3].hide = True
  387. self.initialized = True
  388. def display_update(self, parsed_tree, context):
  389. if self.inputs["Variable Type"].is_linked:
  390. if context.space_data:
  391. node_tree = context.space_data.path[0].node_tree
  392. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  393. if nc:
  394. driver_type = nc.evaluate_input("Variable Type")
  395. else:
  396. driver_type = self.inputs[0].default_value
  397. if driver_type == 'SINGLE_PROP':
  398. self.inputs[1].hide = False
  399. self.inputs[2].hide = False
  400. self.inputs[3].hide = False
  401. self.inputs[4].hide = False
  402. self.inputs[5].hide = False
  403. self.inputs[6].hide = True
  404. elif driver_type == 'LOC_DIFF':
  405. self.inputs[1].hide = True
  406. self.inputs[2].hide = True
  407. self.inputs[3].hide = True
  408. self.inputs[4].hide = True
  409. self.inputs[5].hide = False
  410. self.inputs[6].hide = False
  411. elif driver_type == 'ROTATION_DIFF':
  412. self.inputs[1].hide = True
  413. self.inputs[2].hide = True
  414. self.inputs[3].hide = True
  415. self.inputs[4].hide = False
  416. self.inputs[5].hide = False
  417. self.inputs[6].hide = False
  418. elif driver_type == 'TRANSFORMS':
  419. self.inputs[1].hide = True
  420. self.inputs[2].hide = True
  421. self.inputs[3].hide = False
  422. self.inputs[4].hide = False
  423. self.inputs[5].hide = False
  424. self.inputs[6].hide = True
  425. # TODO: make a way to edit the fCurve directly.
  426. # I had a working version of this in the past, but it required doing sinful things like
  427. # keeping track of the RAM address of the window.
  428. class UtilityFCurveNode(Node, MantisUINode):
  429. """Creates an fCurve for use with a driver."""
  430. bl_idname = "UtilityFCurve"
  431. bl_label = "fCurve"
  432. bl_icon = "NODE"
  433. use_kf_nodes : bpy.props.BoolProperty(default=True)
  434. initialized : bpy.props.BoolProperty(default = False)
  435. mantis_node_class_name=bl_idname
  436. def init(self, context):
  437. self.inputs.new("eFCrvExtrapolationMode", "Extrapolation Mode")
  438. self.outputs.new("FCurveSocket", "fCurve")
  439. self.initialized = True
  440. def draw_buttons(self, context, layout):
  441. layout.operator( 'mantis.fcurve_node_add_kf' )
  442. if (len(self.inputs) > 1):
  443. layout.operator( 'mantis.fcurve_node_remove_kf' )
  444. class UtilityDriverNode(Node, MantisUINode):
  445. """Represents a Driver relationship"""
  446. bl_idname = "UtilityDriver"
  447. bl_label = "Driver"
  448. bl_icon = "NODE"
  449. initialized : bpy.props.BoolProperty(default = False)
  450. mantis_node_class_name=bl_idname
  451. def init(self, context):
  452. self.inputs.new("EnumDriverType", "Driver Type")
  453. self.inputs.new("FCurveSocket", "fCurve")
  454. self.inputs.new("StringSocket", "Expression")
  455. self.outputs.new("DriverSocket", "Driver")
  456. self.initialized = True
  457. def display_update(self, parsed_tree, context):
  458. if not self.inputs["Driver Type"].is_linked:
  459. dType = self.inputs["Driver Type"].default_value
  460. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  461. if nc:
  462. dType = nc.evaluate_input("Driver Type")
  463. if dType == 'SCRIPTED':
  464. self.inputs["Expression"].hide = False
  465. else:
  466. self.inputs["Expression"].hide = True
  467. def draw_buttons(self, context, layout):
  468. # return
  469. layout.operator( 'mantis.driver_node_add_variable' )
  470. if (len(self.inputs) > 3):
  471. layout.operator( 'mantis.driver_node_remove_variable' )
  472. class UtilitySwitchNode(Node, MantisUINode):
  473. """Represents a switch relationship between one driver property and one or more driven properties."""
  474. bl_idname = "UtilitySwitch"
  475. bl_label = "Switch"
  476. bl_icon = "NODE"
  477. initialized : bpy.props.BoolProperty(default = False)
  478. mantis_node_class_name=bl_idname
  479. def init(self, context):
  480. # self.inputs.new("xFormSocket", "xForm")
  481. self.inputs.new("ParameterStringSocket", "Parameter")
  482. self.inputs.new("IntSocket", "Parameter Index")
  483. self.inputs.new("BooleanSocket", "Invert Switch")
  484. self.outputs.new("DriverSocket", "Driver")
  485. self.initialized = True
  486. class UtilityCombineThreeBoolNode(Node, MantisUINode):
  487. """Combines three booleans into a three-bool."""
  488. bl_idname = "UtilityCombineThreeBool"
  489. bl_label = "CombineThreeBool"
  490. bl_icon = "NODE"
  491. initialized : bpy.props.BoolProperty(default = False)
  492. mantis_node_class_name=bl_idname
  493. def init(self, context):
  494. self.inputs.new("BooleanSocket", "X")
  495. self.inputs.new("BooleanSocket", "Y")
  496. self.inputs.new("BooleanSocket", "Z")
  497. self.outputs.new("BooleanThreeTupleSocket", "Three-Bool")
  498. self.initialized = True
  499. class UtilityCombineVectorNode(Node, MantisUINode):
  500. """Combines three floats into a vector."""
  501. bl_idname = "UtilityCombineVector"
  502. bl_label = "CombineVector"
  503. bl_icon = "NODE"
  504. initialized : bpy.props.BoolProperty(default = False)
  505. mantis_node_class_name=bl_idname
  506. def init(self, context):
  507. self.inputs.new("FloatSocket", "X")
  508. self.inputs.new("FloatSocket", "Y")
  509. self.inputs.new("FloatSocket", "Z")
  510. self.outputs.new("VectorSocket", "Vector")
  511. self.initialized = True
  512. class UtilitySeparateVector(Node, MantisUINode):
  513. """Separates a vector into three floats"""
  514. bl_idname = "UtilitySeparateVector"
  515. bl_label = "Separate Vector"
  516. bl_icon = "NODE"
  517. initialized : bpy.props.BoolProperty(default = False)
  518. mantis_node_class_name=bl_idname
  519. def init(self, context):
  520. self.inputs.new("VectorSocket", "Vector")
  521. self.outputs.new("FloatSocket", "X")
  522. self.outputs.new("FloatSocket", "Y")
  523. self.outputs.new("FloatSocket", "Z")
  524. self.initialized = True
  525. class UtilityCatStringsNode(Node, MantisUINode):
  526. """Adds a suffix to a string"""
  527. bl_idname = "UtilityCatStrings"
  528. bl_label = "Concatenate Strings"
  529. bl_icon = "NODE"
  530. initialized : bpy.props.BoolProperty(default = False)
  531. mantis_node_class_name=bl_idname
  532. def init(self, context):
  533. self.inputs.new("StringSocket", "String_1")
  534. self.inputs.new("StringSocket", "String_2")
  535. self.outputs.new("StringSocket", "OutputString")
  536. self.initialized = True
  537. def draw_label(self): # this will prefer a user-set label, or return the evaluated name
  538. if self.label:
  539. return self.label
  540. if self.outputs['OutputString'].display_text:
  541. return self.outputs['OutputString'].display_text
  542. return self.name
  543. def display_update(self, parsed_tree, context):
  544. if context.space_data:
  545. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  546. self.inputs['String_1'].display_text = ""
  547. self.inputs['String_2'].display_text = ""
  548. self.outputs['OutputString'].display_text = ""
  549. if nc:
  550. try:
  551. self.inputs['String_1'].display_text = a = nc.evaluate_input("String_1")
  552. self.inputs['String_2'].display_text = b = nc.evaluate_input("String_2")
  553. # cat the strings here, since the node may not have run yet.
  554. self.outputs['OutputString'].display_text = a+b
  555. except KeyError:
  556. return # the tree isn't ready yet.
  557. class InputLayerMaskNode(Node, MantisUINode):
  558. """Represents a layer mask for a bone."""
  559. bl_idname = "InputLayerMaskNode"
  560. bl_label = "Layer Mask"
  561. bl_icon = "NODE"
  562. initialized : bpy.props.BoolProperty(default = False)
  563. mantis_node_class_name=bl_idname
  564. def init(self, context):
  565. self.outputs.new("LayerMaskInputSocket", "Layer Mask")
  566. self.initialized = True
  567. class InputExistingGeometryObjectNode(Node, MantisUINode):
  568. """Represents an existing geometry object from within the scene."""
  569. bl_idname = "InputExistingGeometryObject"
  570. bl_label = "Existing Object"
  571. bl_icon = "NODE"
  572. initialized : bpy.props.BoolProperty(default = False)
  573. mantis_node_class_name=bl_idname
  574. # We want Mantis to import widgets and stuff, so we hold a reference to the object
  575. object_reference : bpy.props.PointerProperty(type=bpy.types.Object,)
  576. def init(self, context):
  577. self.inputs.new("StringSocket", "Name")
  578. self.outputs.new("xFormSocket", "Object")
  579. self.initialized = True
  580. def display_update(self, parsed_tree, context):
  581. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  582. if nc: # this is done here so I don't have to define yet another custom socket.
  583. self.object_reference = bpy.data.objects.get(nc.evaluate_input("Name"))
  584. # TODO: maybe I should hold a data reference here, too.
  585. # but it is complicated by the fact that Mantis does not distinguish b/tw geo types
  586. class InputExistingGeometryDataNode(Node, MantisUINode):
  587. """Represents a mesh or curve datablock from the scene."""
  588. bl_idname = "InputExistingGeometryData"
  589. bl_label = "Existing Geometry"
  590. bl_icon = "NODE"
  591. initialized : bpy.props.BoolProperty(default = False)
  592. mantis_node_class_name=bl_idname
  593. def init(self, context):
  594. self.inputs.new("StringSocket", "Name")
  595. self.outputs.new("GeometrySocket", "Geometry")
  596. self.initialized = True
  597. class UtilityGeometryOfXForm(Node, MantisUINode):
  598. """Retrieves a mesh or curve datablock from an xForm."""
  599. bl_idname = "UtilityGeometryOfXForm"
  600. bl_label = "Geometry of xForm"
  601. bl_icon = "NODE"
  602. initialized : bpy.props.BoolProperty(default = False)
  603. mantis_node_class_name=bl_idname
  604. def init(self, context):
  605. self.inputs.new("xFormSocket", "xForm")
  606. self.outputs.new("GeometrySocket", "Geometry")
  607. self.initialized = True
  608. class UtilityNameOfXForm(Node, MantisUINode):
  609. """Retrieves the name of a xForm."""
  610. bl_idname = "UtilityNameOfXForm"
  611. bl_label = "Name of xForm"
  612. bl_icon = "NODE"
  613. initialized : bpy.props.BoolProperty(default = False)
  614. mantis_node_class_name=bl_idname
  615. def init(self, context):
  616. self.inputs.new("xFormSocket", "xForm")
  617. self.outputs.new("StringSocket", "Name")
  618. self.initialized = True
  619. class UtilityGetBoneLength(Node, MantisUINode):
  620. """Returns the length of the bone from its matrix."""
  621. bl_idname = "UtilityGetBoneLength"
  622. bl_label = "Get Bone Length"
  623. bl_icon = "NODE"
  624. initialized : bpy.props.BoolProperty(default = False)
  625. mantis_node_class_name=bl_idname
  626. def init(self, context):
  627. self.inputs.new("MatrixSocket", "Bone Matrix")
  628. self.outputs.new("FloatSocket", "Bone Length")
  629. self.initialized = True
  630. # TODO: make it work with BBones!
  631. class UtilityPointFromBoneMatrix(Node, MantisUINode):
  632. """Returns a point representing the location along a bone, given a matrix representing that bone's shape."""
  633. bl_idname = "UtilityPointFromBoneMatrix"
  634. bl_label = "Point from Bone Matrix"
  635. bl_icon = "NODE"
  636. initialized : bpy.props.BoolProperty(default = False)
  637. mantis_node_class_name=bl_idname
  638. def init(self, context):
  639. self.inputs.new("MatrixSocket", "Bone Matrix")
  640. self.inputs.new("FloatFactorSocket", "Head/Tail")
  641. self.outputs.new("VectorSocket", "Point")
  642. self.initialized = True
  643. class UtilitySetBoneLength(Node, MantisUINode):
  644. """Sets the length of a bone matrix."""
  645. bl_idname = "UtilitySetBoneLength"
  646. bl_label = "Set Bone Matrix Length"
  647. bl_icon = "NODE"
  648. initialized : bpy.props.BoolProperty(default = False)
  649. mantis_node_class_name=bl_idname
  650. def init(self, context):
  651. self.inputs.new("MatrixSocket", "Bone Matrix")
  652. self.inputs.new("FloatSocket", "Length")
  653. self.outputs.new("MatrixSocket", "Bone Matrix")
  654. self.initialized = True
  655. # TODO: more keyframe types should be supported in the future.
  656. # Some of the code that can do this is commented out here until I can implement it properly.
  657. class UtilityKeyframe(Node, MantisUINode):
  658. """A keyframe for a FCurve"""
  659. bl_idname = "UtilityKeyframe"
  660. bl_label = "KeyFrame"
  661. bl_icon = "NODE"
  662. initialized : bpy.props.BoolProperty(default = False)
  663. mantis_node_class_name=bl_idname
  664. def init(self, context):
  665. # x and y
  666. # output is keyframe
  667. # self.inputs.new("EnumKeyframeInterpolationTypeSocket", "Interpolation")
  668. # self.inputs.new("EnumKeyframeBezierHandleType", "Left Handle Type")
  669. # self.inputs.new("EnumKeyframeBezierHandleType", "Right Handle Type")
  670. # self.inputs.new("FloatSocket", "Left Handle Distance")
  671. # self.inputs.new("FloatSocket", "Left Handle Value")
  672. # self.inputs.new("FloatSocket", "Right Handle Frame")
  673. # self.inputs.new("FloatSocket", "Right Handle Value")
  674. self.inputs.new("FloatSocket", "Frame")
  675. self.inputs.new("FloatSocket", "Value")
  676. self.outputs.new("KeyframeSocket", "Keyframe")
  677. # there will eventually be inputs for e.g. key type, key handles, etc.
  678. # right now I am gonna hardcode LINEAR keyframes so I don't have to deal with anything else
  679. # TODO TODO TODO
  680. # def display_update(self, parsed_tree, context):
  681. # if context.space_data:
  682. # nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  683. # if nc.evaluate_input("Interpolation") in ["CONSTANT", "LINEAR"]:
  684. # for inp in self.inputs[1:6]:
  685. # inp.hide = True
  686. # else:
  687. # if nc.evaluate_input("Left Handle Type") in ["FREE", "ALIGNED"]:
  688. # for inp in self.inputs[1:6]:
  689. # inp.hide = False
  690. self.initialized = True
  691. class UtilityBoneMatrixHeadTailFlip(Node, MantisUINode):
  692. """Flips a bone matrix so that the head is where the tail was and visa versa."""
  693. bl_idname = "UtilityBoneMatrixHeadTailFlip"
  694. bl_label = "Flip Head/Tail"
  695. bl_icon = "NODE"
  696. initialized : bpy.props.BoolProperty(default = False)
  697. mantis_node_class_name=bl_idname
  698. def init(self, context):
  699. self.inputs.new("MatrixSocket", "Bone Matrix")
  700. self.outputs.new("MatrixSocket", "Bone Matrix")
  701. self.initialized = True
  702. class UtilityMatrixTransform(Node, MantisUINode):
  703. """Transforms a matrix by another."""
  704. bl_idname = "UtilityMatrixTransform"
  705. bl_label = "Matrix Transform"
  706. bl_icon = "NODE"
  707. initialized : bpy.props.BoolProperty(default = False)
  708. mantis_node_class_name=bl_idname
  709. def init(self, context):
  710. self.inputs.new("MatrixSocket", "Matrix 1")
  711. self.inputs.new("MatrixSocket", "Matrix 2")
  712. self.outputs.new("MatrixSocket", "Out Matrix")
  713. self.initialized = True
  714. class UtilityMatrixSetLocation(Node, MantisUINode):
  715. """Sets a matrix's location."""
  716. bl_idname = "UtilityMatrixSetLocation"
  717. bl_label = "Set Matrix Location"
  718. bl_icon = "NODE"
  719. initialized : bpy.props.BoolProperty(default = False)
  720. mantis_node_class_name=bl_idname
  721. def init(self, context):
  722. self.inputs.new("MatrixSocket", "Matrix")
  723. self.inputs.new("VectorSocket", "Location")
  724. self.outputs.new("MatrixSocket", "Matrix")
  725. self.initialized = True
  726. class UtilityMatrixGetLocation(Node, MantisUINode):
  727. """Gets a matrix's location."""
  728. bl_idname = "UtilityMatrixGetLocation"
  729. bl_label = "Get Matrix Location"
  730. bl_icon = "NODE"
  731. initialized : bpy.props.BoolProperty(default = False)
  732. mantis_node_class_name=bl_idname
  733. def init(self, context):
  734. self.inputs.new("MatrixSocket", "Matrix")
  735. self.outputs.new("VectorSocket", "Location")
  736. self.initialized = True
  737. class UtilityTransformationMatrix(Node, MantisUINode):
  738. """Constructs a matrix representing a transformation"""
  739. bl_idname = "UtilityTransformationMatrix"
  740. bl_label = "Transformation Matrix"
  741. bl_icon = "NODE"
  742. initialized : bpy.props.BoolProperty(default = False)
  743. mantis_node_class_name=bl_idname
  744. def init(self, context):
  745. # first input is a transformation type - translation, rotation, or scale
  746. # rotation is an especially annoying feature because it can take multiple types
  747. # so Euler, axis/angle, quaternion, matrix...
  748. # for now I am only going to implement axis-angle
  749. # it should get an axis and a magnitude
  750. # self.inputs.new("MatrixSocket", "Bone Matrix")
  751. self.inputs.new("MatrixTransformOperation", "Operation")
  752. self.inputs.new("VectorSocket", "Vector")
  753. self.inputs.new("FloatSocket", "W")
  754. self.outputs.new("MatrixSocket", "Matrix")
  755. self.initialized = True
  756. def display_update(self, parsed_tree, context):
  757. operation = self.inputs['Operation'].default_value
  758. if self.inputs['Operation'].is_linked:
  759. if context.space_data:
  760. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  761. operation = nc.evaluate_input("Operation")
  762. if operation in ["ROTATE_AXIS_ANGLE", "SCALE"]:
  763. self.inputs["Vector"].hide = False
  764. self.inputs["W"].hide = False
  765. if operation in ["TRANSLATE"]:
  766. self.inputs["Vector"].hide = False
  767. self.inputs["W"].hide = True
  768. # Blender calculates bone roll this way...
  769. # https://projects.blender.org/blender/blender/src/commit/dd209221675ac7b62ce47b7ea42f15cbe34a6035/source/blender/editors/armature/armature_edit.cc#L281
  770. # but this looks like it will be harder to re-implement than to re-use. Unfortunately, it doesn't apply directly to a matrix so I have to call a method
  771. # in the edit bone.
  772. # So instead, we need to avoid calculating the roll for now.
  773. # but I want to make that its own node and add roll-recalc to this node, too.
  774. class UtilitySetBoneMatrixTail(Node, MantisUINode):
  775. """Constructs a matrix representing a transformation"""
  776. bl_idname = "UtilitySetBoneMatrixTail"
  777. bl_label = "Set Bone Matrix Tail"
  778. bl_icon = "NODE"
  779. initialized : bpy.props.BoolProperty(default = False)
  780. mantis_node_class_name=bl_idname
  781. def init(self, context):
  782. self.inputs.new("MatrixSocket", "Matrix")
  783. self.inputs.new("VectorSocket", "Tail Location")
  784. self.outputs.new("MatrixSocket", "Result")
  785. self.initialized = True
  786. class UtilityMatrixFromXForm(Node, MantisUINode):
  787. """Returns the matrix of the given xForm node."""
  788. bl_idname = "UtilityMatrixFromXForm"
  789. bl_label = "Matrix of xForm"
  790. bl_icon = "NODE"
  791. initialized : bpy.props.BoolProperty(default = False)
  792. mantis_node_class_name=bl_idname
  793. def init(self, context):
  794. self.inputs.new("xFormSocket", "xForm")
  795. self.outputs.new("MatrixSocket", "Matrix")
  796. self.initialized = True
  797. class UtilityAxesFromMatrix(Node, MantisUINode):
  798. """Returns the axes of the matrix."""
  799. bl_idname = "UtilityAxesFromMatrix"
  800. bl_label = "Axes of Matrix"
  801. bl_icon = "NODE"
  802. initialized : bpy.props.BoolProperty(default = False)
  803. mantis_node_class_name=bl_idname
  804. def init(self, context):
  805. self.inputs.new("MatrixSocket", "Matrix")
  806. self.outputs.new("VectorSocket", "X Axis")
  807. self.outputs.new("VectorSocket", "Y Axis")
  808. self.outputs.new("VectorSocket", "Z Axis")
  809. self.initialized = True
  810. class UtilityIntToString(Node, MantisUINode):
  811. """Converts a number to a string"""
  812. bl_idname = "UtilityIntToString"
  813. bl_label = "Number String"
  814. bl_icon = "NODE"
  815. initialized : bpy.props.BoolProperty(default = False)
  816. mantis_node_class_name=bl_idname
  817. def init(self, context):
  818. self.inputs.new("IntSocket", "Number")
  819. self.inputs.new("IntSocket", "Zero Padding")
  820. self.outputs.new("StringSocket", "String")
  821. self.initialized = True
  822. class UtilityArrayGet(Node, MantisUINode):
  823. """Gets a value from an array at a specified index."""
  824. bl_idname = "UtilityArrayGet"
  825. bl_label = "Array Get"
  826. bl_icon = "NODE"
  827. initialized : bpy.props.BoolProperty(default = False)
  828. mantis_node_class_name=bl_idname
  829. def init(self, context):
  830. self.inputs.new('EnumArrayGetOptions', 'OoB Behaviour')
  831. self.inputs.new("IntSocket", "Index")
  832. s = self.inputs.new("WildcardSocket", "Array", use_multi_input=True)
  833. s.display_shape = 'SQUARE_DOT'
  834. self.outputs.new("WildcardSocket", "Output")
  835. self.initialized = True
  836. def update(self):
  837. wildcard_color = (0.0,0.0,0.0,0.0)
  838. if self.inputs['Array'].is_linked == False:
  839. self.inputs['Array'].color = wildcard_color
  840. self.outputs['Output'].color = wildcard_color
  841. def insert_link(self, link):
  842. super().insert_link(link)
  843. if link.to_socket.identifier == self.inputs['Array'].identifier:
  844. from_socket = link.from_socket
  845. if hasattr(from_socket, "color"):
  846. self.inputs['Array'].color = from_socket.color
  847. self.outputs['Output'].color = from_socket.color
  848. class UtilityArrayLength(Node, MantisUINode):
  849. """Gets The length of an array."""
  850. bl_idname = "UtilityArrayLength"
  851. bl_label = "Array Length"
  852. bl_icon = "NODE"
  853. initialized : bpy.props.BoolProperty(default = False)
  854. mantis_node_class_name=bl_idname
  855. def init(self, context):
  856. s = self.inputs.new("WildcardSocket", "Array", use_multi_input=True)
  857. s.display_shape = 'SQUARE_DOT'
  858. self.outputs.new("UnsignedIntSocket", "Length")
  859. self.initialized = True
  860. def update(self):
  861. wildcard_color = (0.0,0.0,0.0,0.0)
  862. if self.inputs['Array'].is_linked == False:
  863. self.inputs['Array'].color = wildcard_color
  864. def insert_link(self, link):
  865. super().insert_link(link)
  866. if link.to_socket.identifier == self.inputs['Array'].identifier:
  867. from_socket = link.from_socket
  868. if hasattr(from_socket, "color"):
  869. self.inputs['Array'].color = from_socket.color
  870. class UtilityCompare(Node, MantisUINode):
  871. """Compares two inputs and produces a boolean output"""
  872. bl_idname = "UtilityCompare"
  873. bl_label = "Compare"
  874. bl_icon = "NODE"
  875. initialized : bpy.props.BoolProperty(default = False)
  876. mantis_node_class_name=bl_idname
  877. def init(self, context):
  878. self.inputs.new("WildcardSocket", "A")
  879. self.inputs.new("WildcardSocket", "B")
  880. self.outputs.new("BooleanSocket", "Result")
  881. self.initialized = True
  882. def update(self):
  883. wildcard_color = (0.0,0.0,0.0,0.0)
  884. if self.inputs['A'].is_linked == False:
  885. self.inputs['A'].color = wildcard_color
  886. if self.inputs['B'].is_linked == False:
  887. self.inputs['B'].color = wildcard_color
  888. def insert_link(self, link):
  889. super().insert_link(link)
  890. if link.to_socket.identifier == self.inputs['A'].identifier:
  891. self.inputs['A'].color = link.from_socket.color_simple
  892. if hasattr(link.from_socket, "color"):
  893. self.inputs['A'].color = link.from_socket.color
  894. if link.to_socket.identifier == self.inputs['B'].identifier:
  895. self.inputs['B'].color = link.from_socket.color_simple
  896. if hasattr(link.from_socket, "color"):
  897. self.inputs['B'].color = link.from_socket.color
  898. class UtilityChoose(Node, MantisUINode):
  899. """Chooses an output"""
  900. bl_idname = "UtilityChoose"
  901. bl_label = "Choose"
  902. bl_icon = "NODE"
  903. initialized : bpy.props.BoolProperty(default = False)
  904. mantis_node_class_name=bl_idname
  905. def init(self, context):
  906. self.inputs.new("BooleanSocket", "Condition")
  907. self.inputs.new("WildcardSocket", "A")
  908. self.inputs.new("WildcardSocket", "B")
  909. self.outputs.new("WildcardSocket", "Result")
  910. self.initialized = True
  911. def display_update(self, parsed_tree, context):
  912. wildcard_color = (0.0,0.0,0.0,0.0)
  913. if not self.inputs['A'].is_linked:
  914. self.inputs['A'].color = wildcard_color
  915. if not self.inputs['B'].is_linked:
  916. self.inputs['B'].color = wildcard_color
  917. self.outputs['Result'].color = wildcard_color
  918. # if both inputs are the same color, then use that color for the result
  919. if self.inputs['Condition'].is_linked:
  920. from .base_definitions import get_signature_from_edited_tree
  921. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  922. if nc:
  923. condition = nc.evaluate_input('Condition')
  924. else:
  925. condition = self.inputs['Condition'].default_value
  926. if condition == True:
  927. self.outputs['Result'].color = self.inputs['B'].color
  928. else:
  929. self.outputs['Result'].color = self.inputs['A'].color
  930. def insert_link(self, link):
  931. super().insert_link(link)
  932. if link.to_socket.identifier == self.inputs['A'].identifier:
  933. self.inputs['A'].color = link.from_socket.color_simple
  934. if hasattr(link.from_socket, "color"):
  935. self.inputs['A'].color = link.from_socket.color
  936. if link.to_socket.identifier == self.inputs['B'].identifier:
  937. self.inputs['B'].color = link.from_socket.color_simple
  938. if hasattr(link.from_socket, "color"):
  939. self.inputs['B'].color = link.from_socket.color
  940. class UtilityPrint(Node, MantisUINode):
  941. """A utility used to print arbitrary values."""
  942. bl_idname = "UtilityPrint"
  943. bl_label = "Print"
  944. bl_icon = "NODE"
  945. initialized : bpy.props.BoolProperty(default = False)
  946. mantis_node_class_name=bl_idname
  947. def init(self, context):
  948. self.inputs.new("WildcardSocket", "Input")
  949. self.initialized = True
  950. # Set up the class property that ties the UI classes to the Mantis classes.
  951. for cls in TellClasses():
  952. cls.mantis_node_library='.misc_nodes'
  953. cls.set_mantis_class()