socket_definitions.py 58 KB

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