socket_definitions.py 58 KB

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