link_definitions.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. import bpy
  2. from bpy.types import NodeTree, Node, NodeSocket
  3. from .base_definitions import LinkNode, GraphError
  4. from .utilities import (prRed, prGreen, prPurple, prWhite,
  5. prOrange,
  6. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  7. wrapOrange,)
  8. from .base_definitions import get_signature_from_edited_tree
  9. def TellClasses():
  10. return [ LinkInheritNode,
  11. LinkInverseKinematics,
  12. LinkCopyLocationNode,
  13. LinkCopyRotationNode,
  14. LinkCopyScaleNode,
  15. LinkInheritConstraintNode,
  16. LinkCopyTransformNode,
  17. LinkStretchToNode,
  18. LinkDampedTrackNode,
  19. LinkLockedTrackNode,
  20. LinkTrackToNode,
  21. LinkLimitLocationNode,
  22. LinkLimitScaleNode,
  23. LinkLimitRotationNode,
  24. LinkLimitDistanceNode,
  25. LinkDrivenParameterNode,
  26. LinkArmatureNode,
  27. LinkSplineIKNode,
  28. LinkTransformationNode,
  29. ]
  30. from mathutils import Color # these colors were sampled from Blender's UI
  31. # TODO: maybe read the relevant colors from the Theme
  32. linkColor = Color((0.028034, 0.093164, 0.070379)).from_scene_linear_to_srgb()
  33. inheritColor = Color((0.083213, 0.131242, 0.116497)).from_scene_linear_to_srgb()
  34. trackingColor = Color((0.033114, 0.049013, 0.131248)).from_scene_linear_to_srgb()
  35. ikColor = Color((0.131117, 0.131248, 0.006971)).from_scene_linear_to_srgb()
  36. driverColor = Color((0.043782, 0.014745, 0.131248,)).from_scene_linear_to_srgb()
  37. class LinkInheritNode(Node, LinkNode):
  38. '''A node representing inheritance'''
  39. # cuss, messed this up
  40. bl_idname = 'linkInherit' # l should be L
  41. # need to fix this
  42. bl_label = "Inherit"
  43. bl_icon = 'CONSTRAINT_BONE'
  44. initialized : bpy.props.BoolProperty(default = False)
  45. mantis_node_class_name="LinkInherit"
  46. # bone_prev : bpy.props.BoolProperty(default=False)
  47. # bone_next : bpy.props.BoolProperty(default=False)
  48. def init(self, context):
  49. from .link_containers import LinkInheritSockets
  50. self.init_sockets(LinkInheritSockets)
  51. # set default values...
  52. self.initialized = True
  53. self.use_custom_color = True
  54. self.color = inheritColor
  55. def display_update(self, parsed_tree, context):
  56. node_tree = context.space_data.path[0].node_tree
  57. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  58. if nc:
  59. bone_prev, bone_next = False, False
  60. if (inp := nc.inputs["Parent"]).is_connected:
  61. if from_node := inp.links[0].from_node:
  62. if from_node.__class__.__name__ in ["xFormBone"]:
  63. bone_prev=True
  64. bone_next=True
  65. try:
  66. xForm = nc.GetxForm()
  67. if xForm.__class__.__name__ not in "xFormBone":
  68. bone_next=False
  69. except GraphError:
  70. bone_next=False
  71. # print(bone_prev, bone_next )
  72. if bone_next and bone_prev:
  73. self.inputs["Inherit Rotation"].hide = False
  74. self.inputs["Inherit Scale"].hide = False
  75. self.inputs["Connected"].hide = False
  76. else:
  77. self.inputs["Inherit Rotation"].hide = True or self.inputs["Inherit Rotation"].is_connected
  78. self.inputs["Inherit Scale"].hide = True or self.inputs["Inherit Scale"].is_connected
  79. self.inputs["Connected"].hide = True or self.inputs["Connected"].is_connected
  80. # the node_groups on the way here ought to be active if there
  81. # is no funny business going on.
  82. # DO: make another node for ITASC IK, eh?
  83. class LinkInverseKinematics(Node, LinkNode):
  84. '''A node representing inverse kinematics'''
  85. bl_idname = 'LinkInverseKinematics'
  86. bl_label = "Inverse Kinematics"
  87. bl_icon = 'CON_KINEMATIC'
  88. initialized : bpy.props.BoolProperty(default = False)
  89. mantis_node_class_name=bl_idname
  90. def init(self, context):
  91. self.inputs.new('RelationshipSocket', "Input Relationship")
  92. self.inputs.new ('xFormSocket', "Target")
  93. self.inputs.new ('xFormSocket', "Pole Target")
  94. self.inputs.new ('IKChainLengthSocket', "Chain Length")
  95. self.inputs.new ('BooleanSocket', "Use Tail")
  96. self.inputs.new ('BooleanSocket', "Stretch")
  97. self.inputs.new ('FloatFactorSocket', "Position")
  98. self.inputs.new ('FloatFactorSocket', "Rotation")
  99. self.inputs.new ('FloatFactorSocket', "Influence")
  100. self.inputs.new ('EnableSocket', "Enable")
  101. #Well, it turns out that this has to be a constraint like
  102. # everything else, because of course, there can be more than one.
  103. #self.outputs.new('RelationshipSocket', "Inheritance")
  104. self.outputs.new('RelationshipSocket', "Output Relationship")
  105. self.initialized = True
  106. # color
  107. self.use_custom_color = True
  108. self.color = ikColor
  109. class LinkCopyLocationNode(Node, LinkNode):
  110. '''A node representing Copy Location'''
  111. bl_idname = 'LinkCopyLocation'
  112. bl_label = "Copy Location"
  113. bl_icon = 'CON_LOCLIKE'
  114. initialized : bpy.props.BoolProperty(default = False)
  115. mantis_node_class_name=bl_idname
  116. def init(self, context):
  117. from .link_containers import LinkCopyLocationSockets
  118. self.init_sockets(LinkCopyLocationSockets)
  119. self.use_custom_color = True
  120. self.color = linkColor
  121. self.initialized = True
  122. class LinkCopyRotationNode(Node, LinkNode):
  123. '''A node representing Copy Rotation'''
  124. bl_idname = 'LinkCopyRotation'
  125. bl_label = "Copy Rotation"
  126. bl_icon = 'CON_ROTLIKE'
  127. initialized : bpy.props.BoolProperty(default = False)
  128. mantis_node_class_name=bl_idname
  129. def init(self, context):
  130. from .link_containers import LinkCopyRotationSockets
  131. self.init_sockets(LinkCopyRotationSockets)
  132. self.use_custom_color = True
  133. self.color = linkColor
  134. self.initialized = True
  135. class LinkCopyScaleNode(Node, LinkNode):
  136. '''A node representing Copy Scale'''
  137. bl_idname = 'LinkCopyScale'
  138. bl_label = "Copy Scale"
  139. bl_icon = 'CON_SIZELIKE'
  140. initialized : bpy.props.BoolProperty(default = False)
  141. mantis_node_class_name=bl_idname
  142. def init(self, context):
  143. from .link_containers import LinkCopyScaleSockets
  144. self.init_sockets(LinkCopyScaleSockets)
  145. self.use_custom_color = True
  146. self.color = linkColor
  147. self.initialized = True
  148. class LinkInheritConstraintNode(Node, LinkNode):
  149. # === Basics ===
  150. # Description string
  151. '''A node representing a parent constraint'''
  152. bl_idname = 'LinkInheritConstraint'
  153. bl_label = "Inherit (constraint)"
  154. bl_icon = 'CON_CHILDOF'
  155. initialized : bpy.props.BoolProperty(default = False)
  156. mantis_node_class_name=bl_idname
  157. # === Optional Functions ===
  158. def init(self, context):
  159. self.inputs.new ('RelationshipSocket', "Input Relationship")
  160. self.inputs.new ('BooleanThreeTupleSocket', "Location")
  161. self.inputs.new ('BooleanThreeTupleSocket', "Rotation")
  162. self.inputs.new ('BooleanThreeTupleSocket', "Scale")
  163. self.inputs.new ('FloatFactorSocket', "Influence")
  164. self.inputs.new ('xFormSocket', "Target")
  165. self.inputs.new ('EnableSocket', "Enable")
  166. #
  167. self.outputs.new('RelationshipSocket', "Output Relationship")
  168. # color
  169. self.use_custom_color = True
  170. self.color = inheritColor
  171. self.initialized = True
  172. class LinkCopyTransformNode(Node, LinkNode):
  173. # === Basics ===
  174. # Description string
  175. '''A node representing Copy Transform'''
  176. bl_idname = 'LinkCopyTransforms'
  177. bl_label = "Copy Transform"
  178. bl_icon = 'CON_TRANSLIKE'
  179. initialized : bpy.props.BoolProperty(default = False)
  180. mantis_node_class_name=bl_idname
  181. # === Optional Functions ===
  182. def init(self, context):
  183. from .link_containers import LinkCopyTransformsSockets
  184. self.init_sockets(LinkCopyTransformsSockets)
  185. self.use_custom_color = True
  186. self.color = linkColor
  187. self.initialized = True
  188. class LinkStretchToNode(Node, LinkNode):
  189. '''A node representing Stretch-To'''
  190. bl_idname = 'LinkStretchTo'
  191. bl_label = "Stretch To"
  192. bl_icon = 'CON_STRETCHTO'
  193. initialized : bpy.props.BoolProperty(default = False)
  194. mantis_node_class_name=bl_idname
  195. def init(self, context):
  196. self.inputs.new ('RelationshipSocket', "Input Relationship")
  197. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  198. self.inputs.new ('BooleanSocket', "UseBBone")
  199. self.inputs.new ('FloatSocket', "Original Length")
  200. self.inputs.new ('FloatSocket', "Volume Variation")
  201. self.inputs.new ('BoolUpdateParentNode', "Use Volume Min")
  202. self.inputs.new ('FloatSocket', "Volume Min")
  203. self.inputs.new ('BoolUpdateParentNode', "Use Volume Max")
  204. self.inputs.new ('FloatSocket', "Volume Max")
  205. self.inputs.new ('FloatFactorSocket', "Smooth")
  206. self.inputs.new ('EnumMaintainVolumeStretchToSocket', "Maintain Volume")
  207. self.inputs.new ('EnumRotationStretchTo', "Rotation")
  208. self.inputs.new ('FloatFactorSocket', "Influence")
  209. self.inputs.new ('xFormSocket', "Target")
  210. self.inputs.new ('EnableSocket', "Enable")
  211. #
  212. self.outputs.new('RelationshipSocket', "Output Relationship")
  213. self.initialized = True
  214. # color
  215. self.use_custom_color = True
  216. self.color = trackingColor
  217. class LinkDampedTrackNode(Node, LinkNode):
  218. '''A node representing Stretch-To'''
  219. bl_idname = 'LinkDampedTrack'
  220. bl_label = "Damped Track"
  221. bl_icon = 'CON_TRACKTO'
  222. initialized : bpy.props.BoolProperty(default = False)
  223. mantis_node_class_name=bl_idname
  224. def init(self, context):
  225. self.inputs.new ('RelationshipSocket', "Input Relationship")
  226. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  227. self.inputs.new ('BooleanSocket', "UseBBone")
  228. self.inputs.new ('EnumTrackAxis', "Track Axis")
  229. self.inputs.new ('FloatFactorSocket', "Influence")
  230. self.inputs.new ('xFormSocket', "Target")
  231. self.inputs.new ('EnableSocket', "Enable")
  232. #
  233. self.outputs.new('RelationshipSocket', "Output Relationship")
  234. self.initialized = True
  235. # color
  236. self.use_custom_color = True
  237. self.color = trackingColor
  238. class LinkLockedTrackNode(Node, LinkNode):
  239. '''A node representing Stretch-To'''
  240. bl_idname = 'LinkLockedTrack'
  241. bl_label = "Locked Track"
  242. bl_icon = 'CON_LOCKTRACK'
  243. initialized : bpy.props.BoolProperty(default = False)
  244. mantis_node_class_name=bl_idname
  245. def init(self, context):
  246. self.inputs.new ('RelationshipSocket', "Input Relationship")
  247. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  248. self.inputs.new ('BooleanSocket', "UseBBone")
  249. self.inputs.new ('EnumTrackAxis', "Track Axis")
  250. self.inputs.new ('EnumLockAxis', "Lock Axis")
  251. self.inputs.new ('FloatFactorSocket', "Influence")
  252. self.inputs.new ('xFormSocket', "Target")
  253. self.inputs.new ('EnableSocket', "Enable")
  254. #
  255. self.outputs.new('RelationshipSocket', "Output Relationship")
  256. self.initialized = True
  257. # color
  258. self.use_custom_color = True
  259. self.color = trackingColor
  260. class LinkTrackToNode(Node, LinkNode):
  261. '''A node representing Stretch-To'''
  262. bl_idname = 'LinkTrackTo'
  263. bl_label = "Track To"
  264. bl_icon = 'CON_TRACKTO'
  265. initialized : bpy.props.BoolProperty(default = False)
  266. mantis_node_class_name=bl_idname
  267. def init(self, context):
  268. self.inputs.new ('RelationshipSocket', "Input Relationship")
  269. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  270. self.inputs.new ('BooleanSocket', "UseBBone")
  271. self.inputs.new ('EnumTrackAxis', "Track Axis")
  272. self.inputs.new ('EnumUpAxis', "Up Axis")
  273. self.inputs.new ('BooleanSocket', "Use Target Z")
  274. self.inputs.new ('TransformSpaceSocket', "Target Space")
  275. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  276. self.inputs.new ('FloatFactorSocket', "Influence")
  277. self.inputs.new ('xFormSocket', "Target")
  278. self.inputs.new ('EnableSocket', "Enable")
  279. #
  280. self.outputs.new('RelationshipSocket', "Output Relationship")
  281. self.initialized = True
  282. # color
  283. self.use_custom_color = True
  284. self.color = trackingColor
  285. class LinkLimitLocationNode(Node, LinkNode):
  286. '''A node representing Limit Location'''
  287. bl_idname = 'LinkLimitLocation'
  288. bl_label = "Limit Location"
  289. bl_icon = 'CON_LOCLIMIT'
  290. mantis_node_class_name=bl_idname
  291. initialized : bpy.props.BoolProperty(default = False)
  292. def init(self, context):
  293. self.inputs.new ('RelationshipSocket', "Input Relationship")
  294. self.inputs.new ('BoolUpdateParentNode', "Use Max X")
  295. self.inputs.new ('FloatSocket', "Max X")
  296. self.inputs.new ('BoolUpdateParentNode', "Use Min X")
  297. self.inputs.new ('FloatSocket', "Min X")
  298. self.inputs.new ('BoolUpdateParentNode', "Use Max Y")
  299. self.inputs.new ('FloatSocket', "Max Y")
  300. self.inputs.new ('BoolUpdateParentNode', "Use Min Y")
  301. self.inputs.new ('FloatSocket', "Min Y")
  302. self.inputs.new ('BoolUpdateParentNode', "Use Max Z")
  303. self.inputs.new ('FloatSocket', "Max Z")
  304. self.inputs.new ('BoolUpdateParentNode', "Use Min Z")
  305. self.inputs.new ('FloatSocket', "Min Z")
  306. self.inputs.new ('BooleanSocket', "Affect Transform")
  307. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  308. self.inputs.new ('FloatFactorSocket', "Influence")
  309. self.inputs.new ('EnableSocket', "Enable")
  310. #
  311. self.outputs.new('RelationshipSocket', "Output Relationship")
  312. self.initialized = True
  313. # color
  314. self.use_custom_color = True
  315. self.color = linkColor
  316. class LinkLimitScaleNode(Node, LinkNode):
  317. '''A node representing Limit Scale'''
  318. bl_idname = 'LinkLimitScale'
  319. bl_label = "Limit Scale"
  320. bl_icon = 'CON_SIZELIMIT'
  321. initialized : bpy.props.BoolProperty(default = False)
  322. mantis_node_class_name=bl_idname
  323. def init(self, context):
  324. self.inputs.new ('RelationshipSocket', "Input Relationship")
  325. self.inputs.new ('BoolUpdateParentNode', "Use Max X")
  326. self.inputs.new ('FloatSocket', "Max X")
  327. self.inputs.new ('BoolUpdateParentNode', "Use Min X")
  328. self.inputs.new ('FloatSocket', "Min X")
  329. self.inputs.new ('BoolUpdateParentNode', "Use Max Y")
  330. self.inputs.new ('FloatSocket', "Max Y")
  331. self.inputs.new ('BoolUpdateParentNode', "Use Min Y")
  332. self.inputs.new ('FloatSocket', "Min Y")
  333. self.inputs.new ('BoolUpdateParentNode', "Use Max Z")
  334. self.inputs.new ('FloatSocket', "Max Z")
  335. self.inputs.new ('BoolUpdateParentNode', "Use Min Z")
  336. self.inputs.new ('FloatSocket', "Min Z")
  337. self.inputs.new ('BooleanSocket', "Affect Transform")
  338. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  339. self.inputs.new ('FloatFactorSocket', "Influence")
  340. self.inputs.new ('EnableSocket', "Enable")
  341. #
  342. self.outputs.new('RelationshipSocket', "Output Relationship")
  343. self.initialized = True
  344. # color
  345. self.use_custom_color = True
  346. self.color = linkColor
  347. class LinkLimitRotationNode(Node, LinkNode):
  348. # === Basics ===
  349. # Description string
  350. '''A node representing Limit Rotation'''
  351. bl_idname = 'LinkLimitRotation'
  352. bl_label = "Limit Rotation"
  353. bl_icon = 'CON_ROTLIMIT'
  354. initialized : bpy.props.BoolProperty(default = False)
  355. mantis_node_class_name=bl_idname
  356. # === Optional Functions ===
  357. def init(self, context):
  358. self.inputs.new ('RelationshipSocket', "Input Relationship")
  359. self.inputs.new ('BoolUpdateParentNode', "Use X")
  360. self.inputs.new ('FloatAngleSocket', "Min X")
  361. self.inputs.new ('FloatAngleSocket', "Max X")
  362. self.inputs.new ('BoolUpdateParentNode', "Use Y")
  363. self.inputs.new ('FloatAngleSocket', "Min Y")
  364. self.inputs.new ('FloatAngleSocket', "Max Y")
  365. self.inputs.new ('BoolUpdateParentNode', "Use Z")
  366. self.inputs.new ('FloatAngleSocket', "Min Z")
  367. self.inputs.new ('FloatAngleSocket', "Max Z")
  368. self.inputs.new ('BooleanSocket', "Affect Transform")
  369. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  370. self.inputs.new ('FloatFactorSocket', "Influence")
  371. self.inputs.new ('EnableSocket', "Enable")
  372. #
  373. self.outputs.new('RelationshipSocket', "Output Relationship")
  374. self.initialized = True
  375. # color
  376. self.use_custom_color = True
  377. self.color = linkColor
  378. class LinkLimitDistanceNode(Node, LinkNode):
  379. '''A node representing Limit Distance'''
  380. bl_idname = 'LinkLimitDistance'
  381. bl_label = "Limit Distance"
  382. bl_icon = 'CON_DISTLIMIT'
  383. initialized : bpy.props.BoolProperty(default = False)
  384. mantis_node_class_name=bl_idname
  385. def init(self, context):
  386. self.inputs.new ('RelationshipSocket', "Input Relationship")
  387. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  388. self.inputs.new ('BooleanSocket', "UseBBone")
  389. self.inputs.new ('FloatSocket', "Distance")
  390. self.inputs.new ('EnumLimitMode', "Clamp Region")
  391. self.inputs.new ('BooleanSocket', "Affect Transform")
  392. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  393. self.inputs.new ('TransformSpaceSocket', "Target Space")
  394. self.inputs.new ('FloatFactorSocket', "Influence")
  395. self.inputs.new ('xFormSocket', "Target")
  396. self.inputs.new ('EnableSocket', "Enable")
  397. #
  398. self.outputs.new('RelationshipSocket', "Output Relationship")
  399. # color
  400. self.use_custom_color = True
  401. self.color = linkColor
  402. self.initialized = True
  403. class LinkTransformationNode(Node, LinkNode):
  404. '''A node representing Transformation (Constraint)'''
  405. bl_idname = 'LinkTransformation'
  406. bl_label = "Transformation"
  407. bl_icon = 'CON_TRANSFORM'
  408. initialized : bpy.props.BoolProperty(default = False)
  409. mantis_node_class_name=bl_idname
  410. def init(self, context):
  411. hide_me = []
  412. self.inputs.new ('RelationshipSocket', "Input Relationship")
  413. self.inputs.new ('xFormSocket', "Target")
  414. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  415. self.inputs.new ('TransformSpaceSocket', "Target Space")
  416. self.inputs.new ('BooleanSocket', "Extrapolate")
  417. self.inputs.new ('EnumTransformationMap', "Map From")
  418. hide_me.append( self.inputs.new ('EnumTransformationRotationMode', "Rotation Mode"))
  419. self.inputs.new ('FloatSocket', "X Min From")
  420. self.inputs.new ('FloatSocket', "X Max From")
  421. self.inputs.new ('FloatSocket', "Y Min From")
  422. self.inputs.new ('FloatSocket', "Y Max From")
  423. self.inputs.new ('FloatSocket', "Z Min From")
  424. self.inputs.new ('FloatSocket', "Z Max From")
  425. self.inputs.new ('EnumTransformationMap', "Map To")
  426. hide_me.append( self.inputs.new ('EnumTransformationRotationOrder', "Rotation Order"))
  427. self.inputs.new ('EnumTransformationAxes', "X Source Axis")
  428. self.inputs.new ('FloatSocket', "X Min To")
  429. self.inputs.new ('FloatSocket', "X Max To")
  430. self.inputs.new ('EnumTransformationAxes', "Y Source Axis")
  431. self.inputs.new ('FloatSocket', "Y Min To")
  432. self.inputs.new ('FloatSocket', "Y Max To")
  433. self.inputs.new ('EnumTransformationAxes', "Z Source Axis")
  434. self.inputs.new ('FloatSocket', "Z Min To")
  435. self.inputs.new ('FloatSocket', "Z Max To")
  436. self.inputs.new ('EnumTransformationTranslationMixMode', "Mix Mode (Translation)")
  437. hide_me.append( self.inputs.new ('EnumTransformationRotationMixMode', "Mix Mode (Rotation)"))
  438. hide_me.append( self.inputs.new ('EnumTransformationScaleMixMode', "Mix Mode (Scale)"))
  439. self.inputs.new ('FloatFactorSocket', "Influence")
  440. self.inputs.new ('EnableSocket', "Enable")
  441. #
  442. self.outputs.new('RelationshipSocket', "Output Relationship")
  443. for s in hide_me:
  444. s.hide = True
  445. # color
  446. self.use_custom_color = True
  447. self.color = linkColor
  448. self.initialized = True
  449. def display_update(self, parsed_tree, context):
  450. node_tree = context.space_data.path[0].node_tree
  451. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  452. if nc:
  453. if nc.evaluate_input("Map From") == "ROTATION":
  454. self.inputs["Rotation Mode"].hide=False
  455. else:
  456. self.inputs["Rotation Mode"].hide=True
  457. if nc.evaluate_input("Map To") == "TRANSLATION":
  458. self.inputs["Rotation Order"].hide=True
  459. self.inputs["Mix Mode (Translation)"].hide=False
  460. self.inputs["Mix Mode (Rotation)"].hide=True
  461. self.inputs["Mix Mode (Scale)"].hide=True
  462. elif nc.evaluate_input("Map To") == "ROTATION":
  463. self.inputs["Rotation Order"].hide=False
  464. self.inputs["Mix Mode (Translation)"].hide=True
  465. self.inputs["Mix Mode (Rotation)"].hide=False
  466. self.inputs["Mix Mode (Scale)"].hide=True
  467. elif nc.evaluate_input("Map To") == "SCALE":
  468. self.inputs["Rotation Order"].hide=True
  469. self.inputs["Mix Mode (Translation)"].hide=True
  470. self.inputs["Mix Mode (Rotation)"].hide=True
  471. self.inputs["Mix Mode (Scale)"].hide=False
  472. class LinkArmatureNode(Node, LinkNode):
  473. """A node representing Blender's Armature Constraint"""
  474. bl_idname = "LinkArmature"
  475. bl_label = "Armature (Constraint)"
  476. bl_icon = "CON_ARMATURE"
  477. initialized : bpy.props.BoolProperty(default = False)
  478. mantis_node_class_name=bl_idname
  479. def init(self, context):
  480. self.inputs.new ("RelationshipSocket", "Input Relationship")
  481. self.inputs.new("BooleanSocket", "Preserve Volume")
  482. self.inputs.new("BooleanSocket", "Use Envelopes")
  483. self.inputs.new("BooleanSocket", "Use Current Location")
  484. self.inputs.new("FloatFactorSocket", "Influence")
  485. self.inputs.new ('EnableSocket', "Enable")
  486. self.outputs.new("RelationshipSocket", "Output Relationship")
  487. # color
  488. self.use_custom_color = True
  489. self.color = inheritColor
  490. self.initialized = True
  491. def draw_buttons(self, context, layout):
  492. # return
  493. layout.operator( 'mantis.link_armature_node_add_target' )
  494. if (len(self.inputs) > 6):
  495. layout.operator( 'mantis.link_armature_node_remove_target' )
  496. else:
  497. layout.label(text="")
  498. class LinkSplineIKNode(Node, LinkNode):
  499. """"A node representing Spline IK"""
  500. bl_idname = "LinkSplineIK"
  501. bl_label = "Spline IK"
  502. bl_icon = "CON_SPLINEIK"
  503. initialized : bpy.props.BoolProperty(default = False)
  504. mantis_node_class_name=bl_idname
  505. def init(self, context):
  506. self.inputs.new ("RelationshipSocket", "Input Relationship")
  507. self.inputs.new("xFormSocket", "Target")
  508. self.inputs.new("IntSocket", "Chain Length")
  509. self.inputs.new("BooleanSocket", "Even Divisions")
  510. self.inputs.new("BooleanSocket", "Chain Offset")
  511. self.inputs.new("BooleanSocket", "Use Curve Radius")
  512. self.inputs.new("EnumYScaleMode", "Y Scale Mode")
  513. self.inputs.new("EnumXZScaleMode", "XZ Scale Mode")
  514. self.inputs.new("BooleanSocket", "Use Original Scale")
  515. self.inputs.new("FloatFactorSocket", "Influence")
  516. self.outputs.new("RelationshipSocket", "Output Relationship")
  517. # color
  518. self.use_custom_color = True
  519. self.color = ikColor
  520. self.initialized = True
  521. # DRIVERS!!
  522. class LinkDrivenParameterNode(Node, LinkNode):
  523. """Represents a driven parameter in the downstream xForm node."""
  524. bl_idname = "LinkDrivenParameter"
  525. bl_label = "Driven Parameter"
  526. bl_icon = "CONSTRAINT_BONE"
  527. initialized : bpy.props.BoolProperty(default = False)
  528. mantis_node_class_name=bl_idname
  529. def init(self, context):
  530. self.inputs.new ( "RelationshipSocket", "Input Relationship" )
  531. self.inputs.new ( "FloatSocket", "Value" )
  532. self.inputs.new ( "ParameterStringSocket", "Parameter" )
  533. self.inputs.new ( "IntSocket", "Index" )
  534. self.inputs.new ('EnableSocket', "Enable")
  535. #
  536. self.outputs.new( "RelationshipSocket", "Output Relationship" )
  537. self.initialized = True
  538. # Set up the class property that ties the UI classes to the Mantis classes.
  539. for cls in TellClasses():
  540. cls.set_mantis_class()