link_definitions.py 27 KB

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