link_definitions.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. self.inputs.new ('RelationshipSocket', "Input Relationship")
  184. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  185. self.inputs.new ('BooleanSocket', "UseBBone")
  186. self.inputs.new ('EnumRotationMixCopyTransforms', "Mix")
  187. self.inputs.new ('TransformSpaceSocket', "Target Space")
  188. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  189. self.inputs.new ('FloatFactorSocket', "Influence")
  190. self.inputs.new ('xFormSocket', "Target")
  191. self.inputs.new ('EnableSocket', "Enable")
  192. #
  193. self.outputs.new('RelationshipSocket', "Output Relationship")
  194. # color
  195. self.use_custom_color = True
  196. self.color = linkColor
  197. self.initialized = True
  198. class LinkStretchToNode(Node, LinkNode):
  199. '''A node representing Stretch-To'''
  200. bl_idname = 'LinkStretchTo'
  201. bl_label = "Stretch To"
  202. bl_icon = 'CON_STRETCHTO'
  203. initialized : bpy.props.BoolProperty(default = False)
  204. mantis_node_class_name=bl_idname
  205. def init(self, context):
  206. self.inputs.new ('RelationshipSocket', "Input Relationship")
  207. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  208. self.inputs.new ('BooleanSocket', "UseBBone")
  209. self.inputs.new ('FloatSocket', "Original Length")
  210. self.inputs.new ('FloatSocket', "Volume Variation")
  211. self.inputs.new ('BoolUpdateParentNode', "Use Volume Min")
  212. self.inputs.new ('FloatSocket', "Volume Min")
  213. self.inputs.new ('BoolUpdateParentNode', "Use Volume Max")
  214. self.inputs.new ('FloatSocket', "Volume Max")
  215. self.inputs.new ('FloatFactorSocket', "Smooth")
  216. self.inputs.new ('EnumMaintainVolumeStretchToSocket', "Maintain Volume")
  217. self.inputs.new ('EnumRotationStretchTo', "Rotation")
  218. self.inputs.new ('FloatFactorSocket', "Influence")
  219. self.inputs.new ('xFormSocket', "Target")
  220. self.inputs.new ('EnableSocket', "Enable")
  221. #
  222. self.outputs.new('RelationshipSocket', "Output Relationship")
  223. self.initialized = True
  224. # color
  225. self.use_custom_color = True
  226. self.color = trackingColor
  227. class LinkDampedTrackNode(Node, LinkNode):
  228. '''A node representing Stretch-To'''
  229. bl_idname = 'LinkDampedTrack'
  230. bl_label = "Damped Track"
  231. bl_icon = 'CON_TRACKTO'
  232. initialized : bpy.props.BoolProperty(default = False)
  233. mantis_node_class_name=bl_idname
  234. def init(self, context):
  235. self.inputs.new ('RelationshipSocket', "Input Relationship")
  236. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  237. self.inputs.new ('BooleanSocket', "UseBBone")
  238. self.inputs.new ('EnumTrackAxis', "Track Axis")
  239. self.inputs.new ('FloatFactorSocket', "Influence")
  240. self.inputs.new ('xFormSocket', "Target")
  241. self.inputs.new ('EnableSocket', "Enable")
  242. #
  243. self.outputs.new('RelationshipSocket', "Output Relationship")
  244. self.initialized = True
  245. # color
  246. self.use_custom_color = True
  247. self.color = trackingColor
  248. class LinkLockedTrackNode(Node, LinkNode):
  249. '''A node representing Stretch-To'''
  250. bl_idname = 'LinkLockedTrack'
  251. bl_label = "Locked Track"
  252. bl_icon = 'CON_LOCKTRACK'
  253. initialized : bpy.props.BoolProperty(default = False)
  254. mantis_node_class_name=bl_idname
  255. def init(self, context):
  256. self.inputs.new ('RelationshipSocket', "Input Relationship")
  257. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  258. self.inputs.new ('BooleanSocket', "UseBBone")
  259. self.inputs.new ('EnumTrackAxis', "Track Axis")
  260. self.inputs.new ('EnumLockAxis', "Lock Axis")
  261. self.inputs.new ('FloatFactorSocket', "Influence")
  262. self.inputs.new ('xFormSocket', "Target")
  263. self.inputs.new ('EnableSocket', "Enable")
  264. #
  265. self.outputs.new('RelationshipSocket', "Output Relationship")
  266. self.initialized = True
  267. # color
  268. self.use_custom_color = True
  269. self.color = trackingColor
  270. class LinkTrackToNode(Node, LinkNode):
  271. '''A node representing Stretch-To'''
  272. bl_idname = 'LinkTrackTo'
  273. bl_label = "Track To"
  274. bl_icon = 'CON_TRACKTO'
  275. initialized : bpy.props.BoolProperty(default = False)
  276. mantis_node_class_name=bl_idname
  277. def init(self, context):
  278. self.inputs.new ('RelationshipSocket', "Input Relationship")
  279. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  280. self.inputs.new ('BooleanSocket', "UseBBone")
  281. self.inputs.new ('EnumTrackAxis', "Track Axis")
  282. self.inputs.new ('EnumUpAxis', "Up Axis")
  283. self.inputs.new ('BooleanSocket', "Use Target Z")
  284. self.inputs.new ('TransformSpaceSocket', "Target Space")
  285. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  286. self.inputs.new ('FloatFactorSocket', "Influence")
  287. self.inputs.new ('xFormSocket', "Target")
  288. self.inputs.new ('EnableSocket', "Enable")
  289. #
  290. self.outputs.new('RelationshipSocket', "Output Relationship")
  291. self.initialized = True
  292. # color
  293. self.use_custom_color = True
  294. self.color = trackingColor
  295. class LinkLimitLocationNode(Node, LinkNode):
  296. '''A node representing Limit Location'''
  297. bl_idname = 'LinkLimitLocation'
  298. bl_label = "Limit Location"
  299. bl_icon = 'CON_LOCLIMIT'
  300. mantis_node_class_name=bl_idname
  301. initialized : bpy.props.BoolProperty(default = False)
  302. def init(self, context):
  303. self.inputs.new ('RelationshipSocket', "Input Relationship")
  304. self.inputs.new ('BoolUpdateParentNode', "Use Max X")
  305. self.inputs.new ('FloatSocket', "Max X")
  306. self.inputs.new ('BoolUpdateParentNode', "Use Min X")
  307. self.inputs.new ('FloatSocket', "Min X")
  308. self.inputs.new ('BoolUpdateParentNode', "Use Max Y")
  309. self.inputs.new ('FloatSocket', "Max Y")
  310. self.inputs.new ('BoolUpdateParentNode', "Use Min Y")
  311. self.inputs.new ('FloatSocket', "Min Y")
  312. self.inputs.new ('BoolUpdateParentNode', "Use Max Z")
  313. self.inputs.new ('FloatSocket', "Max Z")
  314. self.inputs.new ('BoolUpdateParentNode', "Use Min Z")
  315. self.inputs.new ('FloatSocket', "Min Z")
  316. self.inputs.new ('BooleanSocket', "Affect Transform")
  317. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  318. self.inputs.new ('FloatFactorSocket', "Influence")
  319. self.inputs.new ('EnableSocket', "Enable")
  320. #
  321. self.outputs.new('RelationshipSocket', "Output Relationship")
  322. self.initialized = True
  323. # color
  324. self.use_custom_color = True
  325. self.color = linkColor
  326. class LinkLimitScaleNode(Node, LinkNode):
  327. '''A node representing Limit Scale'''
  328. bl_idname = 'LinkLimitScale'
  329. bl_label = "Limit Scale"
  330. bl_icon = 'CON_SIZELIMIT'
  331. initialized : bpy.props.BoolProperty(default = False)
  332. mantis_node_class_name=bl_idname
  333. def init(self, context):
  334. self.inputs.new ('RelationshipSocket', "Input Relationship")
  335. self.inputs.new ('BoolUpdateParentNode', "Use Max X")
  336. self.inputs.new ('FloatSocket', "Max X")
  337. self.inputs.new ('BoolUpdateParentNode', "Use Min X")
  338. self.inputs.new ('FloatSocket', "Min X")
  339. self.inputs.new ('BoolUpdateParentNode', "Use Max Y")
  340. self.inputs.new ('FloatSocket', "Max Y")
  341. self.inputs.new ('BoolUpdateParentNode', "Use Min Y")
  342. self.inputs.new ('FloatSocket', "Min Y")
  343. self.inputs.new ('BoolUpdateParentNode', "Use Max Z")
  344. self.inputs.new ('FloatSocket', "Max Z")
  345. self.inputs.new ('BoolUpdateParentNode', "Use Min Z")
  346. self.inputs.new ('FloatSocket', "Min Z")
  347. self.inputs.new ('BooleanSocket', "Affect Transform")
  348. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  349. self.inputs.new ('FloatFactorSocket', "Influence")
  350. self.inputs.new ('EnableSocket', "Enable")
  351. #
  352. self.outputs.new('RelationshipSocket', "Output Relationship")
  353. self.initialized = True
  354. # color
  355. self.use_custom_color = True
  356. self.color = linkColor
  357. class LinkLimitRotationNode(Node, LinkNode):
  358. # === Basics ===
  359. # Description string
  360. '''A node representing Limit Rotation'''
  361. bl_idname = 'LinkLimitRotation'
  362. bl_label = "Limit Rotation"
  363. bl_icon = 'CON_ROTLIMIT'
  364. initialized : bpy.props.BoolProperty(default = False)
  365. mantis_node_class_name=bl_idname
  366. # === Optional Functions ===
  367. def init(self, context):
  368. self.inputs.new ('RelationshipSocket', "Input Relationship")
  369. self.inputs.new ('BoolUpdateParentNode', "Use X")
  370. self.inputs.new ('FloatAngleSocket', "Min X")
  371. self.inputs.new ('FloatAngleSocket', "Max X")
  372. self.inputs.new ('BoolUpdateParentNode', "Use Y")
  373. self.inputs.new ('FloatAngleSocket', "Min Y")
  374. self.inputs.new ('FloatAngleSocket', "Max Y")
  375. self.inputs.new ('BoolUpdateParentNode', "Use Z")
  376. self.inputs.new ('FloatAngleSocket', "Min Z")
  377. self.inputs.new ('FloatAngleSocket', "Max Z")
  378. self.inputs.new ('BooleanSocket', "Affect Transform")
  379. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  380. self.inputs.new ('FloatFactorSocket', "Influence")
  381. self.inputs.new ('EnableSocket', "Enable")
  382. #
  383. self.outputs.new('RelationshipSocket', "Output Relationship")
  384. self.initialized = True
  385. # color
  386. self.use_custom_color = True
  387. self.color = linkColor
  388. class LinkLimitDistanceNode(Node, LinkNode):
  389. '''A node representing Limit Distance'''
  390. bl_idname = 'LinkLimitDistance'
  391. bl_label = "Limit Distance"
  392. bl_icon = 'CON_DISTLIMIT'
  393. initialized : bpy.props.BoolProperty(default = False)
  394. mantis_node_class_name=bl_idname
  395. def init(self, context):
  396. self.inputs.new ('RelationshipSocket', "Input Relationship")
  397. self.inputs.new ('FloatFactorSocket', "Head/Tail")
  398. self.inputs.new ('BooleanSocket', "UseBBone")
  399. self.inputs.new ('FloatSocket', "Distance")
  400. self.inputs.new ('EnumLimitMode', "Clamp Region")
  401. self.inputs.new ('BooleanSocket', "Affect Transform")
  402. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  403. self.inputs.new ('TransformSpaceSocket', "Target Space")
  404. self.inputs.new ('FloatFactorSocket', "Influence")
  405. self.inputs.new ('xFormSocket', "Target")
  406. self.inputs.new ('EnableSocket', "Enable")
  407. #
  408. self.outputs.new('RelationshipSocket', "Output Relationship")
  409. # color
  410. self.use_custom_color = True
  411. self.color = linkColor
  412. self.initialized = True
  413. class LinkTransformationNode(Node, LinkNode):
  414. '''A node representing Transformation (Constraint)'''
  415. bl_idname = 'LinkTransformation'
  416. bl_label = "Transformation"
  417. bl_icon = 'CON_TRANSFORM'
  418. initialized : bpy.props.BoolProperty(default = False)
  419. mantis_node_class_name=bl_idname
  420. def init(self, context):
  421. hide_me = []
  422. self.inputs.new ('RelationshipSocket', "Input Relationship")
  423. self.inputs.new ('xFormSocket', "Target")
  424. self.inputs.new ('TransformSpaceSocket', "Owner Space")
  425. self.inputs.new ('TransformSpaceSocket', "Target Space")
  426. self.inputs.new ('BooleanSocket', "Extrapolate")
  427. self.inputs.new ('EnumTransformationMap', "Map From")
  428. hide_me.append( self.inputs.new ('EnumTransformationRotationMode', "Rotation Mode"))
  429. self.inputs.new ('FloatSocket', "X Min From")
  430. self.inputs.new ('FloatSocket', "X Max From")
  431. self.inputs.new ('FloatSocket', "Y Min From")
  432. self.inputs.new ('FloatSocket', "Y Max From")
  433. self.inputs.new ('FloatSocket', "Z Min From")
  434. self.inputs.new ('FloatSocket', "Z Max From")
  435. self.inputs.new ('EnumTransformationMap', "Map To")
  436. hide_me.append( self.inputs.new ('EnumTransformationRotationOrder', "Rotation Order"))
  437. self.inputs.new ('EnumTransformationAxes', "X Source Axis")
  438. self.inputs.new ('FloatSocket', "X Min To")
  439. self.inputs.new ('FloatSocket', "X Max To")
  440. self.inputs.new ('EnumTransformationAxes', "Y Source Axis")
  441. self.inputs.new ('FloatSocket', "Y Min To")
  442. self.inputs.new ('FloatSocket', "Y Max To")
  443. self.inputs.new ('EnumTransformationAxes', "Z Source Axis")
  444. self.inputs.new ('FloatSocket', "Z Min To")
  445. self.inputs.new ('FloatSocket', "Z Max To")
  446. self.inputs.new ('EnumTransformationTranslationMixMode', "Mix Mode (Translation)")
  447. hide_me.append( self.inputs.new ('EnumTransformationRotationMixMode', "Mix Mode (Rotation)"))
  448. hide_me.append( self.inputs.new ('EnumTransformationScaleMixMode', "Mix Mode (Scale)"))
  449. self.inputs.new ('FloatFactorSocket', "Influence")
  450. self.inputs.new ('EnableSocket', "Enable")
  451. #
  452. self.outputs.new('RelationshipSocket', "Output Relationship")
  453. for s in hide_me:
  454. s.hide = True
  455. # color
  456. self.use_custom_color = True
  457. self.color = linkColor
  458. self.initialized = True
  459. def display_update(self, parsed_tree, context):
  460. node_tree = context.space_data.path[0].node_tree
  461. nc = parsed_tree.get(get_signature_from_edited_tree(self, context))
  462. if nc:
  463. if nc.evaluate_input("Map From") == "ROTATION":
  464. self.inputs["Rotation Mode"].hide=False
  465. else:
  466. self.inputs["Rotation Mode"].hide=True
  467. if nc.evaluate_input("Map To") == "TRANSLATION":
  468. self.inputs["Rotation Order"].hide=True
  469. self.inputs["Mix Mode (Translation)"].hide=False
  470. self.inputs["Mix Mode (Rotation)"].hide=True
  471. self.inputs["Mix Mode (Scale)"].hide=True
  472. elif nc.evaluate_input("Map To") == "ROTATION":
  473. self.inputs["Rotation Order"].hide=False
  474. self.inputs["Mix Mode (Translation)"].hide=True
  475. self.inputs["Mix Mode (Rotation)"].hide=False
  476. self.inputs["Mix Mode (Scale)"].hide=True
  477. elif nc.evaluate_input("Map To") == "SCALE":
  478. self.inputs["Rotation Order"].hide=True
  479. self.inputs["Mix Mode (Translation)"].hide=True
  480. self.inputs["Mix Mode (Rotation)"].hide=True
  481. self.inputs["Mix Mode (Scale)"].hide=False
  482. class LinkArmatureNode(Node, LinkNode):
  483. """A node representing Blender's Armature Constraint"""
  484. bl_idname = "LinkArmature"
  485. bl_label = "Armature (Constraint)"
  486. bl_icon = "CON_ARMATURE"
  487. initialized : bpy.props.BoolProperty(default = False)
  488. mantis_node_class_name=bl_idname
  489. def init(self, context):
  490. self.inputs.new ("RelationshipSocket", "Input Relationship")
  491. self.inputs.new("BooleanSocket", "Preserve Volume")
  492. self.inputs.new("BooleanSocket", "Use Envelopes")
  493. self.inputs.new("BooleanSocket", "Use Current Location")
  494. self.inputs.new("FloatFactorSocket", "Influence")
  495. self.inputs.new ('EnableSocket', "Enable")
  496. self.outputs.new("RelationshipSocket", "Output Relationship")
  497. # color
  498. self.use_custom_color = True
  499. self.color = inheritColor
  500. self.initialized = True
  501. def draw_buttons(self, context, layout):
  502. # return
  503. layout.operator( 'mantis.link_armature_node_add_target' )
  504. if (len(self.inputs) > 6):
  505. layout.operator( 'mantis.link_armature_node_remove_target' )
  506. else:
  507. layout.label(text="")
  508. class LinkSplineIKNode(Node, LinkNode):
  509. """"A node representing Spline IK"""
  510. bl_idname = "LinkSplineIK"
  511. bl_label = "Spline IK"
  512. bl_icon = "CON_SPLINEIK"
  513. initialized : bpy.props.BoolProperty(default = False)
  514. mantis_node_class_name=bl_idname
  515. def init(self, context):
  516. self.inputs.new ("RelationshipSocket", "Input Relationship")
  517. self.inputs.new("xFormSocket", "Target")
  518. self.inputs.new("IntSocket", "Chain Length")
  519. self.inputs.new("BooleanSocket", "Even Divisions")
  520. self.inputs.new("BooleanSocket", "Chain Offset")
  521. self.inputs.new("BooleanSocket", "Use Curve Radius")
  522. self.inputs.new("EnumYScaleMode", "Y Scale Mode")
  523. self.inputs.new("EnumXZScaleMode", "XZ Scale Mode")
  524. self.inputs.new("BooleanSocket", "Use Original Scale")
  525. self.inputs.new("FloatFactorSocket", "Influence")
  526. self.outputs.new("RelationshipSocket", "Output Relationship")
  527. # color
  528. self.use_custom_color = True
  529. self.color = ikColor
  530. self.initialized = True
  531. # DRIVERS!!
  532. class LinkDrivenParameterNode(Node, LinkNode):
  533. """Represents a driven parameter in the downstream xForm node."""
  534. bl_idname = "LinkDrivenParameter"
  535. bl_label = "Driven Parameter"
  536. bl_icon = "CONSTRAINT_BONE"
  537. initialized : bpy.props.BoolProperty(default = False)
  538. mantis_node_class_name=bl_idname
  539. def init(self, context):
  540. self.inputs.new ( "RelationshipSocket", "Input Relationship" )
  541. self.inputs.new ( "FloatSocket", "Value" )
  542. self.inputs.new ( "ParameterStringSocket", "Parameter" )
  543. self.inputs.new ( "IntSocket", "Index" )
  544. self.inputs.new ('EnableSocket', "Enable")
  545. #
  546. self.outputs.new( "RelationshipSocket", "Output Relationship" )
  547. self.initialized = True
  548. # Set up the class property that ties the UI classes to the Mantis classes.
  549. for cls in TellClasses():
  550. cls.set_mantis_class()