socket_definitions.py 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603
  1. import bpy
  2. from bpy.types import NodeSocket, NodeSocketStandard
  3. from mantis.utilities import (prRed, prGreen, prPurple, prWhite,
  4. prOrange,
  5. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  6. wrapOrange,)
  7. transform_spaces = (('WORLD', "World", "World Space"),
  8. ('LOCAL', "Local", "Local Space"),
  9. ('POSE', "Pose", "Pose Space"),
  10. # ('CUSTOM', "Custom", "Custom Space")
  11. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),)
  12. # ('TRANSFORM', "Pose", "Pose Space"),)
  13. transform_spaces_bone_object = (('WORLD', "World", "World Space"),
  14. ('LOCAL', "Local", "Local Space"),
  15. ('POSE', "Pose", "Pose Space"),)
  16. # ('CUSTOM', "Custom", "Custom Space")
  17. transform_spaces_object = (('WORLD', "World", "World Space"),
  18. ('LOCAL', "Local", "Local Space"),)
  19. # ('CUSTOM', "Custom", "Custom Space")
  20. enumRotationOrder =(('AUTO', 'Auto', 'Auto'),
  21. ('XYZ', "XYZ", "XYZ"),
  22. ('XZY', "XZY", "XZY"),
  23. ('ZXY', "ZXY", "ZXY"),
  24. ('ZYX', "ZYX", "ZYX"),
  25. ('YXZ', "YXZ", "YXZ"),
  26. ('YZX', "YZX", "YZX"),
  27. ('QUATERNION', "Quaternion", "Quaternion"),
  28. ('AXIS_ANGLE', "Axis Angle", "Axis Angle"),)
  29. # node socket colors:
  30. cFloat = (0.631373, 0.631373, 0.631373, 1.000000)
  31. cColor = (0.780392, 0.780392, 0.160784, 1.000000)
  32. cVector = (0.388235, 0.388235, 0.780392, 1.000000)
  33. cShader = (0.388235, 0.780392, 0.388235, 1.000000)
  34. cInt = (0.058824, 0.521569, 0.149020, 1.000000)
  35. cString = (0.388235, 0.388235, 0.388235, 1.000000)
  36. # cBool = (0.698039, 0.650980, 0.188235, 1.000000)
  37. cParameter = (0.48, 0.24, 0.24, 1.0)
  38. cDriver = (0.88, 0.11, 0.88, 1.0)
  39. cDriverVariable = (0.66, 0.33, 0.04, 1.0)
  40. cFCurve = (0.77, 0.77, 0.11, 1.0)
  41. cKeyframe = (0.06, 0.22, 0.88, 1.0)
  42. cEnable = (0.92, 0.92, 0.92, 1.0)
  43. cLayerMask = (0.82, 0.82, 0.82, 1.0)
  44. cDeformer = (0.05, 0.08, 0.45, 1.0)
  45. # custom colors:
  46. cIK = (0.596078, 0.596078, 0.364706, 1.000000) #because it's yellow in Blender
  47. cRelationship = (0.352941, 0.584314, 0.431373, 1.000000) #constraint color
  48. cMatrix = (0.0, 1.0, 0.75, 1)
  49. cxForm = (0.843137, 0.592157, 0.388235, 1.000000) #could even fetch the theme colors...
  50. cTransformSpace = (1.0, 0.4, 0.216, 1.0)
  51. cBool = (0.1, 0.1, 0.1, 1.0)
  52. cBool3 = (0.35, 0.25, 0.18, 1.0)
  53. cRotationOrder = (0.0, 0.8, 0.0, 1.0)
  54. cQuaternion = (0.85, 0.25, 0.18, 1.0)
  55. #
  56. cGeometry = (0.000000, 0.672443, 0.366253, 1.000000)
  57. # think about making colors that are representative of the data's purpose:
  58. # location
  59. # rotation
  60. # scale
  61. # OR make all of it a reference to the type of data within?
  62. # Hybrid approach: Make same-data, similar purpose have similar colors.
  63. def TellClasses():
  64. return [ #MantisSocket,
  65. #DefaultSocket,
  66. #InputSocket,
  67. MatrixSocket,
  68. xFormSocket,
  69. xFormMultiSocket,
  70. RelationshipSocket,
  71. DeformerSocket,
  72. GeometrySocket,
  73. GenericRotationSocket,
  74. EnableSocket,
  75. HideSocket,
  76. # InverseKinematicsSocket,
  77. DriverSocket,
  78. DriverVariableSocket,
  79. FCurveSocket,
  80. KeyframeSocket,
  81. LayerMaskSocket,
  82. LayerMaskInputSocket,
  83. xFormParameterSocket,
  84. ParameterBoolSocket,
  85. ParameterIntSocket,
  86. ParameterFloatSocket,
  87. ParameterVectorSocket,
  88. ParameterStringSocket,
  89. TransformSpaceSocket,
  90. BooleanSocket,
  91. BooleanThreeTupleSocket,
  92. RotationOrderSocket,
  93. QuaternionSocket,
  94. QuaternionSocketAA,
  95. IntSocket,
  96. StringSocket,
  97. EnumMetaRigSocket,
  98. EnumMetaBoneSocket,
  99. BoolUpdateParentNode,
  100. LabelSocket,
  101. IKChainLengthSocket,
  102. EnumInheritScale,
  103. EnumRotationMix,
  104. EnumRotationMixCopyTransforms,
  105. EnumMaintainVolumeStretchTo,
  106. EnumRotationStretchTo,
  107. EnumTrackAxis,
  108. EnumUpAxis,
  109. EnumLockAxis,
  110. EnumLimitMode,
  111. EnumYScaleMode,
  112. EnumXZScaleMode,
  113. EnumTransformationMap,
  114. EnumTransformationRotationMode,
  115. EnumTransformationRotationOrder,
  116. EnumTransformationTranslationMixMode,
  117. EnumTransformationRotationMixMode,
  118. EnumTransformationScaleMixMode,
  119. EnumTransformationAxes,
  120. # Deformers
  121. EnumSkinning,
  122. #
  123. FloatSocket,
  124. FloatPositiveSocket,
  125. FloatFactorSocket,
  126. FloatAngleSocket,
  127. VectorSocket,
  128. VectorEulerSocket,
  129. VectorTranslationSocket,
  130. VectorScaleSocket,
  131. # Drivers
  132. EnumDriverVariableType,
  133. EnumDriverVariableEvaluationSpace,
  134. EnumDriverRotationMode,
  135. EnumDriverType,]
  136. def Tell_bl_idnames():
  137. return [cls.bl_idname for cls in TellClasses()]
  138. # Was setting color like this:
  139. # color : bpy.props.FloatVectorProperty(size = 4, default = cFCurve,)
  140. # but this didn't work when Blender automatically generated interface classes?
  141. # so changed it to color = cVariable
  142. # but for color-changing sockets, if I make them, this won' work? Maybe?
  143. #
  144. # I actually think I was wrong about all of that lol
  145. # TODO change it back, dingus
  146. ########################################################################
  147. # Update Callbacks
  148. ########################################################################
  149. def default_update(socket, context, do_execute=True):
  150. context = bpy.context
  151. if not context.space_data:
  152. return
  153. if not hasattr(context.space_data, "path"):
  154. return
  155. node_tree = context.space_data.path[0].node_tree
  156. if node_tree.do_live_update:
  157. # I don't know how the tree can be valid at 0 nodes but doesn't hurt
  158. # to force it if this somehow happens.
  159. if ((node_tree.tree_valid == False or len(node_tree.parsed_tree) == 0)
  160. or socket.node.bl_idname in ["MantisNodeGroup"]):
  161. # prGreen("Forcing Update From Socket Change.")
  162. node_tree.update_tree(context)
  163. elif (node_tree.tree_valid == True):
  164. # prGreen("Partial Update From Socket Change.")
  165. # We don't have to update the whole thing, just the socket
  166. from mantis.utilities import tree_from_nc
  167. for nc in node_tree.parsed_tree.values():
  168. try:
  169. if (tree_from_nc(nc.signature, nc.base_tree) == socket.node.id_data):
  170. if socket.node.name in nc.signature:
  171. getstring = socket.name
  172. if (getstring not in nc.parameters.keys()):
  173. prRed("Socket update failed for %s" % socket.name)
  174. else:
  175. nc.parameters[getstring] = socket.default_value
  176. except AttributeError as e:
  177. prWhite(nc)
  178. prWhite(nc.inputs)
  179. raise e
  180. # Now update the tree display:
  181. node_tree.display_update(context)
  182. if node_tree.do_live_update:
  183. try:
  184. node_tree.execute_tree(context)
  185. except Exception as e:
  186. prRed("Automatic Tree Execution failed because of %s" % e)
  187. def update_socket(self, context,):
  188. default_update(self,context)
  189. def update_mute_socket(self, context):
  190. self.node.mute = not self.default_value
  191. default_update(self,context)
  192. def update_hide_socket(self, context):
  193. self.node.mute = self.default_value
  194. default_update(self,context)
  195. def update_parent_node(self, context):
  196. default_update(self,context)
  197. if hasattr(self.node, "display_update"):
  198. self.node.display_update(context)
  199. def ik_chain_length_update_socket(self, context):
  200. default_update(self,context)
  201. # self.node.update_chain_length(context)
  202. # Driver Variable:
  203. def driver_variable_socket_update(self, context):
  204. default_update(self,context)
  205. self.node.update_on_socket_change(context)
  206. def driver_socket_update(self, context):
  207. default_update(self,context)
  208. self.node.update_on_socket_change(context)
  209. def update_metarig_armature(self, context,):
  210. if self.search_prop:
  211. self.node.armature = self.search_prop.name
  212. self.node.inputs["Meta-Bone"].search_prop = self.search_prop
  213. default_update(self,context)
  214. def update_metarig_posebone(self, context,):
  215. self.node.pose_bone = self.default_value
  216. default_update(self,context)
  217. ########################################################################
  218. # Sockets
  219. ########################################################################
  220. def ChooseDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  221. # TEXT ONLY
  222. if ( (hasattr(self, "text_only")) and (getattr(self, "text_only") ) ):
  223. layout.label(text=text)
  224. # ENUM VALUES (this is a HACK, fix it later)
  225. elif ('Enum' in self.bl_idname) and (use_enum):
  226. layout.prop_tabs_enum(self, "default_value",)
  227. # for OUTPUT sockets that take INPUT (confusing name!)
  228. elif ((hasattr(self, "default_value")) and hasattr(self, "input") and getattr(self, "input")):
  229. # for simple input nodes
  230. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True)
  231. # for INPUTS that are NOT CONNECTED
  232. elif (hasattr(self, "default_value")) and not (self.is_output or self.is_linked):
  233. # DO: expose these values as parameters for this function
  234. # and set them for each socket.
  235. if icon == 'NONE': icon_only = False
  236. elif icon_only == True : text = "" # "real" icon-only looks bad for strings, need to check other props types.
  237. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True, icon=icon,)
  238. # CONNECTED sockets and outputs without input fields
  239. else:
  240. layout.label(text=text)
  241. class RelationshipSocket(NodeSocket):
  242. # Description string
  243. '''Relationship'''
  244. # Optional identifier string. If not explicitly defined, the python class name is used.
  245. bl_idname = 'RelationshipSocket'
  246. bl_label = "Relationship"
  247. color = cRelationship
  248. input : bpy.props.BoolProperty(default =False,)
  249. def draw(self, context, layout, node, text):
  250. ChooseDraw(self, context, layout, node, text)
  251. def draw_color(self, context, node):
  252. return self.color
  253. class DeformerSocket(NodeSocket):
  254. # Description string
  255. '''Deformer'''
  256. # Optional identifier string. If not explicitly defined, the python class name is used.
  257. bl_idname = 'DeformerSocket'
  258. bl_label = "Deformer"
  259. color = cDeformer
  260. input : bpy.props.BoolProperty(default =False,)
  261. def draw(self, context, layout, node, text):
  262. ChooseDraw(self, context, layout, node, text)
  263. def draw_color(self, context, node):
  264. return self.color
  265. class MatrixSocket(NodeSocket):
  266. '''Matrix Input Output'''
  267. bl_idname = 'MatrixSocket'
  268. bl_label = "Matrix"
  269. default_value : bpy.props.FloatVectorProperty(
  270. default = (1.0, 0.0, 0.0, 0.0,
  271. 0.0, 1.0, 0.0, 0.0,
  272. 0.0, 0.0, 1.0, 0.0,
  273. 0.0, 0.0, 0.0, 1.0),
  274. size=16,
  275. update = update_socket,)
  276. color = cMatrix
  277. input : bpy.props.BoolProperty(default =False,)
  278. # Optional function for drawing the socket input value
  279. def draw(self, context, layout, node, text):
  280. layout.label(text=text)
  281. def draw_color(self, context, node):
  282. return self.color
  283. # Utility functions to make handling the 16 numbers more bearable
  284. def SetValue(self, mat):
  285. self.default_value = ( mat[0][0], mat[0][1], mat[0][2], mat[0][3],
  286. mat[1][0], mat[1][1], mat[1][2], mat[1][3],
  287. mat[2][0], mat[2][1], mat[2][2], mat[2][3],
  288. mat[3][0], mat[3][1], mat[3][2], mat[3][3], )
  289. def TellValue(self):
  290. from mathutils import Matrix
  291. v = self.default_value
  292. return Matrix( ( ( v[ 0], v[ 1], v[ 2], v[ 3],),
  293. ( v[ 4], v[ 5], v[ 6], v[ 7],),
  294. ( v[ 8], v[ 9], v[10], v[11],),
  295. ( v[12], v[13], v[14], v[15]), ) )
  296. #NOTE, we're not using the last row
  297. # so we're gonna use it to store data
  298. # unused, unused, unused, bone_length
  299. # but we're not going to make it
  300. # available except by accessor functions
  301. # would like to make this stuff easier to deal with tho
  302. def TellBoneLength(self):
  303. return self.default_value[15]
  304. class xFormSocket(NodeSocket):
  305. '''xFrom Input Output'''
  306. bl_idname = 'xFormSocket'
  307. bl_label = "xForm"
  308. color = cxForm
  309. input : bpy.props.BoolProperty(default =False,)
  310. def draw(self, context, layout, node, text):
  311. ChooseDraw(self, context, layout, node, text)
  312. def draw_color(self, context, node):
  313. return self.color
  314. class xFormMultiSocket(NodeSocket):
  315. '''xFrom Input Output'''
  316. bl_idname = 'xFormMultiSocket'
  317. bl_label = "xForm"
  318. color = cxForm
  319. input : bpy.props.BoolProperty(default =False,)
  320. def __init__(self):
  321. # self.is_multi_input=True
  322. self.link_limit=0
  323. def draw(self, context, layout, node, text):
  324. ChooseDraw(self, context, layout, node, text)
  325. def draw_color(self, context, node):
  326. return self.color
  327. class GeometrySocket(NodeSocket):
  328. '''Geometry Input Output'''
  329. bl_idname = 'GeometrySocket'
  330. bl_label = "Geometry"
  331. color = cGeometry
  332. input : bpy.props.BoolProperty(default =False,)
  333. def draw(self, context, layout, node, text):
  334. ChooseDraw(self, context, layout, node, text)
  335. def draw_color(self, context, node):
  336. return self.color
  337. class GenericRotationSocket(NodeSocket):
  338. '''Custom node socket type'''
  339. bl_idname = 'GenericRotationSocket'
  340. bl_label = "Rotation"
  341. color = (0.0,0.0,0.0,0.0)
  342. input : bpy.props.BoolProperty(default =False,)
  343. def draw(self, context, layout, node, text):
  344. ChooseDraw(self, context, layout, node, text)
  345. def draw_color(self, context, node):
  346. return self.color
  347. #TODO reimplement the below
  348. # not high priority in the least
  349. # def draw(self, context, layout, node, text):
  350. # if ((self.is_linked) and (not ToMathutilsValue(QuerySocket(self)[0]))):
  351. # layout.label(text="Invalid Input")
  352. # else:
  353. # layout.label(text=text)
  354. # def draw_color(self, context, node):
  355. # from mathutils import Vector, Euler, Matrix, Quaternion
  356. # sock = QuerySocket(self)[0]
  357. # val = ToMathutilsValue(sock)
  358. # color = (1.0, 0.0, 0.0, 1.0,)
  359. # if (not self.is_linked):
  360. # color = (0.0, 0.0, 0.0, 0.0,)
  361. # if (val):
  362. # if ((isinstance(val, Vector)) or (isinstance(val, Euler))):
  363. # color = cVector
  364. # elif (isinstance(val, Quaternion)):
  365. # color = cQuaternion
  366. # elif (isinstance(val, Matrix)):
  367. # color = cMatrix
  368. # return (color)
  369. ###############################
  370. class EnableSocket(NodeSocket):
  371. '''Custom node socket type'''
  372. bl_idname = 'EnableSocket'
  373. bl_label = "Enable"
  374. default_value: bpy.props.BoolProperty(default=True, update = update_mute_socket,)
  375. color = cEnable
  376. input : bpy.props.BoolProperty(default =False,)
  377. def draw(self, context, layout, node, text):
  378. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  379. def draw_color(self, context, node):
  380. return self.color
  381. class HideSocket(NodeSocket):
  382. '''Custom node socket type'''
  383. bl_idname = 'HideSocket'
  384. bl_label = "Enable"
  385. default_value: bpy.props.BoolProperty(default=False, update = update_hide_socket,)
  386. color = cEnable
  387. input : bpy.props.BoolProperty(default =False,)
  388. def draw(self, context, layout, node, text):
  389. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  390. def draw_color(self, context, node):
  391. return self.color
  392. class FCurveSocket(NodeSocket):
  393. '''fCurve'''
  394. bl_idname = 'FCurveSocket'
  395. bl_label = "fCurve"
  396. color = cFCurve
  397. input : bpy.props.BoolProperty(default =False, update = update_socket)
  398. def __init__(self):
  399. self.display_shape = 'DIAMOND'
  400. def draw(self, context, layout, node, text):
  401. ChooseDraw(self, context, layout, node, text)
  402. def draw_color(self, context, node):
  403. return self.color
  404. class KeyframeSocket(NodeSocket):
  405. '''Keyframe'''
  406. bl_idname = 'KeyframeSocket'
  407. bl_label = "Keyframe"
  408. color = cKeyframe
  409. input : bpy.props.BoolProperty(default =False, update = update_socket)
  410. def __init__(self):
  411. self.display_shape = 'DIAMOND'
  412. def draw(self, context, layout, node, text):
  413. ChooseDraw(self, context, layout, node, text)
  414. def draw_color(self, context, node):
  415. return self.color
  416. class DriverSocket(NodeSocket):
  417. '''Driver'''
  418. bl_idname = 'DriverSocket'
  419. bl_label = "Driver"
  420. color = cDriver
  421. input : bpy.props.BoolProperty(default =False, update = update_socket)
  422. def __init__(self):
  423. self.display_shape = 'DIAMOND'
  424. def draw(self, context, layout, node, text):
  425. ChooseDraw(self, context, layout, node, text)
  426. def draw_color(self, context, node):
  427. return self.color
  428. class DriverVariableSocket(NodeSocket):
  429. '''Driver'''
  430. bl_idname = 'DriverVariableSocket'
  431. bl_label = "Driver"
  432. color = cDriverVariable
  433. input : bpy.props.BoolProperty(default =False, update = update_socket)
  434. def __init__(self):
  435. self.display_shape = 'DIAMOND'
  436. def draw(self, context, layout, node, text):
  437. ChooseDraw(self, context, layout, node, text)
  438. def draw_color(self, context, node):
  439. return self.color
  440. # transform_spaces
  441. # transform_spaces_bone_object
  442. # transform_spaces_object
  443. # def get_transform_space_enum(self, context):
  444. # pass
  445. class TransformSpaceSocket(NodeSocket):
  446. '''Custom node socket type'''
  447. bl_idname = 'TransformSpaceSocket'
  448. bl_label = "Transform Space"
  449. default_value: bpy.props.EnumProperty(
  450. name="Space Transform",
  451. description="Space Transform",
  452. items=transform_spaces,
  453. default='WORLD',
  454. update = update_socket,)
  455. color = cTransformSpace
  456. input : bpy.props.BoolProperty(default =False,)
  457. def draw(self, context, layout, node, text):
  458. ChooseDraw(self, context, layout, node, text)
  459. def draw_color(self, context, node):
  460. return self.color
  461. class BooleanSocket(NodeSocket):
  462. '''Custom node socket type'''
  463. bl_idname = 'BooleanSocket'
  464. bl_label = "Boolean"
  465. default_value: bpy.props.BoolProperty(update = update_socket,)
  466. color = cBool
  467. input : bpy.props.BoolProperty(default =False,)
  468. def draw(self, context, layout, node, text):
  469. ChooseDraw(self, context, layout, node, text)
  470. def draw_color(self, context, node):
  471. return self.color
  472. class BooleanThreeTupleSocket(NodeSocket):
  473. # Description string
  474. '''Custom node socket type'''
  475. # Optional identifier string. If not explicitly defined, the python class name is used.
  476. bl_idname = 'BooleanThreeTupleSocket'
  477. bl_label = "Boolean Vector"
  478. default_value: bpy.props.BoolVectorProperty(subtype = "XYZ",update = update_socket,)
  479. color = cBool3
  480. input : bpy.props.BoolProperty(default =False,)
  481. def draw(self, context, layout, node, text):
  482. ChooseDraw(self, context, layout, node, text)
  483. def draw_color(self, context, node):
  484. return self.color
  485. def TellValue(self):
  486. return (self.default_value[0], self.default_value[1], self.default_value[2])
  487. class RotationOrderSocket(NodeSocket):
  488. '''Custom node socket type'''
  489. bl_idname = 'RotationOrderSocket'
  490. bl_label = "Rotation Order"
  491. default_value: bpy.props.EnumProperty(
  492. name="Rotation Order",
  493. description="Rotation Order",
  494. items=enumRotationOrder,
  495. default='AUTO',
  496. update = update_socket,)
  497. color = cRotationOrder
  498. input : bpy.props.BoolProperty(default =False,)
  499. def draw(self, context, layout, node, text):
  500. ChooseDraw(self, context, layout, node, text)
  501. def draw_color(self, context, node):
  502. return self.color
  503. class QuaternionSocket(NodeSocket):
  504. '''Custom node socket type'''
  505. bl_idname = 'QuaternionSocket'
  506. bl_label = "Quaternion"
  507. default_value: bpy.props.FloatVectorProperty(
  508. subtype = "QUATERNION",
  509. size = 4,
  510. default = (1.0, 0.0, 0.0, 0.0,),
  511. update = update_socket,)
  512. color = cQuaternion
  513. input : bpy.props.BoolProperty(default =False,)
  514. def draw(self, context, layout, node, text):
  515. ChooseDraw(self, context, layout, node, text)
  516. def draw_color(self, context, node):
  517. return self.color
  518. class QuaternionSocketAA(NodeSocket):
  519. '''Custom node socket type'''
  520. bl_idname = 'QuaternionSocketAA'
  521. bl_label = "Axis Angle"
  522. color = cQuaternion
  523. input : bpy.props.BoolProperty(default =False,)
  524. default_value: bpy.props.FloatVectorProperty(
  525. subtype = "AXISANGLE",
  526. size = 4,
  527. default = (1.0, 0.0, 0.0, 0.0,),
  528. update = update_socket,)
  529. def draw(self, context, layout, node, text):
  530. ChooseDraw(self, context, layout, node, text)
  531. def draw_color(self, context, node):
  532. return self.color
  533. class IntSocket(NodeSocket):
  534. '''Custom node socket type'''
  535. bl_idname = 'IntSocket'
  536. bl_label = "Boolean"
  537. default_value: bpy.props.IntProperty(default=0, update = update_socket,)
  538. color = cInt
  539. input : bpy.props.BoolProperty(default =False,)
  540. def draw(self, context, layout, node, text):
  541. ChooseDraw(self, context, layout, node, text)
  542. def draw_color(self, context, node):
  543. return self.color
  544. class StringSocket(bpy.types.NodeSocketString):
  545. """Float Input socket"""
  546. bl_idname = 'StringSocket'
  547. bl_label = "Float"
  548. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  549. # text_only : bpy.props.BoolProperty(default=False)
  550. color = cString
  551. icon : bpy.props.StringProperty(default = "NONE",)
  552. input : bpy.props.BoolProperty(default =False,)
  553. # def __init__(self):
  554. # if self.node.bl_idname == 'UtilityBoneProperties':
  555. # self.display_shape='DIAMOND'
  556. def draw(self, context, layout, node, text):
  557. ChooseDraw(self, context, layout, node, text, icon=self.icon, icon_only=True)
  558. def draw_color(self, context, node):
  559. return self.color
  560. class LayerMaskSocket(bpy.types.NodeSocket):
  561. """Layer Mask Input socket"""
  562. bl_idname = 'LayerMaskSocket'
  563. bl_label = "Layer Mask"
  564. default_value: bpy.props.BoolVectorProperty(subtype = "LAYER", update = update_socket, size=32)
  565. color = cLayerMask
  566. input : bpy.props.BoolProperty(default =False,)
  567. def draw(self, context, layout, node, text):
  568. ChooseDraw(self, context, layout, node, text)
  569. def draw_color(self, context, node):
  570. return self.color
  571. class LayerMaskInputSocket(bpy.types.NodeSocket): # I can probably use inheritance somehow lol
  572. """Layer Mask Input socket"""
  573. bl_idname = 'LayerMaskInputSocket'
  574. bl_label = "Layer Mask"
  575. default_value: bpy.props.BoolVectorProperty(subtype = "LAYER", update = update_socket, size=32)
  576. color = cLayerMask
  577. input : bpy.props.BoolProperty(default =True,)
  578. def draw(self, context, layout, node, text):
  579. ChooseDraw(self, context, layout, node, text)
  580. def draw_color(self, context, node):
  581. return self.color
  582. #####################################################################################
  583. # Parameters
  584. #####################################################################################
  585. class xFormParameterSocket(NodeSocket):
  586. '''xFrom Parameter'''
  587. bl_idname = 'xFormParameterSocket'
  588. bl_label = "Parameter"
  589. color = cxForm
  590. input : bpy.props.BoolProperty(default =False,)
  591. def __init__(self):
  592. self.display_shape = 'DIAMOND'
  593. def draw(self, context, layout, node, text):
  594. ChooseDraw(self, context, layout, node, text)
  595. def draw_color(self, context, node):
  596. return self.color
  597. # what is this one again?
  598. class ParameterBoolSocket(bpy.types.NodeSocket):
  599. """Boolean Parameter Socket"""
  600. bl_idname = 'ParameterBoolSocket'
  601. bl_label = "Bool"
  602. color = cBool
  603. input : bpy.props.BoolProperty(default =False,)
  604. #custom properties:
  605. min:bpy.props.FloatProperty(default = 0)
  606. max:bpy.props.FloatProperty(default = 1)
  607. soft_min:bpy.props.FloatProperty(default = 0)
  608. soft_max:bpy.props.FloatProperty(default = 1)
  609. description:bpy.props.StringProperty(default = "")
  610. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  611. def __init__(self):
  612. self.display_shape = 'DIAMOND'
  613. # if True:
  614. # print (self.is_property_set("default_value"))
  615. # ui_data = self.id_properties_ui("default_value")
  616. # ui_data.update(
  617. # description=self.description,
  618. # default=0,) # for now
  619. # ui_data.update(
  620. # min = self.min,
  621. # max = self.max,
  622. # soft_min = self.soft_min,
  623. # soft_max = self.soft_max,)
  624. def draw(self, context, layout, node, text):
  625. ChooseDraw(self, context, layout, node, text)
  626. def draw_color(self, context, node):
  627. return self.color
  628. class ParameterIntSocket(bpy.types.NodeSocket):
  629. """Integer Parameter socket"""
  630. bl_idname = 'ParameterIntSocket'
  631. bl_label = "Int"
  632. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  633. color = cInt
  634. input : bpy.props.BoolProperty(default =False,)
  635. #custom properties:
  636. min:bpy.props.FloatProperty(default = 0)
  637. max:bpy.props.FloatProperty(default = 1)
  638. soft_min:bpy.props.FloatProperty(default = 0)
  639. soft_max:bpy.props.FloatProperty(default = 1)
  640. description:bpy.props.StringProperty(default = "")
  641. def __init__(self):
  642. self.display_shape = 'DIAMOND'
  643. def draw(self, context, layout, node, text):
  644. ChooseDraw(self, context, layout, node, text)
  645. def draw_color(self, context, node):
  646. return self.color
  647. class ParameterFloatSocket(bpy.types.NodeSocket):
  648. """Float Parameter socket"""
  649. bl_idname = 'ParameterFloatSocket'
  650. bl_label = "Float"
  651. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  652. color = cFloat
  653. input : bpy.props.BoolProperty(default =False,)
  654. #custom properties:
  655. min:bpy.props.FloatProperty(default = 0)
  656. max:bpy.props.FloatProperty(default = 1)
  657. soft_min:bpy.props.FloatProperty(default = 0)
  658. soft_max:bpy.props.FloatProperty(default = 1)
  659. description:bpy.props.StringProperty(default = "")
  660. def __init__(self):
  661. self.display_shape = 'DIAMOND'
  662. def draw(self, context, layout, node, text):
  663. ChooseDraw(self, context, layout, node, text)
  664. def draw_color(self, context, node):
  665. return self.color
  666. class ParameterVectorSocket(bpy.types.NodeSocket):
  667. """Vector Parameter socket"""
  668. bl_idname = 'ParameterVectorSocket'
  669. bl_label = "Vector"
  670. default_value : bpy.props.FloatVectorProperty(
  671. default = (0.0, 0.0, 0.0),
  672. update = update_socket,)
  673. color = cVector
  674. input : bpy.props.BoolProperty(default =False,)
  675. #custom properties:
  676. description:bpy.props.StringProperty(default = "")
  677. def __init__(self):
  678. self.display_shape = 'DIAMOND'
  679. def draw(self, context, layout, node, text):
  680. ChooseDraw(self, context, layout, node, text)
  681. def draw_color(self, context, node):
  682. return self.color
  683. class ParameterStringSocket(bpy.types.NodeSocket):
  684. """String Parameter socket"""
  685. bl_idname = 'ParameterStringSocket'
  686. bl_label = "Float"
  687. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  688. color = cString
  689. input : bpy.props.BoolProperty(default =False,)
  690. text_only : bpy.props.BoolProperty(default=False)
  691. #custom properties:
  692. description:bpy.props.StringProperty(default = "")
  693. def __init__(self):
  694. self.display_shape = 'DIAMOND'
  695. def draw(self, context, layout, node, text):
  696. ChooseDraw(self, context, layout, node, text)
  697. def draw_color(self, context, node):
  698. return self.color
  699. #####################################################################################
  700. # Additional socket types, for special cases
  701. #####################################################################################
  702. from bpy.props import PointerProperty, StringProperty
  703. def poll_is_armature(self, obj):
  704. return obj.type == "ARMATURE"
  705. # def poll_is_armature(self, obj):
  706. # return obj.type == "ARMATURE"
  707. class EnumMetaRigSocket(NodeSocket):
  708. '''Custom node socket type'''
  709. bl_idname = 'EnumMetaRigSocket'
  710. bl_label = "Meta Rig"
  711. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  712. def get_default_value(self):
  713. return self.search_prop.name
  714. default_value : StringProperty(name = "", get=get_default_value)
  715. color = cString
  716. def draw(self, context, layout, node, text):
  717. if not (self.is_linked):
  718. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  719. else:
  720. layout.label(text=self.node.armature)
  721. def draw_color(self, context, node):
  722. return self.color
  723. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  724. layout.prop_search(data=self, property="default_value", search_data=self.search_prop.data, search_property="bones", text=text, icon=icon, results_are_suggestions=True)
  725. class EnumMetaBoneSocket(NodeSocket):
  726. '''Custom node socket type'''
  727. bl_idname = 'EnumMetaBoneSocket'
  728. bl_label = "Meta Bone"
  729. search_prop:PointerProperty(type=bpy.types.Object)
  730. bone:StringProperty()
  731. def populate_bones_list(self, context):
  732. # just gonna hardcode the value
  733. if (meta_rig := self.search_prop):
  734. retList = []
  735. armatures = []
  736. i = -1
  737. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  738. for b in meta_rig.data.bones:
  739. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  740. return(retList)
  741. return None
  742. # default_value : bpy.props.EnumProperty(
  743. # items = populate_bones_list,
  744. # name = "Meta Rig")
  745. def get_default_value(self):
  746. return self.search_prop.name
  747. default_value : StringProperty(name = "", update=update_metarig_posebone)
  748. color = cString
  749. def draw(self, context, layout, node, text):
  750. if not (self.is_linked):
  751. if self.search_prop is None:
  752. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  753. else:
  754. SearchPBDraw(self, context, layout, node, text="")
  755. else:
  756. layout.label(text=self.node.pose_bone)
  757. def draw_color(self, context, node):
  758. return self.color
  759. class BoolUpdateParentNode(NodeSocket):
  760. '''Custom node socket type'''
  761. bl_idname = 'BoolUpdateParentNode'
  762. bl_label = "Boolean"
  763. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  764. color = cBool
  765. input : bpy.props.BoolProperty(default =False,)
  766. def draw(self, context, layout, node, text):
  767. ChooseDraw(self, context, layout, node, text)
  768. def draw_color(self, context, node):
  769. return self.color
  770. class LabelSocket(bpy.types.NodeSocket):
  771. """Float Input socket"""
  772. bl_idname = 'LabelSocket'
  773. bl_label = "Label"
  774. color = (0.000, 0.000, 0.000, 0.000000)
  775. input : bpy.props.BoolProperty(default =False,)
  776. def draw(self, context, layout, node, text):
  777. ChooseDraw(self, context, layout, node, text)
  778. def draw_color(self, context, node):
  779. return self.color
  780. class IKChainLengthSocket(NodeSocket):
  781. '''Custom node socket type'''
  782. bl_idname = 'IKChainLengthSocket'
  783. bl_label = "Chain Length"
  784. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  785. color = cInt
  786. input : bpy.props.BoolProperty(default =False,)
  787. def draw(self, context, layout, node, text):
  788. ChooseDraw(self, context, layout, node, text)
  789. def draw_color(self, context, node):
  790. return self.color
  791. # Inherit
  792. eInheritScale = (
  793. ('FULL', "Full", "Fully inherit scale", 1),
  794. ('AVERAGE', "Average", "todo", 2),
  795. ('ALIGNED', "Aligned", "todo", 3),
  796. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  797. ('NONE', "None", "todo", 5),
  798. )
  799. class EnumInheritScale(NodeSocket):
  800. '''Custom node socket type'''
  801. bl_idname = 'EnumInheritScale'
  802. bl_label = "Inherit Scale"
  803. default_value: bpy.props.EnumProperty(
  804. items=eInheritScale,
  805. name="Inherit Scale",
  806. description="Inherit Scale",
  807. default = 'FULL',
  808. #options = set(),
  809. update = update_socket,)
  810. color = cString
  811. input : bpy.props.BoolProperty(default =False,)
  812. def draw(self, context, layout, node, text):
  813. ChooseDraw(self, context, layout, node, text)
  814. def draw_color(self, context, node):
  815. return self.color
  816. # Copy Rotation
  817. eRotationMix =(
  818. ('REPLACE', "Replace", "Fully inherit scale", 0),
  819. ('BEFORE', "Before", "Fully inherit scale", 1),
  820. ('AFTER', "After", "Fully inherit scale", 2),
  821. ('ADD', "Add", "Fully inherit scale", 3),
  822. #todo, but i don't care much
  823. )
  824. # TODO HACK
  825. # I am trying to figure out how to do enum_flag as
  826. # mutually exclusive options
  827. # but! I don't think it's possible
  828. # I just like the UI for it :P
  829. class EnumRotationMix(NodeSocket):
  830. '''Custom node socket type'''
  831. bl_idname = 'EnumRotationMix'
  832. bl_label = "Rotation Mix"
  833. default_value: bpy.props.EnumProperty(
  834. items=eRotationMix,
  835. name="Rotation Mix",
  836. description="Rotation Mix",
  837. default = 'REPLACE',#{'REPLACE'},
  838. options = set(), # this has to be a set lol
  839. update = update_socket,)
  840. color = cString
  841. input : bpy.props.BoolProperty(default =False,)
  842. def draw(self, context, layout, node, text):
  843. ChooseDraw(self, context, layout, node, text)
  844. def draw_color(self, context, node):
  845. return self.color
  846. eRotationMix_copytransforms =(
  847. ('REPLACE', "Replace", "Fully inherit scale"),
  848. ('BEFORE', "Before", "Fully inherit scale"),
  849. ('AFTER', "After", "Fully inherit scale"),)
  850. class EnumRotationMixCopyTransforms(NodeSocket):
  851. '''Custom node socket type'''
  852. bl_idname = 'EnumRotationMixCopyTransforms'
  853. bl_label = "Rotation Mix"
  854. default_value: bpy.props.EnumProperty(
  855. items=eRotationMix_copytransforms,
  856. name="Rotation Mix",
  857. description="Rotation Mix",
  858. default = 'REPLACE', #{'REPLACE'},
  859. #options = {'ENUM_FLAG'}, # this sux
  860. update = update_socket,)
  861. color = cString
  862. input : bpy.props.BoolProperty(default =False,)
  863. def draw(self, context, layout, node, text):
  864. ChooseDraw(self, context, layout, node, text)
  865. def draw_color(self, context, node):
  866. return self.color
  867. # STRETCH TO
  868. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  869. ('VOLUME_X', "X", "X", 2),
  870. ('VOLUME_Z', "Z", "Z", 4),
  871. ('NO_VOLUME', "None", "None", 8),)
  872. class EnumMaintainVolumeStretchTo(NodeSocket):
  873. '''Custom node socket type'''
  874. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  875. bl_label = "Maintain Volume"
  876. default_value: bpy.props.EnumProperty(
  877. items=eMaintainVolumeStretchTo,
  878. name="Maintain Volume",
  879. description="Maintain Volume",
  880. default = 'VOLUME_XZX',
  881. #options = {'ENUM_FLAG'},
  882. update = update_socket,)
  883. color = cString
  884. input : bpy.props.BoolProperty(default =False,)
  885. def draw(self, context, layout, node, text):
  886. ChooseDraw(self, context, layout, node, text)
  887. def draw_color(self, context, node):
  888. return self.color
  889. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  890. ('PLANE_Z', "ZX", "ZX", 2),
  891. ('SWING_Y', "Swing", "Swing", 4),)
  892. class EnumRotationStretchTo(NodeSocket):
  893. '''Custom node socket type'''
  894. bl_idname = 'EnumRotationStretchTo'
  895. bl_label = "Rotation"
  896. default_value: bpy.props.EnumProperty(
  897. items=eRotationStretchTo,
  898. name="Rotation",
  899. description="Rotation",
  900. default = 'PLANE_X',
  901. #options = {'ENUM_FLAG'},
  902. update = update_socket,)
  903. color = cString
  904. input : bpy.props.BoolProperty(default =False,)
  905. def draw(self, context, layout, node, text):
  906. ChooseDraw(self, context, layout, node, text)
  907. def draw_color(self, context, node):
  908. return self.color
  909. # Track-To
  910. eTrackAxis = (('TRACK_X', "X", "X", 1),
  911. ('TRACK_Y', "Y", "Y", 2),
  912. ('TRACK_Z', "Z", "Z", 4),
  913. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  914. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  915. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  916. eUpAxis = (('UP_X', "X", "X", 1),
  917. ('UP_Y', "Y", "Y", 2),
  918. ('UP_Z', "Z", "Z", 4),)
  919. class EnumTrackAxis(NodeSocket):
  920. '''Custom node socket type'''
  921. bl_idname = 'EnumTrackAxis'
  922. bl_label = "Track Axis"
  923. default_value: bpy.props.EnumProperty(
  924. items=eTrackAxis,
  925. name="Track Axis",
  926. description="Track Axis",
  927. default = 'TRACK_X',
  928. #options = {'ENUM_FLAG'},
  929. update = update_socket,)
  930. color = cString
  931. input : bpy.props.BoolProperty(default =False,)
  932. def draw(self, context, layout, node, text):
  933. ChooseDraw(self, context, layout, node, text)
  934. def draw_color(self, context, node):
  935. return self.color
  936. class EnumUpAxis(NodeSocket):
  937. '''Custom node socket type'''
  938. bl_idname = 'EnumUpAxis'
  939. bl_label = "Up Axis"
  940. default_value: bpy.props.EnumProperty(
  941. items=eUpAxis,
  942. name="Up Axis",
  943. description="Up Axis",
  944. default = 'UP_X',
  945. #options = {'ENUM_FLAG'},
  946. update = update_socket,)
  947. color = cString
  948. input : bpy.props.BoolProperty(default =False,)
  949. def draw(self, context, layout, node, text):
  950. ChooseDraw(self, context, layout, node, text)
  951. def draw_color(self, context, node):
  952. return self.color
  953. # Locked Track
  954. eLockAxis = (('LOCK_X', "X", "X", 1),
  955. ('LOCK_Y', "Y", "Y", 2),
  956. ('LOCK_Z', "Z", "Z", 4),)
  957. class EnumLockAxis(NodeSocket):
  958. '''Custom node socket type'''
  959. bl_idname = 'EnumLockAxis'
  960. bl_label = "Lock Axis"
  961. default_value: bpy.props.EnumProperty(
  962. items=eLockAxis,
  963. name="Lock Axis",
  964. description="Lock Axis",
  965. default = 'LOCK_X',
  966. #options = {'ENUM_FLAG'},
  967. update = update_socket,)
  968. color = cString
  969. input : bpy.props.BoolProperty(default =False,)
  970. def draw(self, context, layout, node, text):
  971. ChooseDraw(self, context, layout, node, text)
  972. def draw_color(self, context, node):
  973. return self.color
  974. # Limit Distance:
  975. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  976. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  977. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  978. class EnumLimitMode(NodeSocket):
  979. '''Custom node socket type'''
  980. bl_idname = 'EnumLimitMode'
  981. bl_label = "Clamp Region"
  982. default_value: bpy.props.EnumProperty(
  983. items=eLimitMode,
  984. name="Clamp Region",
  985. description="Clamp Region",
  986. default = 'LIMITDIST_INSIDE',
  987. update = update_socket,)
  988. color = cString
  989. input : bpy.props.BoolProperty(default =False,)
  990. def draw(self, context, layout, node, text):
  991. ChooseDraw(self, context, layout, node, text)
  992. def draw_color(self, context, node):
  993. return self.color
  994. # Spline IK
  995. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  996. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  997. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  998. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  999. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1000. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1001. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1002. class EnumYScaleMode(NodeSocket):
  1003. '''Custom node socket type'''
  1004. bl_idname = 'EnumYScaleMode'
  1005. bl_label = "Y Scale Mode"
  1006. default_value: bpy.props.EnumProperty(
  1007. items=eYScaleMode,
  1008. name="Y Scale Mode",
  1009. description="Y Scale Mode",
  1010. default = 'FIT_CURVE',
  1011. update = update_socket,)
  1012. color = cString
  1013. input : bpy.props.BoolProperty(default =False,)
  1014. def draw(self, context, layout, node, text):
  1015. ChooseDraw(self, context, layout, node, text)
  1016. def draw_color(self, context, node):
  1017. return self.color
  1018. class EnumXZScaleMode(NodeSocket):
  1019. '''Custom node socket type'''
  1020. bl_idname = 'EnumXZScaleMode'
  1021. bl_label = "Y Scale Mode"
  1022. default_value: bpy.props.EnumProperty(
  1023. items=eXZScaleMode,
  1024. name="XZ Scale Mode",
  1025. description="XZ Scale Mode",
  1026. default = 'NONE',
  1027. update = update_socket,)
  1028. color = cString
  1029. input : bpy.props.BoolProperty(default =False,)
  1030. def draw(self, context, layout, node, text):
  1031. ChooseDraw(self, context, layout, node, text)
  1032. def draw_color(self, context, node):
  1033. return self.color
  1034. eMapxForm = (('LOCATION', "Location", "Location",),
  1035. ('ROTATION', "Rotation", "Rotation",),
  1036. ('SCALE', "Scale", "Scale",),)
  1037. eRotationMode = (('AUTO', 'Auto', 'Euler using the rotation order of the target.', 0),
  1038. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1039. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1040. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1041. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1042. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1043. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1044. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1045. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1046. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1047. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1048. enumTransformationRotationOrder = enumRotationOrder[:6]
  1049. eTranslationMix =(
  1050. ('ADD', "Add", "", 0),
  1051. ('REPLACE', "Replace", "", 1),
  1052. )
  1053. eScaleMix =(
  1054. ('MULTIPLY', "Multiply", "", 0),
  1055. ('REPLACE', "Replace", "", 1),
  1056. )
  1057. class EnumTransformationMap(NodeSocket):
  1058. '''Custom node socket type'''
  1059. bl_idname = 'EnumTransformationMap'
  1060. bl_label = "Map"
  1061. default_value: bpy.props.EnumProperty(
  1062. items=eMapxForm,
  1063. name="Map To/From",
  1064. description="Map To/From",
  1065. default = 'LOCATION',
  1066. update = update_socket,)
  1067. color = cString
  1068. input : bpy.props.BoolProperty(default =False,)
  1069. def draw(self, context, layout, node, text):
  1070. ChooseDraw(self, context, layout, node, text)
  1071. def draw_color(self, context, node):
  1072. return self.color
  1073. class EnumTransformationRotationMode(NodeSocket):
  1074. '''Custom node socket type'''
  1075. bl_idname = 'EnumTransformationRotationMode'
  1076. bl_label = "Map"
  1077. default_value: bpy.props.EnumProperty(
  1078. items=eRotationMode,
  1079. name="Rotation Mode",
  1080. description="Rotation Mode",
  1081. default = 'AUTO',
  1082. update = update_socket,)
  1083. color = cString
  1084. input : bpy.props.BoolProperty(default =False,)
  1085. def draw(self, context, layout, node, text):
  1086. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1087. def draw_color(self, context, node):
  1088. return self.color
  1089. class EnumTransformationRotationOrder(NodeSocket):
  1090. '''Custom node socket type'''
  1091. bl_idname = 'EnumTransformationRotationOrder'
  1092. bl_label = "Map"
  1093. default_value: bpy.props.EnumProperty(
  1094. items=enumTransformationRotationOrder,
  1095. name="Rotation Order",
  1096. description="Rotation Order",
  1097. default = 'AUTO',
  1098. update = update_socket,)
  1099. color = cString
  1100. input : bpy.props.BoolProperty(default =False,)
  1101. def draw(self, context, layout, node, text):
  1102. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1103. def draw_color(self, context, node):
  1104. return self.color
  1105. class EnumTransformationTranslationMixMode(NodeSocket):
  1106. '''Custom node socket type'''
  1107. bl_idname = 'EnumTransformationTranslationMixMode'
  1108. bl_label = "Map"
  1109. default_value: bpy.props.EnumProperty(
  1110. items=eTranslationMix,
  1111. name="Mix Translation",
  1112. description="Mix Translation",
  1113. default = 'ADD',
  1114. update = update_socket,)
  1115. color = cString
  1116. input : bpy.props.BoolProperty(default =False,)
  1117. def draw(self, context, layout, node, text):
  1118. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1119. def draw_color(self, context, node):
  1120. return self.color
  1121. class EnumTransformationRotationMixMode(NodeSocket):
  1122. '''Custom node socket type'''
  1123. bl_idname = 'EnumTransformationRotationMixMode'
  1124. bl_label = "Map"
  1125. default_value: bpy.props.EnumProperty(
  1126. items=eRotationMix,
  1127. name="Mix Rotation",
  1128. description="Mix Rotation",
  1129. default = 'ADD',
  1130. update = update_socket,)
  1131. color = cString
  1132. input : bpy.props.BoolProperty(default =False,)
  1133. def draw(self, context, layout, node, text):
  1134. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1135. def draw_color(self, context, node):
  1136. return self.color
  1137. class EnumTransformationScaleMixMode(NodeSocket):
  1138. '''Custom node socket type'''
  1139. bl_idname = 'EnumTransformationScaleMixMode'
  1140. bl_label = "Map"
  1141. default_value: bpy.props.EnumProperty(
  1142. items=eScaleMix,
  1143. name="Mix Scale",
  1144. description="Mix Scale",
  1145. default = 'REPLACE',
  1146. update = update_socket,)
  1147. color = cString
  1148. input : bpy.props.BoolProperty(default =False,)
  1149. def draw(self, context, layout, node, text):
  1150. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1151. def draw_color(self, context, node):
  1152. return self.color
  1153. eAxes = (
  1154. ('X', "X", "X", 0),
  1155. ('Y', "Y", "Y", 1),
  1156. ('Z', "Z", "Z", 1),
  1157. )
  1158. class EnumTransformationAxes(NodeSocket):
  1159. '''Custom node socket type'''
  1160. bl_idname = 'EnumTransformationAxes'
  1161. bl_label = "Map"
  1162. default_value: bpy.props.EnumProperty(
  1163. items=eAxes,
  1164. # name="",
  1165. # description="",
  1166. default = 'X',
  1167. update = update_socket,)
  1168. color = cString
  1169. input : bpy.props.BoolProperty(default =False,)
  1170. def draw(self, context, layout, node, text):
  1171. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1172. def draw_color(self, context, node):
  1173. return self.color
  1174. #
  1175. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  1176. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),)
  1177. class EnumSkinning(NodeSocket):
  1178. '''Custom node socket type'''
  1179. bl_idname = 'EnumSkinning'
  1180. bl_label = "Skinning Method"
  1181. default_value: bpy.props.EnumProperty(
  1182. items=eSkinningMethod,
  1183. name="Skinning Method",
  1184. description="Skinning Method",
  1185. default = 'AUTOMATIC_HEAT',
  1186. update = update_socket,)
  1187. color = cString
  1188. input : bpy.props.BoolProperty(default =False,)
  1189. def draw(self, context, layout, node, text):
  1190. ChooseDraw(self, context, layout, node, text)
  1191. def draw_color(self, context, node):
  1192. return self.color
  1193. eDriverVariableType = (
  1194. ( 'SINGLE_PROP',
  1195. "Property",
  1196. "Property",
  1197. 1),
  1198. ( 'LOC_DIFF',
  1199. "Distance",
  1200. "Distance",
  1201. 2),
  1202. ( 'ROTATION_DIFF',
  1203. "Rotational Difference",
  1204. "Rotational Difference",
  1205. 3),
  1206. # TRANSFORMS
  1207. )
  1208. class EnumDriverVariableType(NodeSocket):
  1209. '''Custom node socket type'''
  1210. bl_idname = 'EnumDriverVariableType'
  1211. bl_label = "Variable Type"
  1212. default_value: bpy.props.EnumProperty(
  1213. items = eDriverVariableType,
  1214. name = "Variable Type",
  1215. description = "Variable Type",
  1216. default = 'SINGLE_PROP',
  1217. update = driver_variable_socket_update,)
  1218. color = cString
  1219. input : bpy.props.BoolProperty(default =False,)
  1220. def draw(self, context, layout, node, text):
  1221. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1222. def draw_color(self, context, node):
  1223. return self.color
  1224. eDriverVariableEvaluationSpace = (
  1225. ( 'WORLD_SPACE',
  1226. "World",
  1227. "World",
  1228. 1),
  1229. ( 'TRANSFORM_SPACE',
  1230. "Transform",
  1231. "Transform",
  1232. 2),
  1233. ( 'LOCAL_SPACE',
  1234. "Local",
  1235. "Local",
  1236. 3),
  1237. )
  1238. class EnumDriverVariableEvaluationSpace(NodeSocket):
  1239. '''Custom node socket type'''
  1240. bl_idname = 'EnumDriverVariableEvaluationSpace'
  1241. bl_label = "Evaluation Space"
  1242. default_value: bpy.props.EnumProperty(
  1243. items = eDriverVariableEvaluationSpace,
  1244. name = "Evaluation Space",
  1245. description = "Evaluation Space",
  1246. default = 'WORLD_SPACE',
  1247. update = driver_variable_socket_update,)
  1248. color = cString
  1249. input : bpy.props.BoolProperty(default =False,)
  1250. def draw(self, context, layout, node, text):
  1251. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1252. def draw_color(self, context, node):
  1253. return self.color
  1254. class EnumDriverRotationMode(NodeSocket):
  1255. '''Custom node socket type'''
  1256. bl_idname = 'EnumDriverRotationMode'
  1257. bl_label = "Rotaton Mode"
  1258. default_value: bpy.props.EnumProperty(
  1259. items = eRotationMode,
  1260. name = "Rotation Mode",
  1261. description = "Rotation Mode",
  1262. default = 'AUTO',
  1263. update = driver_variable_socket_update,)
  1264. color = cString
  1265. input : bpy.props.BoolProperty(default =False,)
  1266. def draw(self, context, layout, node, text):
  1267. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1268. def draw_color(self, context, node):
  1269. return self.color
  1270. #
  1271. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  1272. ('SUM', "Sum", "Sum", 1),
  1273. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  1274. ('MIN', "Min", "Minimum", 3),
  1275. ('MAX', "Max", "Maximum", 4),)
  1276. class EnumDriverType(NodeSocket):
  1277. '''Custom node socket type'''
  1278. bl_idname = 'EnumDriverType'
  1279. bl_label = "Driver Type"
  1280. default_value: bpy.props.EnumProperty(
  1281. items = eDriverType,
  1282. name = "Driver Type",
  1283. description = "Driver Type",
  1284. default = 'AVERAGE',
  1285. update = driver_socket_update,)
  1286. color = cString
  1287. input : bpy.props.BoolProperty(default =False,)
  1288. def draw(self, context, layout, node, text):
  1289. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1290. def draw_color(self, context, node):
  1291. return self.color
  1292. # Keyframe
  1293. # Enum for kf handle type
  1294. # enum for interpolation type
  1295. # eventually gonna make it to the fancy stuff
  1296. class FloatSocket(bpy.types.NodeSocketFloat):
  1297. """Float Input socket"""
  1298. bl_idname = 'FloatSocket'
  1299. bl_label = "Float"
  1300. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1301. color = cFloat
  1302. input : bpy.props.BoolProperty(default =False,)
  1303. def draw(self, context, layout, node, text):
  1304. ChooseDraw(self, context, layout, node, text)
  1305. def draw_color(self, context, node):
  1306. return self.color
  1307. class FloatPositiveSocket(bpy.types.NodeSocketFloat):
  1308. """Float Input socket"""
  1309. bl_idname = 'FloatPositiveSocket'
  1310. bl_label = "Float"
  1311. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  1312. color = cFloat
  1313. input : bpy.props.BoolProperty(default =False,)
  1314. def draw(self, context, layout, node, text):
  1315. ChooseDraw(self, context, layout, node, text)
  1316. def draw_color(self, context, node):
  1317. return self.color
  1318. class FloatFactorSocket(bpy.types.NodeSocketFloatFactor):
  1319. '''xFrom Input Output'''
  1320. bl_idname = 'FloatFactorSocket'
  1321. bl_label = "xForm"
  1322. default_value : bpy.props.FloatProperty(
  1323. default = 0.0,
  1324. min = 0.0,
  1325. max=1.0,
  1326. update = update_socket,
  1327. subtype='FACTOR',)
  1328. color = cFloat
  1329. input : bpy.props.BoolProperty(default =False,)
  1330. def draw(self, context, layout, node, text):
  1331. ChooseDraw(self, context, layout, node, text)
  1332. def draw_color(self, context, node):
  1333. return self.color
  1334. class FloatAngleSocket(bpy.types.NodeSocketFloatAngle):
  1335. '''xFrom Input Output'''
  1336. bl_idname = 'FloatAngleSocket'
  1337. bl_label = "xForm"
  1338. default_value : bpy.props.FloatProperty(
  1339. default = 0.0,
  1340. min = -180,
  1341. max=180,
  1342. update = update_socket,
  1343. subtype='ANGLE',)
  1344. color = cFloat
  1345. input : bpy.props.BoolProperty(default =False,)
  1346. def draw(self, context, layout, node, text):
  1347. ChooseDraw(self, context, layout, node, text)
  1348. def draw_color(self, context, node):
  1349. return self.color
  1350. class VectorSocket(bpy.types.NodeSocketVectorEuler):
  1351. """Vector Input socket"""
  1352. bl_idname = 'VectorSocket'
  1353. bl_label = "Float"
  1354. default_value : bpy.props.FloatVectorProperty(
  1355. default = (0.0, 0.0, 0.0),
  1356. update = update_socket,)
  1357. color = cVector
  1358. input : bpy.props.BoolProperty(default =False,)
  1359. def draw(self, context, layout, node, text):
  1360. ChooseDraw(self, context, layout, node, text)
  1361. def draw_color(self, context, node):
  1362. return self.color
  1363. class VectorEulerSocket(bpy.types.NodeSocketVectorEuler):
  1364. """Vector Input socket"""
  1365. bl_idname = 'VectorEulerSocket'
  1366. bl_label = "Float"
  1367. default_value : bpy.props.FloatVectorProperty(
  1368. default = (0.0, 0.0, 0.0),
  1369. update = update_socket,
  1370. subtype='EULER',)
  1371. color = cVector
  1372. input : bpy.props.BoolProperty(default =False,)
  1373. def draw(self, context, layout, node, text):
  1374. ChooseDraw(self, context, layout, node, text)
  1375. def draw_color(self, context, node):
  1376. return self.color
  1377. class VectorTranslationSocket(bpy.types.NodeSocketVectorTranslation):
  1378. """Vector Input socket"""
  1379. bl_idname = 'VectorTranslationSocket'
  1380. bl_label = "Float"
  1381. default_value : bpy.props.FloatVectorProperty(
  1382. default = (0.0, 0.0, 0.0),
  1383. update = update_socket,
  1384. subtype='TRANSLATION',)
  1385. color = cVector
  1386. input : bpy.props.BoolProperty(default =False,)
  1387. def draw(self, context, layout, node, text):
  1388. ChooseDraw(self, context, layout, node, text)
  1389. def draw_color(self, context, node):
  1390. return self.color
  1391. class VectorScaleSocket(bpy.types.NodeSocketVectorXYZ):
  1392. """Vector Input socket"""
  1393. bl_idname = 'VectorScaleSocket'
  1394. bl_label = "Float"
  1395. default_value : bpy.props.FloatVectorProperty(
  1396. default = (1.0, 1.0, 1.0),
  1397. update = update_socket,
  1398. subtype='XYZ',)
  1399. color = cVector
  1400. input : bpy.props.BoolProperty(default =False,)
  1401. def draw(self, context, layout, node, text):
  1402. ChooseDraw(self, context, layout, node, text)
  1403. def draw_color(self, context, node):
  1404. return self.color