socket_definitions.py 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452
  1. import bpy
  2. from bpy.types import NodeSocket, NodeSocketStandard
  3. # Classes which do not have default_value
  4. # needed to detect when there is an error updating dynamic nodes
  5. no_default_value= [
  6. 'MantisSocket',
  7. 'RelationshipSocket',
  8. 'DeformerSocket',
  9. 'xFormSocket',
  10. 'GeometrySocket',
  11. 'GenericRotationSocket',
  12. 'FCurveSocket',
  13. 'DriverSocket',
  14. 'DriverVariableSocket',
  15. 'xFormParameterSocket',
  16. 'MorphTargetSocket',
  17. 'KeyframeSocket',
  18. 'WildcardSocket',
  19. ]
  20. # the sockets that do not have this field do not transfer data.
  21. # instead, it is the link itself which is meaningful.
  22. class MantisSocket(NodeSocket):
  23. is_valid_interface_type=False
  24. from .utilities import (prRed, prGreen, prPurple, prWhite,
  25. prOrange,
  26. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  27. wrapOrange,)
  28. transform_spaces_bone_to = (('WORLD', "World", "World Space"),
  29. ('LOCAL', "Local", "Local Space"),
  30. ('POSE', "Pose", "Pose Space"),
  31. ('CUSTOM', "Custom", "Custom Space"),
  32. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),
  33. ('LOCAL_OWNER_ORIENT', "Local (Owner Orientation)", "Local Space"),)
  34. transform_spaces_bone_from = (('WORLD', "World", "World Space"),
  35. ('LOCAL', "Local", "Local Space"),
  36. ('POSE', "Pose", "Pose Space"),
  37. ('CUSTOM', "Custom", "Custom Space"),
  38. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),)
  39. transform_spaces_bone_object = (('WORLD', "World", "World Space"),
  40. ('LOCAL', "Local", "Local Space"),
  41. ('POSE', "Pose", "Pose Space"),
  42. ('CUSTOM', "Custom", "Custom Space"),)
  43. transform_spaces_object = (('WORLD', "World", "World Space"),
  44. ('LOCAL', "Local", "Local Space"),
  45. ('CUSTOM', "Custom", "Custom Space"),)
  46. enumRotationOrder =(('AUTO', 'Auto', 'Auto'),
  47. ('XYZ', "XYZ", "XYZ"),
  48. ('XZY', "XZY", "XZY"),
  49. ('ZXY', "ZXY", "ZXY"),
  50. ('ZYX', "ZYX", "ZYX"),
  51. ('YXZ', "YXZ", "YXZ"),
  52. ('YZX', "YZX", "YZX"),
  53. ('QUATERNION', "Quaternion", "Quaternion"),
  54. ('AXIS_ANGLE', "Axis Angle", "Axis Angle"),)
  55. # node socket colors:
  56. cFloat = (0.631373, 0.631373, 0.631373, 1.000000)
  57. cColor = (0.780392, 0.780392, 0.160784, 1.000000)
  58. cVector = (0.388235, 0.388235, 0.780392, 1.000000)
  59. cShader = (0.388235, 0.780392, 0.388235, 1.000000)
  60. cInt = (0.058824, 0.521569, 0.149020, 1.000000)
  61. cString = (0.388235, 0.388235, 0.388235, 1.000000)
  62. # cBool = (0.698039, 0.650980, 0.188235, 1.000000)
  63. cParameter = (0.48, 0.24, 0.24, 1.0)
  64. cDriver = (0.88, 0.11, 0.88, 1.0)
  65. cDriverVariable = (0.66, 0.33, 0.04, 1.0)
  66. cFCurve = (0.77, 0.77, 0.11, 1.0)
  67. cKeyframe = (0.06, 0.22, 0.88, 1.0)
  68. cEnable = (0.92, 0.92, 0.92, 1.0)
  69. cBoneCollection = (0.82, 0.82, 0.82, 1.0)
  70. cDeformer = (0.05, 0.08, 0.45, 1.0)
  71. cShapeKey = (0.95, 0.32, 0.05, 1.0)
  72. # custom colors:
  73. cIK = (0.596078, 0.596078, 0.364706, 1.000000) #because it's yellow in Blender
  74. cRelationship = (0.352941, 0.584314, 0.431373, 1.000000) #constraint color
  75. cMatrix = (0.0, 1.0, 0.75, 1)
  76. cxForm = (0.843137, 0.592157, 0.388235, 1.000000) #could even fetch the theme colors...
  77. cTransformSpace = (1.0, 0.4, 0.216, 1.0)
  78. cBool = (0.1, 0.1, 0.1, 1.0)
  79. cBool3 = (0.35, 0.25, 0.18, 1.0)
  80. cRotationOrder = (0.0, 0.8, 0.0, 1.0)
  81. cQuaternion = (0.85, 0.25, 0.18, 1.0)
  82. #
  83. cGeometry = (0.000000, 0.672443, 0.366253, 1.000000)
  84. # think about making colors that are representative of the data's purpose:
  85. # location
  86. # rotation
  87. # scale
  88. # OR make all of it a reference to the type of data within?
  89. # Hybrid approach: Make same-data, similar purpose have similar colors.
  90. from typing import List
  91. def TellClasses() -> List[MantisSocket]:
  92. return [ #MantisSocket,
  93. #DefaultSocket,
  94. #InputSocket,
  95. MatrixSocket,
  96. xFormSocket,
  97. RelationshipSocket,
  98. DeformerSocket,
  99. GeometrySocket,
  100. GenericRotationSocket,
  101. EnableSocket,
  102. HideSocket,
  103. # InverseKinematicsSocket,
  104. DriverSocket,
  105. DriverVariableSocket,
  106. FCurveSocket,
  107. # LayerMaskSocket,
  108. # LayerMaskInputSocket,
  109. BoneCollectionSocket,
  110. EnumArrayGetOptions,
  111. xFormParameterSocket,
  112. ParameterBoolSocket,
  113. ParameterIntSocket,
  114. ParameterFloatSocket,
  115. ParameterVectorSocket,
  116. ParameterStringSocket,
  117. TransformSpaceSocket,
  118. BooleanSocket,
  119. BooleanThreeTupleSocket,
  120. RotationOrderSocket,
  121. QuaternionSocket,
  122. QuaternionSocketAA,
  123. UnsignedIntSocket,
  124. IntSocket,
  125. StringSocket,
  126. EnumMetaRigSocket,
  127. EnumMetaBoneSocket,
  128. EnumCurveSocket,
  129. BoolUpdateParentNode,
  130. # LabelSocket,
  131. IKChainLengthSocket,
  132. EnumInheritScale,
  133. EnumRotationMix,
  134. EnumRotationMixCopyTransforms,
  135. EnumMaintainVolumeStretchTo,
  136. EnumRotationStretchTo,
  137. EnumTrackAxis,
  138. EnumUpAxis,
  139. EnumFollowPathForwardAxis,
  140. EnumLockAxis,
  141. EnumLimitMode,
  142. EnumYScaleMode,
  143. EnumXZScaleMode,
  144. EnumTransformationMap,
  145. EnumTransformationRotationMode,
  146. EnumTransformationRotationOrder,
  147. EnumTransformationTranslationMixMode,
  148. EnumTransformationRotationMixMode,
  149. EnumTransformationScaleMixMode,
  150. EnumTransformationAxes,
  151. EnumBBoneHandleType,
  152. # Deformers
  153. EnumSkinning,
  154. MorphTargetSocket,
  155. #
  156. FloatSocket,
  157. FloatPositiveSocket,
  158. FloatFactorSocket,
  159. FloatAngleSocket,
  160. VectorSocket,
  161. VectorEulerSocket,
  162. VectorTranslationSocket,
  163. VectorScaleSocket,
  164. # Drivers
  165. EnumDriverVariableType,
  166. EnumDriverVariableEvaluationSpace,
  167. EnumDriverVariableTransformChannel,
  168. EnumDriverRotationMode,
  169. EnumDriverType,
  170. KeyframeSocket,
  171. EnumKeyframeInterpolationTypeSocket,
  172. EnumKeyframeBezierHandleTypeSocket,
  173. eFCrvExtrapolationMode,
  174. # Math
  175. MathFloatOperation,
  176. MathVectorOperation,
  177. MatrixTransformOperation,
  178. #conditions
  179. EnumCompareOperation,
  180. # Schema
  181. WildcardSocket,
  182. # xFormArraySocket,
  183. # RelationshipArraySocket,
  184. # BooleanArraySocket,
  185. # IntArraySocket,
  186. # FloatArraySocket,
  187. # BooleanThreeTupleArraySocket,
  188. # VectorArraySocket,
  189. # QuaternionArraySocket,
  190. # MatrixArraySocket,
  191. # StringArraySocket,
  192. ]
  193. def Tell_bl_idnames(): # reroute nodes
  194. return [cls.bl_idname for cls in TellClasses()]#+["NodeSocketColor"]
  195. def tell_valid_bl_idnames():
  196. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  197. return (cls.bl_idname for cls in valid_classes)
  198. # Was setting color like this:
  199. # color : bpy.props.FloatVectorProperty(size = 4, default = cFCurve,)
  200. # but this didn't work when Blender automatically generated interface classes?
  201. # so changed it to color = cVariable
  202. # but for color-changing sockets, if I make them, this won' work? Maybe?
  203. #
  204. # I actually think I was wrong about all of that lol
  205. # TODO change it back, dingus
  206. ########################################################################
  207. # Update Callbacks
  208. ########################################################################
  209. def default_update(socket, context, do_execute=True):
  210. # return
  211. context = bpy.context
  212. if not context.space_data:
  213. return
  214. if not hasattr(context.space_data, "path"):
  215. return
  216. try:
  217. node_tree = context.space_data.path[0].node_tree
  218. except IndexError: # not in the UI, for example, in a script instead.
  219. node_tree = None
  220. return
  221. if hasattr(socket.node, "initialized"):
  222. if not socket.node.initialized: return
  223. else: return
  224. if node_tree.do_live_update and not (node_tree.is_executing or node_tree.is_exporting):
  225. # I don't know how the tree can be valid at 0 nodes but doesn't hurt
  226. # to force it if this somehow happens.
  227. if ((node_tree.tree_valid == False or len(node_tree.parsed_tree) == 0)
  228. or socket.node.bl_idname in ["MantisNodeGroup"]):
  229. # prGreen("Forcing Update From Socket Change.")
  230. node_tree.update_tree(context)
  231. elif (node_tree.tree_valid == True):
  232. # prGreen("Partial Update From Socket Change.")
  233. # We don't have to update the whole thing, just the socket
  234. from .utilities import tree_from_nc
  235. for nc in node_tree.parsed_tree.values():
  236. try:
  237. if (tree_from_nc(nc.signature, nc.base_tree) == socket.node.id_data):
  238. if socket.node.name in nc.signature:
  239. getstring = socket.name
  240. if (getstring not in nc.parameters.keys()):
  241. prRed("Socket update failed for %s" % socket.name)
  242. else:
  243. nc.parameters[getstring] = socket.default_value
  244. except AttributeError as e:
  245. prWhite(nc)
  246. prWhite(nc.inputs)
  247. raise e
  248. # Now update the tree display:
  249. node_tree.display_update(context)
  250. try:
  251. prPurple("calling Execute Tree from socket update")
  252. node_tree.execute_tree(context)
  253. except Exception as e:
  254. prRed("Automatic Tree Execution failed because of %s" % e)
  255. # I don't want to deal with this right now TODO
  256. # e.__traceback__.print_last() this isn't the same kind of traceback object as the traceback module
  257. # socket.node.is_triggering_execute = True
  258. def update_socket(self, context,):
  259. default_update(self,context)
  260. def update_mute_socket(self, context):
  261. self.node.mute = not self.default_value
  262. default_update(self,context)
  263. def update_hide_socket(self, context):
  264. self.node.mute = self.default_value
  265. default_update(self,context)
  266. def update_parent_node(self, context):
  267. default_update(self,context)
  268. if hasattr(self.node, "display_update"):
  269. self.node.display_update(context)
  270. def ik_chain_length_update_socket(self, context):
  271. default_update(self,context)
  272. # self.node.update_chain_length(context)
  273. # TODO: this is stupid. I don't know what I was trying to do when i made this
  274. # Driver Variable:
  275. def driver_variable_socket_update(self, context):
  276. default_update(self,context)
  277. # self.node.update_on_socket_change(context) # why?
  278. def driver_socket_update(self, context):
  279. default_update(self,context)
  280. # self.node.update_on_socket_change(context) # same here, no idea
  281. def update_metarig_armature(self, context,):
  282. if self.search_prop:
  283. self.node.armature = self.search_prop.name
  284. self.node.inputs["Meta-Bone"].search_prop = self.search_prop
  285. default_update(self,context)
  286. def update_metarig_posebone(self, context,):
  287. self.node.pose_bone = self.default_value
  288. default_update(self,context)
  289. ########################################################################
  290. # Sockets
  291. ########################################################################
  292. def ChooseDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  293. # return
  294. # TEXT ONLY
  295. if self.node.bl_idname in ["NodeGroupInput", "NodeGroupOutput"]:
  296. layout.label(text=text)
  297. elif hasattr(self, "display_text") and self.display_text and self.is_linked:
  298. layout.label(text=self.display_text)
  299. else:
  300. # ENUM VALUES (this is a HACK, fix it later)
  301. if ('Enum' in self.bl_idname) and (use_enum):
  302. if not (self.is_output or self.is_linked):
  303. layout.prop_tabs_enum(self, "default_value",)
  304. else:
  305. layout.label(text=text)
  306. # for OUTPUT sockets that take INPUT (confusing name!)
  307. elif ((hasattr(self, "default_value")) and hasattr(self, "input") and getattr(self, "input")):
  308. # for simple input nodes
  309. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True)
  310. # for INPUTS that are NOT CONNECTED
  311. elif (hasattr(self, "default_value")) and not (self.is_output or self.is_linked):
  312. # DO: expose these values as parameters for this function
  313. # and set them for each socket.
  314. if icon == 'NONE': icon_only = False
  315. elif icon_only == True : text = "" # "real" icon-only looks bad for strings, need to check other props types.
  316. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True, icon=icon,)
  317. # CONNECTED sockets and outputs without input fields
  318. else:
  319. layout.label(text=text)
  320. class RelationshipSocket(MantisSocket):
  321. # Description string
  322. '''Relationship'''
  323. # Optional identifier string. If not explicitly defined, the python class name is used.
  324. bl_idname = 'RelationshipSocket'
  325. bl_label = "Relationship"
  326. color_simple = cRelationship
  327. color : bpy.props.FloatVectorProperty(default=cRelationship, size=4)
  328. input : bpy.props.BoolProperty(default =False,)
  329. is_valid_interface_type=True
  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. @classmethod
  335. def draw_color_simple(self):
  336. return self.color_simple
  337. class DeformerSocket(MantisSocket):
  338. # Description string
  339. '''Deformer'''
  340. # Optional identifier string. If not explicitly defined, the python class name is used.
  341. bl_idname = 'DeformerSocket'
  342. bl_label = "Deformer"
  343. is_valid_interface_type=True
  344. color_simple = cDeformer
  345. color : bpy.props.FloatVectorProperty(default=cDeformer, size=4)
  346. input : bpy.props.BoolProperty(default =False,)
  347. def draw(self, context, layout, node, text):
  348. ChooseDraw(self, context, layout, node, text)
  349. def draw_color(self, context, node):
  350. return self.color
  351. @classmethod
  352. def draw_color_simple(self):
  353. return self.color_simple
  354. class MatrixSocket(MantisSocket):
  355. '''Matrix Input Output'''
  356. bl_idname = 'MatrixSocket'
  357. bl_label = "Matrix"
  358. default_value : bpy.props.FloatVectorProperty(
  359. default = (1.0, 0.0, 0.0, 0.0,
  360. 0.0, 1.0, 0.0, 0.0,
  361. 0.0, 0.0, 1.0, 0.0,
  362. 0.0, 0.0, 0.0, 1.0),
  363. size=16,
  364. update = update_socket,)
  365. color_simple = cMatrix
  366. color : bpy.props.FloatVectorProperty(default=cMatrix, size=4)
  367. input : bpy.props.BoolProperty(default =False,)
  368. is_valid_interface_type=True
  369. # Optional function for drawing the socket input value
  370. def draw(self, context, layout, node, text):
  371. layout.label(text=text)
  372. def draw_color(self, context, node):
  373. return self.color
  374. @classmethod
  375. def draw_color_simple(self):
  376. return self.color_simple
  377. # Utility functions to make handling the 16 numbers more bearable
  378. def SetValue(self, mat):
  379. self.default_value = ( mat[0][0], mat[0][1], mat[0][2], mat[0][3],
  380. mat[1][0], mat[1][1], mat[1][2], mat[1][3],
  381. mat[2][0], mat[2][1], mat[2][2], mat[2][3],
  382. mat[3][0], mat[3][1], mat[3][2], mat[3][3], )
  383. def TellValue(self):
  384. from mathutils import Matrix
  385. v = self.default_value
  386. return Matrix( ( ( v[ 0], v[ 1], v[ 2], v[ 3],),
  387. ( v[ 4], v[ 5], v[ 6], v[ 7],),
  388. ( v[ 8], v[ 9], v[10], v[11],),
  389. ( v[12], v[13], v[14], v[15]), ) )
  390. #NOTE, we're not using the last row
  391. # so we're gonna use it to store data
  392. # unused, unused, unused, bone_length
  393. # but we're not going to make it
  394. # available except by accessor functions
  395. # would like to make this stuff easier to deal with tho
  396. def TellBoneLength(self):
  397. return self.default_value[15]
  398. class xFormSocket(MantisSocket):
  399. '''xFrom Input Output'''
  400. bl_idname = 'xFormSocket'
  401. bl_label = "xForm"
  402. color_simple = cxForm
  403. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  404. input : bpy.props.BoolProperty(default =False,)
  405. is_valid_interface_type=True
  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. @classmethod
  411. def draw_color_simple(self):
  412. return self.color_simple
  413. class GeometrySocket(MantisSocket):
  414. '''Geometry Input Output'''
  415. bl_idname = 'GeometrySocket'
  416. bl_label = "Geometry"
  417. color_simple = cGeometry
  418. color : bpy.props.FloatVectorProperty(default=cGeometry, size=4)
  419. input : bpy.props.BoolProperty(default =False,)
  420. is_valid_interface_type=True
  421. def draw(self, context, layout, node, text):
  422. ChooseDraw(self, context, layout, node, text)
  423. def draw_color(self, context, node):
  424. return self.color
  425. @classmethod
  426. def draw_color_simple(self):
  427. return self.color_simple
  428. class GenericRotationSocket(MantisSocket):
  429. '''Custom node socket type'''
  430. bl_idname = 'GenericRotationSocket'
  431. bl_label = "Rotation"
  432. color = (0.0,0.0,0.0,0.0)
  433. input : bpy.props.BoolProperty(default =False,)
  434. def draw(self, context, layout, node, text):
  435. ChooseDraw(self, context, layout, node, text)
  436. def draw_color(self, context, node):
  437. return self.color
  438. @classmethod
  439. def draw_color_simple(self):
  440. return self.color_simple
  441. ###############################
  442. class EnableSocket(MantisSocket):
  443. '''Custom node socket type'''
  444. bl_idname = 'EnableSocket'
  445. bl_label = "Enable"
  446. default_value: bpy.props.BoolProperty(default=True, update = update_mute_socket,)
  447. color_simple = cEnable
  448. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  449. input : bpy.props.BoolProperty(default =False,)
  450. def draw(self, context, layout, node, text):
  451. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  452. def draw_color(self, context, node):
  453. return self.color
  454. @classmethod
  455. def draw_color_simple(self):
  456. return self.color_simple
  457. class HideSocket(MantisSocket):
  458. '''Custom node socket type'''
  459. bl_idname = 'HideSocket'
  460. bl_label = "Hide"
  461. default_value: bpy.props.BoolProperty(default=False, update = update_hide_socket,)
  462. color_simple = cEnable
  463. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  464. input : bpy.props.BoolProperty(default =False,)
  465. def draw(self, context, layout, node, text):
  466. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  467. def draw_color(self, context, node):
  468. return self.color
  469. @classmethod
  470. def draw_color_simple(self):
  471. return self.color_simple
  472. class FCurveSocket(MantisSocket):
  473. '''fCurve'''
  474. bl_idname = 'FCurveSocket'
  475. bl_label = "fCurve"
  476. color_simple = cFCurve
  477. color : bpy.props.FloatVectorProperty(default=cFCurve, size=4)
  478. input : bpy.props.BoolProperty(default =False, update = update_socket)
  479. is_valid_interface_type=True
  480. def init(self):
  481. self.display_shape = 'CIRCLE_DOT'
  482. def draw(self, context, layout, node, text):
  483. ChooseDraw(self, context, layout, node, text)
  484. def draw_color(self, context, node):
  485. return self.color
  486. @classmethod
  487. def draw_color_simple(self):
  488. return self.color_simple
  489. class DriverSocket(MantisSocket):
  490. '''Driver'''
  491. bl_idname = 'DriverSocket'
  492. bl_label = "Driver"
  493. color_simple = cDriver
  494. color : bpy.props.FloatVectorProperty(default=cDriver, size=4)
  495. input : bpy.props.BoolProperty(default =False, update = update_socket)
  496. is_valid_interface_type=True
  497. def init(self):
  498. self.display_shape = 'CIRCLE_DOT'
  499. def draw(self, context, layout, node, text):
  500. ChooseDraw(self, context, layout, node, text)
  501. def draw_color(self, context, node):
  502. return self.color
  503. @classmethod
  504. def draw_color_simple(self):
  505. return self.color_simple
  506. class DriverVariableSocket(MantisSocket):
  507. '''Driver'''
  508. bl_idname = 'DriverVariableSocket'
  509. bl_label = "Driver Variable"
  510. color_simple = cDriverVariable
  511. color : bpy.props.FloatVectorProperty(default=cDriverVariable, size=4)
  512. input : bpy.props.BoolProperty(default =False, update = update_socket)
  513. is_valid_interface_type=True
  514. def init(self):
  515. self.display_shape = 'CIRCLE_DOT'
  516. def draw(self, context, layout, node, text):
  517. ChooseDraw(self, context, layout, node, text)
  518. def draw_color(self, context, node):
  519. return self.color
  520. @classmethod
  521. def draw_color_simple(self):
  522. return self.color_simple
  523. # transform_spaces
  524. # transform_spaces_bone_object
  525. # transform_spaces_object
  526. # def get_transform_space_enum(self, context):
  527. # pass
  528. def get_transform_space(self, context):
  529. if "Owner" in self.name:
  530. return transform_spaces_bone_from
  531. else:
  532. return transform_spaces_bone_to
  533. class TransformSpaceSocket(MantisSocket):
  534. '''Custom node socket type'''
  535. bl_idname = 'TransformSpaceSocket'
  536. bl_label = "Transform Space"
  537. default_value: bpy.props.EnumProperty(
  538. name="Space Transform",
  539. description="Space Transform",
  540. items=get_transform_space,
  541. default=0,
  542. update = update_socket,)
  543. color_simple = cTransformSpace
  544. color : bpy.props.FloatVectorProperty(default=cTransformSpace, size=4)
  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. @classmethod
  551. def draw_color_simple(self):
  552. return self.color_simple
  553. class BooleanSocket(MantisSocket):
  554. '''Custom node socket type'''
  555. bl_idname = 'BooleanSocket'
  556. bl_label = "Boolean"
  557. default_value: bpy.props.BoolProperty(update = update_socket,)
  558. color_simple = cBool
  559. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  560. input : bpy.props.BoolProperty(default =False,)
  561. is_valid_interface_type=True
  562. def draw(self, context, layout, node, text):
  563. ChooseDraw(self, context, layout, node, text)
  564. def draw_color(self, context, node):
  565. return self.color
  566. @classmethod
  567. def draw_color_simple(self):
  568. return self.color_simple
  569. class BooleanThreeTupleSocket(MantisSocket):
  570. # Description string
  571. '''Custom node socket type'''
  572. # Optional identifier string. If not explicitly defined, the python class name is used.
  573. bl_idname = 'BooleanThreeTupleSocket'
  574. bl_label = "Boolean Vector"
  575. default_value: bpy.props.BoolVectorProperty(subtype = "XYZ",update = update_socket,)
  576. color_simple = cBool3
  577. color : bpy.props.FloatVectorProperty(default=cBool3, size=4)
  578. input : bpy.props.BoolProperty(default =False,)
  579. is_valid_interface_type=True
  580. def draw(self, context, layout, node, text):
  581. ChooseDraw(self, context, layout, node, text)
  582. def draw_color(self, context, node):
  583. return self.color
  584. @classmethod
  585. def draw_color_simple(self):
  586. return self.color_simple
  587. def TellValue(self):
  588. return (self.default_value[0], self.default_value[1], self.default_value[2])
  589. class RotationOrderSocket(MantisSocket):
  590. '''Custom node socket type'''
  591. bl_idname = 'RotationOrderSocket'
  592. bl_label = "Rotation Order"
  593. default_value: bpy.props.EnumProperty(
  594. name="Rotation Order",
  595. description="Rotation Order",
  596. items=enumRotationOrder,
  597. default='AUTO',
  598. update = update_socket,)
  599. color_simple = cRotationOrder
  600. color : bpy.props.FloatVectorProperty(default=cRotationOrder, size=4)
  601. input : bpy.props.BoolProperty(default =False,)
  602. def draw(self, context, layout, node, text):
  603. ChooseDraw(self, context, layout, node, text)
  604. def draw_color(self, context, node):
  605. return self.color
  606. @classmethod
  607. def draw_color_simple(self):
  608. return self.color_simple
  609. class QuaternionSocket(MantisSocket):
  610. '''Custom node socket type'''
  611. bl_idname = 'QuaternionSocket'
  612. bl_label = "Quaternion"
  613. default_value: bpy.props.FloatVectorProperty(
  614. subtype = "QUATERNION",
  615. size = 4,
  616. default = (1.0, 0.0, 0.0, 0.0,),
  617. update = update_socket,)
  618. color_simple = cQuaternion
  619. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  620. input : bpy.props.BoolProperty(default =False,)
  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. @classmethod
  626. def draw_color_simple(self):
  627. return self.color_simple
  628. class QuaternionSocketAA(MantisSocket):
  629. '''Custom node socket type'''
  630. bl_idname = 'QuaternionSocketAA'
  631. bl_label = "Axis Angle Quaternion"
  632. color_simple = cQuaternion
  633. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  634. input : bpy.props.BoolProperty(default =False,)
  635. default_value: bpy.props.FloatVectorProperty(
  636. subtype = "AXISANGLE",
  637. size = 4,
  638. default = (1.0, 0.0, 0.0, 0.0,),
  639. update = update_socket,)
  640. def draw(self, context, layout, node, text):
  641. ChooseDraw(self, context, layout, node, text)
  642. def draw_color(self, context, node):
  643. return self.color
  644. @classmethod
  645. def draw_color_simple(self):
  646. return self.color_simple
  647. class IntSocket(MantisSocket):
  648. '''Custom node socket type'''
  649. bl_idname = 'IntSocket'
  650. bl_label = "Integer"
  651. default_value: bpy.props.IntProperty(default=0, update = update_socket, soft_min=-256, soft_max=256)
  652. color_simple = cInt
  653. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  654. input : bpy.props.BoolProperty(default =False,)
  655. is_valid_interface_type=True
  656. def draw(self, context, layout, node, text):
  657. ChooseDraw(self, context, layout, node, text)
  658. def draw_color(self, context, node):
  659. return self.color
  660. @classmethod
  661. def draw_color_simple(self):
  662. return self.color_simple
  663. class UnsignedIntSocket(MantisSocket):
  664. '''Unsigned Integer Socket'''
  665. bl_idname = 'UnsignedIntSocket'
  666. bl_label = "Unsigned Integer"
  667. default_value: bpy.props.IntProperty(default=0, update = update_socket, min=0, soft_max=256, max=2**13)
  668. color_simple = cInt
  669. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  670. input : bpy.props.BoolProperty(default =False,)
  671. is_valid_interface_type=True
  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. @classmethod
  677. def draw_color_simple(self):
  678. return self.color_simple
  679. class StringSocket(bpy.types.NodeSocketString, MantisSocket):
  680. """Float Input socket"""
  681. bl_idname = 'StringSocket'
  682. bl_label = "String"
  683. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  684. color_simple = cString
  685. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  686. icon : bpy.props.StringProperty(default = "NONE",)
  687. input : bpy.props.BoolProperty(default =False,)
  688. display_text : bpy.props.StringProperty(default="")
  689. is_valid_interface_type=True
  690. # def init(self):
  691. # if self.node.bl_idname == 'UtilityBoneProperties':
  692. # self.display_shape='CIRCLE_DOT'
  693. def draw(self, context, layout, node, text):
  694. ChooseDraw(self, context, layout, node, text, icon=self.icon, icon_only=True,)
  695. def draw_color(self, context, node):
  696. return self.color
  697. @classmethod
  698. def draw_color_simple(self):
  699. return self.color_simple
  700. class BoneCollectionSocket(MantisSocket):
  701. """Bone Collection socket"""
  702. bl_idname = 'BoneCollectionSocket'
  703. bl_label = "Bone Collection"
  704. default_value: bpy.props.StringProperty(default = "Collection", update = update_socket,)
  705. input : bpy.props.BoolProperty(default =False,)
  706. color_simple = cBoneCollection
  707. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  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. @classmethod
  713. def draw_color_simple(self):
  714. return self.color_simple
  715. eArrayGetOptions =(
  716. ('CAP', "Cap", "Fail if the index is out of bounds."),
  717. ('WRAP', "Wrap", "Wrap around to the beginning of the array once the idex goes out of bounds."),
  718. ('HOLD', "Hold", "Reuse the last element of the array if the index is out of bounds."),)
  719. class EnumArrayGetOptions(MantisSocket):
  720. '''Custom node socket type'''
  721. bl_idname = 'EnumArrayGetOptions'
  722. bl_label = "OoB Behaviour"
  723. default_value: bpy.props.EnumProperty(
  724. items=eArrayGetOptions,
  725. name="OoB Behaviour",
  726. description="Out-of-bounds behaviour.",
  727. default = 'HOLD',
  728. update = update_socket,)
  729. color_simple = cString
  730. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  731. input : bpy.props.BoolProperty(default =False,)
  732. def draw(self, context, layout, node, text):
  733. ChooseDraw(self, context, layout, node, text)
  734. def draw_color(self, context, node):
  735. return self.color
  736. @classmethod
  737. def draw_color_simple(self):
  738. return self.color_simple
  739. #####################################################################################
  740. # Parameters
  741. #####################################################################################
  742. class xFormParameterSocket(MantisSocket):
  743. '''xFrom Parameter'''
  744. bl_idname = 'xFormParameterSocket'
  745. bl_label = "sForm Parameter"
  746. color_simple = cxForm
  747. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  748. input : bpy.props.BoolProperty(default =False,)
  749. def init(self):
  750. self.display_shape = 'CIRCLE_DOT'
  751. def draw(self, context, layout, node, text):
  752. ChooseDraw(self, context, layout, node, text)
  753. def draw_color(self, context, node):
  754. return self.color
  755. @classmethod
  756. def draw_color_simple(self):
  757. return self.color_simple
  758. # what is this one again?
  759. class ParameterBoolSocket(MantisSocket):
  760. """Boolean Parameter Socket"""
  761. bl_idname = 'ParameterBoolSocket'
  762. bl_label = "Boolean Parameter"
  763. color_simple = cBool
  764. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  765. input : bpy.props.BoolProperty(default =False,)
  766. #custom properties:
  767. min:bpy.props.FloatProperty(default = 0)
  768. max:bpy.props.FloatProperty(default = 1)
  769. soft_min:bpy.props.FloatProperty(default = 0)
  770. soft_max:bpy.props.FloatProperty(default = 1)
  771. description:bpy.props.StringProperty(default = "")
  772. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  773. def init(self):
  774. self.display_shape = 'CIRCLE_DOT'
  775. # if True:
  776. # print (self.is_property_set("default_value"))
  777. # ui_data = self.id_properties_ui("default_value")
  778. # ui_data.update(
  779. # description=self.description,
  780. # default=0,) # for now
  781. # ui_data.update(
  782. # min = self.min,
  783. # max = self.max,
  784. # soft_min = self.soft_min,
  785. # soft_max = self.soft_max,)
  786. def draw(self, context, layout, node, text):
  787. ChooseDraw(self, context, layout, node, text)
  788. def draw_color(self, context, node):
  789. return self.color
  790. @classmethod
  791. def draw_color_simple(self):
  792. return self.color_simple
  793. class ParameterIntSocket(MantisSocket):
  794. """Integer Parameter socket"""
  795. bl_idname = 'ParameterIntSocket'
  796. bl_label = "Integer Parameter"
  797. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  798. color_simple = cInt
  799. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  800. input : bpy.props.BoolProperty(default =False,)
  801. #custom properties:
  802. min:bpy.props.FloatProperty(default = 0)
  803. max:bpy.props.FloatProperty(default = 1)
  804. soft_min:bpy.props.FloatProperty(default = 0)
  805. soft_max:bpy.props.FloatProperty(default = 1)
  806. description:bpy.props.StringProperty(default = "")
  807. def init(self):
  808. self.display_shape = 'CIRCLE_DOT'
  809. def draw(self, context, layout, node, text):
  810. ChooseDraw(self, context, layout, node, text)
  811. def draw_color(self, context, node):
  812. return self.color
  813. @classmethod
  814. def draw_color_simple(self):
  815. return self.color_simple
  816. class ParameterFloatSocket(MantisSocket):
  817. """Float Parameter socket"""
  818. bl_idname = 'ParameterFloatSocket'
  819. bl_label = "Float Parameter"
  820. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  821. color_simple = cFloat
  822. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  823. input : bpy.props.BoolProperty(default =False,)
  824. #custom properties:
  825. min:bpy.props.FloatProperty(default = 0)
  826. max:bpy.props.FloatProperty(default = 1)
  827. soft_min:bpy.props.FloatProperty(default = 0)
  828. soft_max:bpy.props.FloatProperty(default = 1)
  829. description:bpy.props.StringProperty(default = "")
  830. def init(self):
  831. self.display_shape = 'CIRCLE_DOT'
  832. def draw(self, context, layout, node, text):
  833. ChooseDraw(self, context, layout, node, text)
  834. def draw_color(self, context, node):
  835. return self.color
  836. @classmethod
  837. def draw_color_simple(self):
  838. return self.color_simple
  839. class ParameterVectorSocket(MantisSocket):
  840. """Vector Parameter socket"""
  841. bl_idname = 'ParameterVectorSocket'
  842. bl_label = "Vector Parameter"
  843. default_value : bpy.props.FloatVectorProperty(
  844. default = (0.0, 0.0, 0.0),
  845. update = update_socket,)
  846. color_simple = cVector
  847. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  848. input : bpy.props.BoolProperty(default =False,)
  849. #custom properties:
  850. description:bpy.props.StringProperty(default = "")
  851. def init(self):
  852. self.display_shape = 'CIRCLE_DOT'
  853. def draw(self, context, layout, node, text):
  854. ChooseDraw(self, context, layout, node, text)
  855. def draw_color(self, context, node):
  856. return self.color
  857. @classmethod
  858. def draw_color_simple(self):
  859. return self.color_simple
  860. class ParameterStringSocket(MantisSocket):
  861. """String Parameter socket"""
  862. bl_idname = 'ParameterStringSocket'
  863. bl_label = "String Parameter"
  864. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  865. color_simple = cString
  866. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  867. input : bpy.props.BoolProperty(default =False,)
  868. #custom properties:
  869. description:bpy.props.StringProperty(default = "")
  870. def init(self):
  871. self.display_shape = 'CIRCLE_DOT'
  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. @classmethod
  877. def draw_color_simple(self):
  878. return self.color_simple
  879. #####################################################################################
  880. # Additional socket types, for special cases
  881. #####################################################################################
  882. from bpy.props import PointerProperty, StringProperty
  883. def poll_is_armature(self, obj):
  884. return obj.type == "ARMATURE"
  885. # def poll_is_armature(self, obj):
  886. # return obj.type == "ARMATURE"
  887. class EnumMetaRigSocket(MantisSocket):
  888. '''Custom node socket type'''
  889. bl_idname = 'EnumMetaRigSocket'
  890. bl_label = "Meta Rig"
  891. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  892. def get_default_value(self):
  893. if self.search_prop:
  894. return self.search_prop.name
  895. return ""
  896. def set_default_value(self, value):
  897. if ob:= bpy.data.objects.get(value):
  898. if ob.type == 'ARMATURE':
  899. self.search_prop=ob
  900. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  901. color_simple = cString
  902. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  903. def draw(self, context, layout, node, text):
  904. if self.is_output:
  905. layout.label(text=self.name)
  906. elif not (self.is_linked):
  907. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  908. elif hasattr(self.node, "armature"):
  909. layout.label(text=self.node.armature)
  910. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  911. # which doesn't have this parameter. whatever.
  912. else:
  913. layout.label(text=self.name)
  914. def draw_color(self, context, node):
  915. return self.color
  916. @classmethod
  917. def draw_color_simple(self):
  918. return self.color_simple
  919. def poll_is_curve(self, obj):
  920. return obj.type == "CURVE"
  921. class EnumCurveSocket(MantisSocket):
  922. '''Choose a curve'''
  923. bl_idname = 'EnumCurveSocket'
  924. bl_label = "Curve"
  925. is_valid_interface_type=True
  926. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_curve, update=update_socket)
  927. def get_default_value(self):
  928. if self.search_prop:
  929. return self.search_prop.name
  930. return ""
  931. def set_default_value(self, value):
  932. if ob:= bpy.data.objects.get(value):
  933. if ob.type == 'CURVE':
  934. self.search_prop=ob
  935. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  936. color_simple = cString
  937. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  938. def draw(self, context, layout, node, text):
  939. if not (self.is_linked) and not self.is_output:
  940. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="CURVE_DATA", results_are_suggestions=True)
  941. else:
  942. try:
  943. layout.label(text=self.search_prop.name)
  944. except AttributeError: # TODO make this show the graph's result
  945. layout.label(text=self.name)
  946. def draw_color(self, context, node):
  947. return self.color
  948. @classmethod
  949. def draw_color_simple(self):
  950. return self.color_simple
  951. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  952. 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)
  953. class EnumMetaBoneSocket(MantisSocket):
  954. '''Custom node socket type'''
  955. bl_idname = 'EnumMetaBoneSocket'
  956. bl_label = "Meta Bone"
  957. search_prop:PointerProperty(type=bpy.types.Object)
  958. bone:StringProperty()
  959. def populate_bones_list(self, context):
  960. # just gonna hardcode the value
  961. if (meta_rig := self.search_prop):
  962. retList = []
  963. armatures = []
  964. i = -1
  965. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  966. for b in meta_rig.data.bones:
  967. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  968. return(retList)
  969. return None
  970. # default_value : bpy.props.EnumProperty(
  971. # items = populate_bones_list,
  972. # name = "Meta Rig")
  973. # def get_default_value(self):
  974. # return self.search_prop.name
  975. default_value : StringProperty(name = "", update=update_metarig_posebone)
  976. color_simple = cString
  977. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  978. def draw(self, context, layout, node, text):
  979. if not (self.is_linked):
  980. if self.search_prop is None:
  981. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  982. else:
  983. SearchPBDraw(self, context, layout, node, text="")
  984. else:
  985. layout.label(text=self.node.pose_bone)
  986. def draw_color(self, context, node):
  987. return self.color
  988. @classmethod
  989. def draw_color_simple(self):
  990. return self.color_simple
  991. class BoolUpdateParentNode(MantisSocket):
  992. '''Custom node socket type'''
  993. bl_idname = 'BoolUpdateParentNode'
  994. bl_label = "Boolean"
  995. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  996. color_simple = cBool
  997. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  998. input : bpy.props.BoolProperty(default =False,)
  999. def draw(self, context, layout, node, text):
  1000. ChooseDraw(self, context, layout, node, text)
  1001. def draw_color(self, context, node):
  1002. return self.color
  1003. @classmethod
  1004. def draw_color_simple(self):
  1005. return self.color_simple
  1006. class IKChainLengthSocket(MantisSocket):
  1007. '''Custom node socket type'''
  1008. bl_idname = 'IKChainLengthSocket'
  1009. bl_label = "IK Chain Length"
  1010. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  1011. color_simple = cInt
  1012. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1013. input : bpy.props.BoolProperty(default =False,)
  1014. def draw(self, context, layout, node, text):
  1015. ChooseDraw(self, context, layout, node, text)
  1016. def draw_color(self, context, node):
  1017. return self.color
  1018. @classmethod
  1019. def draw_color_simple(self):
  1020. return self.color_simple
  1021. # Inherit
  1022. eInheritScale = (
  1023. ('FULL', "Full", "Fully inherit scale", 1),
  1024. ('AVERAGE', "Average", "todo", 2),
  1025. ('ALIGNED', "Aligned", "todo", 3),
  1026. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  1027. ('NONE', "None", "todo", 5),
  1028. )
  1029. class EnumInheritScale(MantisSocket):
  1030. '''Custom node socket type'''
  1031. bl_idname = 'EnumInheritScale'
  1032. bl_label = "Inherit Scale"
  1033. default_value: bpy.props.EnumProperty(
  1034. items=eInheritScale,
  1035. name="Inherit Scale",
  1036. description="Inherit Scale",
  1037. default = 'FULL',
  1038. #options = set(),
  1039. update = update_socket,)
  1040. color_simple = cString
  1041. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1042. input : bpy.props.BoolProperty(default =False,)
  1043. def draw(self, context, layout, node, text):
  1044. ChooseDraw(self, context, layout, node, text)
  1045. def draw_color(self, context, node):
  1046. return self.color
  1047. @classmethod
  1048. def draw_color_simple(self):
  1049. return self.color_simple
  1050. # Copy Rotation
  1051. eRotationMix =(
  1052. ('REPLACE', "Replace", "Fully inherit scale", 0),
  1053. ('BEFORE', "Before", "Fully inherit scale", 1),
  1054. ('AFTER', "After", "Fully inherit scale", 2),
  1055. ('ADD', "Add", "Fully inherit scale", 3),
  1056. #todo, but i don't care much
  1057. )
  1058. # TODO HACK
  1059. # I am trying to figure out how to do enum_flag as
  1060. # mutually exclusive options
  1061. # but! I don't think it's possible
  1062. # I just like the UI for it :P
  1063. class EnumRotationMix(MantisSocket):
  1064. '''Custom node socket type'''
  1065. bl_idname = 'EnumRotationMix'
  1066. bl_label = "Rotation Mix"
  1067. default_value: bpy.props.EnumProperty(
  1068. items=eRotationMix,
  1069. name="Rotation Mix",
  1070. description="Rotation Mix",
  1071. default = 'REPLACE',#{'REPLACE'},
  1072. options = set(), # this has to be a set lol
  1073. update = update_socket,)
  1074. color_simple = cString
  1075. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1076. input : bpy.props.BoolProperty(default =False,)
  1077. def draw(self, context, layout, node, text):
  1078. ChooseDraw(self, context, layout, node, text)
  1079. def draw_color(self, context, node):
  1080. return self.color
  1081. @classmethod
  1082. def draw_color_simple(self):
  1083. return self.color_simple
  1084. eRotationMix_copytransforms =(
  1085. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  1086. ('BEFORE', "Before (Aligned)", "Fully inherit scale"),
  1087. ('AFTER', "After (Aligned)", "Fully inherit scale"),
  1088. ('REPLACE_SPLIT', "Replace (Split Channels)", "Fully inherit scale"),
  1089. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  1090. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  1091. ('REPLACE_FULL', "Replace (Full)", "Fully inherit scale"),
  1092. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  1093. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  1094. class EnumRotationMixCopyTransforms(MantisSocket):
  1095. '''Custom node socket type'''
  1096. bl_idname = 'EnumRotationMixCopyTransforms'
  1097. bl_label = "Rotation Mix"
  1098. default_value: bpy.props.EnumProperty(
  1099. items=eRotationMix_copytransforms,
  1100. name="Rotation Mix",
  1101. description="Rotation Mix",
  1102. default = 'REPLACE', #{'REPLACE'},
  1103. #options = {'ENUM_FLAG'}, # this sux
  1104. update = update_socket,)
  1105. color_simple = cString
  1106. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1107. input : bpy.props.BoolProperty(default =False,)
  1108. def draw(self, context, layout, node, text):
  1109. ChooseDraw(self, context, layout, node, text)
  1110. def draw_color(self, context, node):
  1111. return self.color
  1112. @classmethod
  1113. def draw_color_simple(self):
  1114. return self.color_simple
  1115. # STRETCH TO
  1116. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  1117. ('VOLUME_X', "X", "X", 2),
  1118. ('VOLUME_Z', "Z", "Z", 4),
  1119. ('NO_VOLUME', "None", "None", 8),)
  1120. class EnumMaintainVolumeStretchTo(MantisSocket):
  1121. '''Custom node socket type'''
  1122. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  1123. bl_label = "Maintain Volume"
  1124. default_value: bpy.props.EnumProperty(
  1125. items=eMaintainVolumeStretchTo,
  1126. name="Maintain Volume",
  1127. description="Maintain Volume",
  1128. default = 'VOLUME_XZX',
  1129. #options = {'ENUM_FLAG'},
  1130. update = update_socket,)
  1131. color_simple = cString
  1132. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1133. input : bpy.props.BoolProperty(default =False,)
  1134. def draw(self, context, layout, node, text):
  1135. ChooseDraw(self, context, layout, node, text)
  1136. def draw_color(self, context, node):
  1137. return self.color
  1138. @classmethod
  1139. def draw_color_simple(self):
  1140. return self.color_simple
  1141. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  1142. ('PLANE_Z', "ZX", "ZX", 2),
  1143. ('SWING_Y', "Swing", "Swing", 4),)
  1144. class EnumRotationStretchTo(MantisSocket):
  1145. '''Custom node socket type'''
  1146. bl_idname = 'EnumRotationStretchTo'
  1147. bl_label = "Rotation"
  1148. default_value: bpy.props.EnumProperty(
  1149. items=eRotationStretchTo,
  1150. name="Rotation",
  1151. description="Rotation",
  1152. default = 'PLANE_X',
  1153. #options = {'ENUM_FLAG'},
  1154. update = update_socket,)
  1155. color_simple = cString
  1156. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1157. input : bpy.props.BoolProperty(default =False,)
  1158. def draw(self, context, layout, node, text):
  1159. ChooseDraw(self, context, layout, node, text)
  1160. def draw_color(self, context, node):
  1161. return self.color
  1162. @classmethod
  1163. def draw_color_simple(self):
  1164. return self.color_simple
  1165. # Track-To
  1166. eTrackAxis = (('TRACK_X', "X", "X", 1),
  1167. ('TRACK_Y', "Y", "Y", 2),
  1168. ('TRACK_Z', "Z", "Z", 4),
  1169. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  1170. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  1171. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  1172. eUpAxis = (('UP_X', "X", "X", 1),
  1173. ('UP_Y', "Y", "Y", 2),
  1174. ('UP_Z', "Z", "Z", 4),)
  1175. # ugly but I can't change it easily without messing up versioning
  1176. class EnumTrackAxis(MantisSocket):
  1177. '''Custom node socket type'''
  1178. bl_idname = 'EnumTrackAxis'
  1179. bl_label = "Track Axis"
  1180. default_value: bpy.props.EnumProperty(
  1181. items=eTrackAxis,
  1182. name="Track Axis",
  1183. description="Track Axis",
  1184. default = 'TRACK_X',
  1185. #options = {'ENUM_FLAG'},
  1186. update = update_socket,)
  1187. color_simple = cString
  1188. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1189. input : bpy.props.BoolProperty(default =False,)
  1190. def draw(self, context, layout, node, text):
  1191. ChooseDraw(self, context, layout, node, text)
  1192. def draw_color(self, context, node):
  1193. return self.color
  1194. @classmethod
  1195. def draw_color_simple(self):
  1196. return self.color_simple
  1197. class EnumUpAxis(MantisSocket):
  1198. '''Custom node socket type'''
  1199. bl_idname = 'EnumUpAxis'
  1200. bl_label = "Up Axis"
  1201. default_value: bpy.props.EnumProperty(
  1202. items=eUpAxis,
  1203. name="Up Axis",
  1204. description="Up Axis",
  1205. default = 'UP_X',
  1206. #options = {'ENUM_FLAG'},
  1207. update = update_socket,)
  1208. color_simple = cString
  1209. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1210. input : bpy.props.BoolProperty(default =False,)
  1211. def draw(self, context, layout, node, text):
  1212. ChooseDraw(self, context, layout, node, text)
  1213. def draw_color(self, context, node):
  1214. return self.color
  1215. @classmethod
  1216. def draw_color_simple(self):
  1217. return self.color_simple
  1218. # Follow Track Forward axis
  1219. eForwardAxis = (('FORWARD_X', "X", "X", 0),
  1220. ('FORWARD_Y', "Y", "Y", 1),
  1221. ('FORWARD_Z', "Z", "Z", 2),
  1222. ('TRACK_NEGATIVE_X', "-X", "-X", 3),
  1223. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 4),
  1224. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 5),)
  1225. class EnumFollowPathForwardAxis(MantisSocket):
  1226. '''Custom node socket type'''
  1227. bl_idname = 'EnumFollowPathForwardAxis'
  1228. bl_label = "Forward Axis"
  1229. default_value: bpy.props.EnumProperty(
  1230. items=eForwardAxis,
  1231. name="Forward Axis",
  1232. description="Forward Axis",
  1233. default = 'FORWARD_X',
  1234. update = update_socket,)
  1235. color_simple = cString
  1236. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1237. input : bpy.props.BoolProperty(default =False,)
  1238. def draw(self, context, layout, node, text):
  1239. ChooseDraw(self, context, layout, node, text)
  1240. def draw_color(self, context, node):
  1241. return self.color
  1242. @classmethod
  1243. def draw_color_simple(self):
  1244. return self.color_simple
  1245. # Locked Track
  1246. eLockAxis = (('LOCK_X', "X", "X", 1),
  1247. ('LOCK_Y', "Y", "Y", 2),
  1248. ('LOCK_Z', "Z", "Z", 4),)
  1249. class EnumLockAxis(MantisSocket):
  1250. '''Custom node socket type'''
  1251. bl_idname = 'EnumLockAxis'
  1252. bl_label = "Lock Axis"
  1253. default_value: bpy.props.EnumProperty(
  1254. items=eLockAxis,
  1255. name="Lock Axis",
  1256. description="Lock Axis",
  1257. default = 'LOCK_X',
  1258. #options = {'ENUM_FLAG'},
  1259. update = update_socket,)
  1260. color_simple = cString
  1261. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1262. input : bpy.props.BoolProperty(default =False,)
  1263. def draw(self, context, layout, node, text):
  1264. ChooseDraw(self, context, layout, node, text)
  1265. def draw_color(self, context, node):
  1266. return self.color
  1267. @classmethod
  1268. def draw_color_simple(self):
  1269. return self.color_simple
  1270. # Limit Distance:
  1271. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  1272. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  1273. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  1274. class EnumLimitMode(MantisSocket):
  1275. '''Custom node socket type'''
  1276. bl_idname = 'EnumLimitMode'
  1277. bl_label = "Clamp Region"
  1278. default_value: bpy.props.EnumProperty(
  1279. items=eLimitMode,
  1280. name="Clamp Region",
  1281. description="Clamp Region",
  1282. default = 'LIMITDIST_INSIDE',
  1283. update = update_socket,)
  1284. color_simple = cString
  1285. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1286. input : bpy.props.BoolProperty(default =False,)
  1287. def draw(self, context, layout, node, text):
  1288. ChooseDraw(self, context, layout, node, text)
  1289. def draw_color(self, context, node):
  1290. return self.color
  1291. @classmethod
  1292. def draw_color_simple(self):
  1293. return self.color_simple
  1294. # Spline IK
  1295. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1296. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  1297. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  1298. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1299. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1300. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1301. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1302. class EnumYScaleMode(MantisSocket):
  1303. '''Custom node socket type'''
  1304. bl_idname = 'EnumYScaleMode'
  1305. bl_label = "Y Scale Mode"
  1306. default_value: bpy.props.EnumProperty(
  1307. items=eYScaleMode,
  1308. name="Y Scale Mode",
  1309. description="Y Scale Mode",
  1310. default = 'FIT_CURVE',
  1311. update = update_socket,)
  1312. color_simple = cString
  1313. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1314. input : bpy.props.BoolProperty(default =False,)
  1315. def draw(self, context, layout, node, text):
  1316. ChooseDraw(self, context, layout, node, text)
  1317. def draw_color(self, context, node):
  1318. return self.color
  1319. @classmethod
  1320. def draw_color_simple(self):
  1321. return self.color_simple
  1322. class EnumXZScaleMode(MantisSocket):
  1323. '''Custom node socket type'''
  1324. bl_idname = 'EnumXZScaleMode'
  1325. bl_label = "XZ Scale Mode"
  1326. default_value: bpy.props.EnumProperty(
  1327. items=eXZScaleMode,
  1328. name="XZ Scale Mode",
  1329. description="XZ Scale Mode",
  1330. default = 'NONE',
  1331. update = update_socket,)
  1332. color_simple = cString
  1333. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1334. input : bpy.props.BoolProperty(default =False,)
  1335. def draw(self, context, layout, node, text):
  1336. ChooseDraw(self, context, layout, node, text)
  1337. def draw_color(self, context, node):
  1338. return self.color
  1339. @classmethod
  1340. def draw_color_simple(self):
  1341. return self.color_simple
  1342. eMapxForm = (('LOCATION', "Location", "Location",),
  1343. ('ROTATION', "Rotation", "Rotation",),
  1344. ('SCALE', "Scale", "Scale",),)
  1345. eRotationMode = (('AUTO', 'Auto', 'Automattically Selected.', 0),
  1346. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1347. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1348. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1349. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1350. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1351. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1352. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1353. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1354. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1355. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1356. enumTransformationRotationOrder = enumRotationOrder[:6]
  1357. eTranslationMix =(
  1358. ('ADD', "Add", "", 0),
  1359. ('REPLACE', "Replace", "", 1),
  1360. )
  1361. eScaleMix =(
  1362. ('MULTIPLY', "Multiply", "", 0),
  1363. ('REPLACE', "Replace", "", 1),
  1364. )
  1365. class EnumTransformationMap(MantisSocket):
  1366. '''Custom node socket type'''
  1367. bl_idname = 'EnumTransformationMap'
  1368. bl_label = "Map To/From"
  1369. default_value: bpy.props.EnumProperty(
  1370. items=eMapxForm,
  1371. name="Map To/From",
  1372. description="Map To/From",
  1373. default = 'LOCATION',
  1374. update = update_socket,)
  1375. color_simple = cString
  1376. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1377. input : bpy.props.BoolProperty(default =False,)
  1378. def draw(self, context, layout, node, text):
  1379. ChooseDraw(self, context, layout, node, text)
  1380. def draw_color(self, context, node):
  1381. return self.color
  1382. @classmethod
  1383. def draw_color_simple(self):
  1384. return self.color_simple
  1385. class EnumTransformationRotationMode(MantisSocket):
  1386. '''Custom node socket type'''
  1387. bl_idname = 'EnumTransformationRotationMode'
  1388. bl_label = "Map To/From"
  1389. default_value: bpy.props.EnumProperty(
  1390. items=eRotationMode,
  1391. name="Rotation Mode",
  1392. description="Rotation Mode",
  1393. default = 'AUTO',
  1394. update = update_socket,)
  1395. color_simple = cString
  1396. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1397. input : bpy.props.BoolProperty(default =False,)
  1398. def draw(self, context, layout, node, text):
  1399. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1400. def draw_color(self, context, node):
  1401. return self.color
  1402. @classmethod
  1403. def draw_color_simple(self):
  1404. return self.color_simple
  1405. class EnumTransformationRotationOrder(MantisSocket):
  1406. '''Custom node socket type'''
  1407. bl_idname = 'EnumTransformationRotationOrder'
  1408. bl_label = "Map To/From"
  1409. default_value: bpy.props.EnumProperty(
  1410. items=enumTransformationRotationOrder,
  1411. name="Rotation Order",
  1412. description="Rotation Order",
  1413. default = 'AUTO',
  1414. update = update_socket,)
  1415. color_simple = cString
  1416. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1417. input : bpy.props.BoolProperty(default =False,)
  1418. def draw(self, context, layout, node, text):
  1419. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1420. def draw_color(self, context, node):
  1421. return self.color
  1422. @classmethod
  1423. def draw_color_simple(self):
  1424. return self.color_simple
  1425. class EnumTransformationTranslationMixMode(MantisSocket):
  1426. '''Custom node socket type'''
  1427. bl_idname = 'EnumTransformationTranslationMixMode'
  1428. bl_label = "Mix Mode"
  1429. default_value: bpy.props.EnumProperty(
  1430. items=eTranslationMix,
  1431. name="Mix Translation",
  1432. description="Mix Translation",
  1433. default = 'ADD',
  1434. update = update_socket,)
  1435. color_simple = cString
  1436. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1437. input : bpy.props.BoolProperty(default =False,)
  1438. def draw(self, context, layout, node, text):
  1439. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1440. def draw_color(self, context, node):
  1441. return self.color
  1442. @classmethod
  1443. def draw_color_simple(self):
  1444. return self.color_simple
  1445. class EnumTransformationRotationMixMode(MantisSocket):
  1446. '''Custom node socket type'''
  1447. bl_idname = 'EnumTransformationRotationMixMode'
  1448. bl_label = "Mix Mode"
  1449. default_value: bpy.props.EnumProperty(
  1450. items=eRotationMix,
  1451. name="Mix Rotation",
  1452. description="Mix Rotation",
  1453. default = 'ADD',
  1454. update = update_socket,)
  1455. color_simple = cString
  1456. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1457. input : bpy.props.BoolProperty(default =False,)
  1458. def draw(self, context, layout, node, text):
  1459. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1460. def draw_color(self, context, node):
  1461. return self.color
  1462. @classmethod
  1463. def draw_color_simple(self):
  1464. return self.color_simple
  1465. class EnumTransformationScaleMixMode(MantisSocket):
  1466. '''Custom node socket type'''
  1467. bl_idname = 'EnumTransformationScaleMixMode'
  1468. bl_label = "Mix Mode"
  1469. default_value: bpy.props.EnumProperty(
  1470. items=eScaleMix,
  1471. name="Mix Scale",
  1472. description="Mix Scale",
  1473. default = 'REPLACE',
  1474. update = update_socket,)
  1475. color_simple = cString
  1476. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1477. input : bpy.props.BoolProperty(default =False,)
  1478. def draw(self, context, layout, node, text):
  1479. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1480. def draw_color(self, context, node):
  1481. return self.color
  1482. @classmethod
  1483. def draw_color_simple(self):
  1484. return self.color_simple
  1485. eAxes = (
  1486. ('X', "X", "X", 0),
  1487. ('Y', "Y", "Y", 1),
  1488. ('Z', "Z", "Z", 2),
  1489. )
  1490. class EnumTransformationAxes(MantisSocket):
  1491. '''Custom node socket type'''
  1492. bl_idname = 'EnumTransformationAxes'
  1493. bl_label = "Axes"
  1494. default_value: bpy.props.EnumProperty(
  1495. items=eAxes,
  1496. # name="",
  1497. # description="",
  1498. default = 'X',
  1499. update = update_socket,)
  1500. color_simple = cString
  1501. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1502. input : bpy.props.BoolProperty(default =False,)
  1503. def draw(self, context, layout, node, text):
  1504. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1505. def draw_color(self, context, node):
  1506. return self.color
  1507. @classmethod
  1508. def draw_color_simple(self):
  1509. return self.color_simple
  1510. #
  1511. eBBoneHandleType = (
  1512. ('AUTO', "Automatic", "", 0),
  1513. ('ABSOLUTE', "Absolute", "", 1),
  1514. ('RELATIVE', "Relative", "", 2),
  1515. ('TANGENT', "Tangent", "", 3),
  1516. )
  1517. class EnumBBoneHandleType(MantisSocket):
  1518. '''Custom node socket type'''
  1519. bl_idname = 'EnumBBoneHandleType'
  1520. bl_label = "Axes"
  1521. default_value: bpy.props.EnumProperty(
  1522. items=eBBoneHandleType,
  1523. # name="",
  1524. # description="",
  1525. default = 'AUTO',
  1526. update = update_socket,)
  1527. color_simple = cString
  1528. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1529. input : bpy.props.BoolProperty(default =False,)
  1530. def draw(self, context, layout, node, text):
  1531. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1532. def draw_color(self, context, node):
  1533. return self.color
  1534. @classmethod
  1535. def draw_color_simple(self):
  1536. return self.color_simple
  1537. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  1538. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),
  1539. ('COPY_FROM_OBJECT', "Copy from object", "Copy skin weights from the selected object"),)
  1540. class EnumSkinning(MantisSocket):
  1541. '''Custom node socket type'''
  1542. bl_idname = 'EnumSkinning'
  1543. bl_label = "Skinning Method"
  1544. default_value: bpy.props.EnumProperty(
  1545. items=eSkinningMethod,
  1546. name="Skinning Method",
  1547. description="Skinning Method",
  1548. default = 'AUTOMATIC_HEAT',
  1549. update = update_socket,)
  1550. color_simple = cString
  1551. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1552. input : bpy.props.BoolProperty(default =False,)
  1553. def draw(self, context, layout, node, text):
  1554. ChooseDraw(self, context, layout, node, text)
  1555. def draw_color(self, context, node):
  1556. return self.color
  1557. @classmethod
  1558. def draw_color_simple(self):
  1559. return self.color_simple
  1560. class MorphTargetSocket(MantisSocket):
  1561. """Morph Target"""
  1562. bl_idname = 'MorphTargetSocket'
  1563. bl_label = "Morph Target"
  1564. color_simple = cShapeKey
  1565. color : bpy.props.FloatVectorProperty(default=cShapeKey, size=4)
  1566. input : bpy.props.BoolProperty(default =False,)
  1567. is_valid_interface_type=True
  1568. def draw(self, context, layout, node, text):
  1569. ChooseDraw(self, context, layout, node, text)
  1570. def draw_color(self, context, node):
  1571. return self.color
  1572. @classmethod
  1573. def draw_color_simple(self):
  1574. return self.color_simple
  1575. eDriverVariableType = (
  1576. ( 'SINGLE_PROP',
  1577. "Property",
  1578. "Property",
  1579. 1),
  1580. ( 'LOC_DIFF',
  1581. "Distance",
  1582. "Distance",
  1583. 2),
  1584. ( 'ROTATION_DIFF',
  1585. "Rotational Difference",
  1586. "Rotational Difference",
  1587. 3),
  1588. # ( 'TRANSFORMS',
  1589. # "Transform Channel",
  1590. # "Transform Channel",
  1591. # 4),
  1592. )
  1593. class EnumDriverVariableType(MantisSocket):
  1594. '''Custom node socket type'''
  1595. bl_idname = 'EnumDriverVariableType'
  1596. bl_label = "Variable Type"
  1597. default_value: bpy.props.EnumProperty(
  1598. items = eDriverVariableType,
  1599. name = "Variable Type",
  1600. description = "Variable Type",
  1601. default = 'SINGLE_PROP',
  1602. update = driver_variable_socket_update,)
  1603. color_simple = cString
  1604. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1605. input : bpy.props.BoolProperty(default =False,)
  1606. def draw(self, context, layout, node, text):
  1607. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1608. def draw_color(self, context, node):
  1609. return self.color
  1610. @classmethod
  1611. def draw_color_simple(self):
  1612. return self.color_simple
  1613. eDriverVariableEvaluationSpace = (
  1614. ( 'WORLD_SPACE',
  1615. "World",
  1616. "World",
  1617. 1),
  1618. ( 'TRANSFORM_SPACE',
  1619. "Transform",
  1620. "Transform",
  1621. 2),
  1622. ( 'LOCAL_SPACE',
  1623. "Local",
  1624. "Local",
  1625. 3),
  1626. )
  1627. class EnumDriverVariableEvaluationSpace(MantisSocket):
  1628. '''Custom node socket type'''
  1629. bl_idname = 'EnumDriverVariableEvaluationSpace'
  1630. bl_label = "Evaluation Space"
  1631. default_value: bpy.props.EnumProperty(
  1632. items = eDriverVariableEvaluationSpace,
  1633. name = "Evaluation Space",
  1634. description = "Evaluation Space",
  1635. default = 'WORLD_SPACE',
  1636. update = driver_variable_socket_update,)
  1637. color_simple = cString
  1638. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1639. input : bpy.props.BoolProperty(default =False,)
  1640. def draw(self, context, layout, node, text):
  1641. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1642. def draw_color(self, context, node):
  1643. return self.color
  1644. @classmethod
  1645. def draw_color_simple(self):
  1646. return self.color_simple
  1647. eDriverVariableTransformChannel = (
  1648. ("LOC_X", "X Location", "The X-coordinate of an object's location.", 1),
  1649. ("LOC_Y", "Y Location", "The Y-coordinate of an object's location.", 2),
  1650. ("LOC_Z", "Z Location", "The Z-coordinate of an object's location.", 3),
  1651. ("ROT_X", "X Rotation", "Rotation X-axis.", 4),
  1652. ("ROT_Y", "Y Rotation", "Rotation Y-axis.", 5),
  1653. ("ROT_Z", "Z Rotation", "Rotation Z-axis.", 6),
  1654. ("ROT_W", "W Rotation", "Rotation W-axis.", 7),
  1655. ("SCALE_X", "X Scale", "The X-scale of an object's scale.", 8),
  1656. ("SCALE_Y", "Y Scale", "The Y-scale of an object's scale.", 9),
  1657. ("SCALE_Z", "Z Scale", "The Z-scale of an object's scale.", 10),
  1658. ("SCALE_AVG", "Average Scale", "The scale factor of an object's scale.", 11),
  1659. )
  1660. class EnumDriverVariableTransformChannel(MantisSocket):
  1661. '''Custom node socket type'''
  1662. bl_idname = 'EnumDriverVariableTransformChannel'
  1663. bl_label = "Transform Channel"
  1664. default_value: bpy.props.EnumProperty(
  1665. items = eDriverVariableTransformChannel,
  1666. name = "Transform Channel",
  1667. description = "Transform Channel",
  1668. default = 'LOC_X',
  1669. update = driver_variable_socket_update,)
  1670. color_simple = cString
  1671. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1672. input : bpy.props.BoolProperty(default =False,)
  1673. def draw(self, context, layout, node, text):
  1674. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1675. def draw_color(self, context, node):
  1676. return self.color
  1677. @classmethod
  1678. def draw_color_simple(self):
  1679. return self.color_simple
  1680. class EnumDriverRotationMode(MantisSocket):
  1681. '''Custom node socket type'''
  1682. bl_idname = 'EnumDriverRotationMode'
  1683. bl_label = "Rotaton Mode"
  1684. default_value: bpy.props.EnumProperty(
  1685. items = eRotationMode,
  1686. name = "Rotation Mode",
  1687. description = "Rotation Mode",
  1688. default = 'AUTO',
  1689. update = driver_variable_socket_update,)
  1690. color_simple = cString
  1691. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1692. input : bpy.props.BoolProperty(default =False,)
  1693. def draw(self, context, layout, node, text):
  1694. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1695. def draw_color(self, context, node):
  1696. return self.color
  1697. @classmethod
  1698. def draw_color_simple(self):
  1699. return self.color_simple
  1700. #
  1701. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  1702. ('SUM', "Sum", "Sum", 1),
  1703. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  1704. ('MIN', "Min", "Minimum", 3),
  1705. ('MAX', "Max", "Maximum", 4),)
  1706. class EnumDriverType(MantisSocket):
  1707. '''Custom node socket type'''
  1708. bl_idname = 'EnumDriverType'
  1709. bl_label = "Driver Type"
  1710. default_value: bpy.props.EnumProperty(
  1711. items = eDriverType,
  1712. name = "Driver Type",
  1713. description = "Driver Type",
  1714. default = 'AVERAGE',
  1715. update = driver_socket_update,)
  1716. color_simple = cString
  1717. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1718. input : bpy.props.BoolProperty(default =False,)
  1719. def draw(self, context, layout, node, text):
  1720. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1721. def draw_color(self, context, node):
  1722. return self.color
  1723. @classmethod
  1724. def draw_color_simple(self):
  1725. return self.color_simple
  1726. # Keyframe
  1727. # Enum for kf handle type
  1728. # enum for interpolation type
  1729. # eventually gonna make it to the fancy stuff
  1730. class FloatSocket(bpy.types.NodeSocketFloat, MantisSocket):
  1731. """Float Input socket"""
  1732. bl_idname = 'FloatSocket'
  1733. bl_label = "Float"
  1734. is_valid_interface_type=True
  1735. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1736. color_simple = cFloat
  1737. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1738. input : bpy.props.BoolProperty(default =False,)
  1739. def draw(self, context, layout, node, text):
  1740. ChooseDraw(self, context, layout, node, text)
  1741. def draw_color(self, context, node):
  1742. return self.color
  1743. @classmethod
  1744. def draw_color_simple(self):
  1745. return self.color_simple
  1746. class FloatPositiveSocket(bpy.types.NodeSocketFloat, MantisSocket):
  1747. """Float Input socket"""
  1748. bl_idname = 'FloatPositiveSocket'
  1749. bl_label = "Float (Positive)"
  1750. is_valid_interface_type=True
  1751. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  1752. color_simple = cFloat
  1753. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1754. input : bpy.props.BoolProperty(default =False,)
  1755. def draw(self, context, layout, node, text):
  1756. ChooseDraw(self, context, layout, node, text)
  1757. def draw_color(self, context, node):
  1758. return self.color
  1759. @classmethod
  1760. def draw_color_simple(self):
  1761. return self.color_simple
  1762. class FloatFactorSocket(bpy.types.NodeSocketFloatFactor, MantisSocket):
  1763. '''xFrom Input Output'''
  1764. bl_idname = 'FloatFactorSocket'
  1765. bl_label = "Float (Factor)"
  1766. is_valid_interface_type=True
  1767. default_value : bpy.props.FloatProperty(
  1768. default = 0.0,
  1769. min = 0.0,
  1770. max=1.0,
  1771. update = update_socket,
  1772. subtype='FACTOR',)
  1773. color_simple = cFloat
  1774. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1775. input : bpy.props.BoolProperty(default =False,)
  1776. def draw(self, context, layout, node, text):
  1777. ChooseDraw(self, context, layout, node, text)
  1778. def draw_color(self, context, node):
  1779. return self.color
  1780. @classmethod
  1781. def draw_color_simple(self):
  1782. return self.color_simple
  1783. class FloatAngleSocket(bpy.types.NodeSocketFloatAngle, MantisSocket):
  1784. '''xFrom Input Output'''
  1785. bl_idname = 'FloatAngleSocket'
  1786. bl_label = "Float (Angle)"
  1787. is_valid_interface_type=True
  1788. default_value : bpy.props.FloatProperty(
  1789. default = 0.0,
  1790. min = -180,
  1791. max=180,
  1792. update = update_socket,
  1793. subtype='ANGLE',)
  1794. color_simple = cFloat
  1795. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1796. input : bpy.props.BoolProperty(default =False,)
  1797. def draw(self, context, layout, node, text):
  1798. ChooseDraw(self, context, layout, node, text)
  1799. def draw_color(self, context, node):
  1800. return self.color
  1801. @classmethod
  1802. def draw_color_simple(self):
  1803. return self.color_simple
  1804. class VectorSocket(bpy.types.NodeSocketVectorEuler, MantisSocket):
  1805. """Vector Input socket"""
  1806. bl_idname = 'VectorSocket'
  1807. bl_label = "Vector"
  1808. is_valid_interface_type=True
  1809. default_value : bpy.props.FloatVectorProperty(
  1810. default = (0.0, 0.0, 0.0),
  1811. update = update_socket,)
  1812. color_simple = cVector
  1813. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1814. input : bpy.props.BoolProperty(default =False,)
  1815. def draw(self, context, layout, node, text):
  1816. ChooseDraw(self, context, layout, node, text)
  1817. def draw_color(self, context, node):
  1818. return self.color
  1819. @classmethod
  1820. def draw_color_simple(self):
  1821. return self.color_simple
  1822. class VectorEulerSocket(bpy.types.NodeSocketVectorEuler, MantisSocket):
  1823. """Vector Input socket"""
  1824. bl_idname = 'VectorEulerSocket'
  1825. bl_label = "Euler"
  1826. is_valid_interface_type=True
  1827. default_value : bpy.props.FloatVectorProperty(
  1828. default = (0.0, 0.0, 0.0),
  1829. update = update_socket,
  1830. subtype='EULER',)
  1831. color_simple = cVector
  1832. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1833. input : bpy.props.BoolProperty(default =False,)
  1834. def draw(self, context, layout, node, text):
  1835. ChooseDraw(self, context, layout, node, text)
  1836. def draw_color(self, context, node):
  1837. return self.color
  1838. @classmethod
  1839. def draw_color_simple(self):
  1840. return self.color_simple
  1841. class VectorTranslationSocket(bpy.types.NodeSocketVectorTranslation, MantisSocket):
  1842. """Vector Input socket"""
  1843. bl_idname = 'VectorTranslationSocket'
  1844. bl_label = "Vector (Translation)"
  1845. default_value : bpy.props.FloatVectorProperty(
  1846. default = (0.0, 0.0, 0.0),
  1847. update = update_socket,
  1848. subtype='TRANSLATION',)
  1849. color_simple = cVector
  1850. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1851. input : bpy.props.BoolProperty(default =False,)
  1852. def draw(self, context, layout, node, text):
  1853. ChooseDraw(self, context, layout, node, text)
  1854. def draw_color(self, context, node):
  1855. return self.color
  1856. @classmethod
  1857. def draw_color_simple(self):
  1858. return self.color_simple
  1859. class VectorScaleSocket(bpy.types.NodeSocketVectorXYZ, MantisSocket):
  1860. """Vector Input socket"""
  1861. bl_idname = 'VectorScaleSocket'
  1862. bl_label = "Vector (Scale)"
  1863. default_value : bpy.props.FloatVectorProperty(
  1864. default = (1.0, 1.0, 1.0),
  1865. update = update_socket,
  1866. subtype='XYZ',)
  1867. color_simple = cVector
  1868. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1869. input : bpy.props.BoolProperty(default =False,)
  1870. def draw(self, context, layout, node, text):
  1871. ChooseDraw(self, context, layout, node, text)
  1872. def draw_color(self, context, node):
  1873. return self.color
  1874. @classmethod
  1875. def draw_color_simple(self):
  1876. return self.color_simple
  1877. class KeyframeSocket(MantisSocket):
  1878. '''Keyframe'''
  1879. bl_idname = 'KeyframeSocket'
  1880. bl_label = "Keyframe"
  1881. is_valid_interface_type=True
  1882. color_simple = cKeyframe
  1883. color : bpy.props.FloatVectorProperty(default=cKeyframe, size=4)
  1884. input : bpy.props.BoolProperty(default =False, update = update_socket)
  1885. def init(self):
  1886. self.display_shape = 'CIRCLE_DOT'
  1887. def draw(self, context, layout, node, text):
  1888. ChooseDraw(self, context, layout, node, text)
  1889. def draw_color(self, context, node):
  1890. return self.color
  1891. @classmethod
  1892. def draw_color_simple(self):
  1893. return self.color_simple
  1894. EnumKeyframeInterpolationType = (('CONSTANT', 'Stepped', 'Stepped'),
  1895. ('LINEAR', "Linear", "Linear"),
  1896. ('BEZIER', "Bezier", "Bezier"),)
  1897. class EnumKeyframeInterpolationTypeSocket(MantisSocket):
  1898. '''Keyframe Interpolation Type'''
  1899. bl_idname = 'EnumKeyframeInterpolationTypeSocket'
  1900. bl_label = "Keyframe Interpolation Type"
  1901. default_value :bpy.props.EnumProperty(
  1902. name="",
  1903. description="Interpolation",
  1904. items=EnumKeyframeInterpolationType,
  1905. default='LINEAR',
  1906. update = update_socket,)
  1907. color_simple = cString
  1908. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1909. input : bpy.props.BoolProperty(default =False, update = update_socket)
  1910. def draw(self, context, layout, node, text):
  1911. ChooseDraw(self, context, layout, node, text)
  1912. def draw_color(self, context, node):
  1913. return self.color
  1914. @classmethod
  1915. def draw_color_simple(self):
  1916. return self.color_simple
  1917. EnumKeyframeBezierHandleType = (('FREE', 'Free', 'Completely independent manually set handle.'),
  1918. ('ALIGNED', "Aligned", "Manually set handle with rotation locked together with its pair."),
  1919. ('VECTOR', "Vector", "Automatic handles that create straight lines."),
  1920. ('AUTO', "Automatic", "Automatic handles that create smooth curves."),
  1921. ('AUTO_CLAMPED', "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes."),)
  1922. class EnumKeyframeBezierHandleTypeSocket(MantisSocket):
  1923. '''Keyframe Bezier Handle Type'''
  1924. bl_idname = 'EnumKeyframeBezierHandleTypeSocket'
  1925. bl_label = "Keyframe Bezier Handle Type"
  1926. default_value :bpy.props.EnumProperty(
  1927. name="",
  1928. description="Handle Type",
  1929. items=EnumKeyframeBezierHandleType,
  1930. default='AUTO_CLAMPED',
  1931. update = update_socket,)
  1932. color_simple = cString
  1933. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1934. input : bpy.props.BoolProperty(default =False, update = update_socket)
  1935. def draw(self, context, layout, node, text):
  1936. ChooseDraw(self, context, layout, node, text)
  1937. def draw_color(self, context, node):
  1938. return self.color
  1939. @classmethod
  1940. def draw_color_simple(self):
  1941. return self.color_simple
  1942. enumExtrapolationMode = (('CONSTANT', 'Constant', 'Constant'),
  1943. ('LINEAR', "Linear", "Linear"),)
  1944. class eFCrvExtrapolationMode(MantisSocket):
  1945. '''FCurve Extrapolation Mode'''
  1946. bl_idname = 'eFCrvExtrapolationMode'
  1947. bl_label = "Extrapolation Mode"
  1948. default_value :bpy.props.EnumProperty(
  1949. name="",
  1950. description="Handle Type",
  1951. items=enumExtrapolationMode,
  1952. default='CONSTANT',
  1953. update = update_socket,)
  1954. color_simple = cString
  1955. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1956. input : bpy.props.BoolProperty(default =False, update = update_socket)
  1957. def draw(self, context, layout, node, text):
  1958. ChooseDraw(self, context, layout, node, text)
  1959. def draw_color(self, context, node):
  1960. return self.color
  1961. @classmethod
  1962. def draw_color_simple(self):
  1963. return self.color_simple
  1964. enumFloatOperations = (('ADD', 'Add', 'Add'),
  1965. ('SUBTRACT', "Subtract", "Subtract"),
  1966. ('MULTIPLY', "Multiply", "Multiply"),
  1967. ('DIVIDE', "Divide", "Divide"),
  1968. ('POWER', "Power", "Power"),
  1969. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  1970. ('MODULUS', "Modulus", "Modulus"),
  1971. ('ABSOLUTE', "Absolute", "Absolute Value"),
  1972. ('MAXIMUM', "Maximum", "Maximum"),
  1973. ('MINIMUM', "Minimum", "Minimum"),
  1974. ('GREATER THAN', "Greater Than", "Greater Than"),
  1975. ('LESS THAN', "Less Than", "Less Than"),
  1976. ('ARCTAN2', "atan2", "2-argument arctan function"),)
  1977. class MathFloatOperation(MantisSocket):
  1978. """Float Math Operation"""
  1979. bl_idname = 'MathFloatOperation'
  1980. bl_label = "Operation"
  1981. default_value :bpy.props.EnumProperty(
  1982. name="",
  1983. description="Operation",
  1984. items=enumFloatOperations,
  1985. default='MULTIPLY',
  1986. update = update_socket,)
  1987. color_simple = cString
  1988. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1989. input : bpy.props.BoolProperty(default =False,)
  1990. def draw(self, context, layout, node, text):
  1991. ChooseDraw(self, context, layout, node, text)
  1992. def draw_color(self, context, node):
  1993. return self.color
  1994. @classmethod
  1995. def draw_color_simple(self):
  1996. return self.color_simple
  1997. enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
  1998. ('SUBTRACT', "Subtract", "Subtract (Component-wise)"),
  1999. ('MULTIPLY', "Multiply", "Multiply (Component-wise)"),
  2000. ('SCALE', "Scale", "Scales vector by input float or average magnitude of input vector's components."),
  2001. ('DIVIDE', "Divide", "Divide (Component-wise)"),
  2002. ('POWER', "Power", "Power (Component-wise)"),
  2003. ('LENGTH', "Length", "Length"),
  2004. ('CROSS', "Cross Product", "Cross product of A X B"),
  2005. ('NORMALIZE', "Normalize", "Returns a normalized vector."),
  2006. ('DOT', "Dot Product", "Dot product of A . B"),
  2007. ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))
  2008. class MathVectorOperation(MantisSocket):
  2009. """Vector Math Operation"""
  2010. bl_idname = 'MathVectorOperation'
  2011. bl_label = "Operation"
  2012. default_value :bpy.props.EnumProperty(
  2013. name="",
  2014. description="Operation",
  2015. items=enumVectorOperations,
  2016. default='MULTIPLY',
  2017. update = update_socket,)
  2018. color_simple = cString
  2019. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2020. input : bpy.props.BoolProperty(default =False,)
  2021. def draw(self, context, layout, node, text):
  2022. ChooseDraw(self, context, layout, node, text)
  2023. def draw_color(self, context, node):
  2024. return self.color
  2025. @classmethod
  2026. def draw_color_simple(self):
  2027. return self.color_simple
  2028. enumMatrixTransform = (('TRANSLATE', 'Translate', 'Translate'),
  2029. ('ROTATE_AXIS_ANGLE', "Rotate (Axis-angle)", "Rotates a number of radians around an axis"),
  2030. # ('ROTATE_EULER', "Rotate (Euler)", "Euler Rotation"),
  2031. # ('ROTATE_QUATERNION', "Rotate (Quaternion)", "Quaternion Rotation"),
  2032. ('SCALE', "Scale", "Scale"),)
  2033. class MatrixTransformOperation(MantisSocket):
  2034. """Matrix Transform Operation"""
  2035. bl_idname = 'MatrixTransformOperation'
  2036. bl_label = "Operation"
  2037. default_value :bpy.props.EnumProperty(
  2038. name="",
  2039. description="Operation",
  2040. items=enumMatrixTransform,
  2041. default='TRANSLATE',
  2042. update = update_socket,)
  2043. color_simple = cString
  2044. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2045. input : bpy.props.BoolProperty(default =False,)
  2046. def draw(self, context, layout, node, text):
  2047. ChooseDraw(self, context, layout, node, text)
  2048. def draw_color(self, context, node):
  2049. return self.color
  2050. @classmethod
  2051. def draw_color_simple(self):
  2052. return self.color_simple
  2053. enumIntOperations = (('ADD', 'Add', 'Add'),
  2054. ('SUBTRACT', "Subtract", "Subtract"),
  2055. ('MULTIPLY', "Multiply", "Multiply"),
  2056. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2057. ('POWER', "Power", "Power"),
  2058. ('MODULUS', "Modulus", "Modulus"),
  2059. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2060. ('MAXIMUM', "Maximum", "Maximum"),
  2061. ('MINIMUM', "Minimum", "Minimum"),
  2062. ('GREATER THAN', "Greater Than", "Greater Than"),
  2063. ('LESS THAN', "Less Than", "Less Than"),)
  2064. class MathIntOperation(MantisSocket):
  2065. """Int Math Operation"""
  2066. bl_idname = 'MathIntOperation'
  2067. bl_label = "Operation"
  2068. default_value :bpy.props.EnumProperty(
  2069. name="",
  2070. description="Operation",
  2071. items=enumIntOperations,
  2072. default='MULTIPLY',
  2073. update = update_socket,)
  2074. color_simple = cString
  2075. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2076. input : bpy.props.BoolProperty(default =False,)
  2077. def draw(self, context, layout, node, text):
  2078. ChooseDraw(self, context, layout, node, text)
  2079. def draw_color(self, context, node):
  2080. return self.color
  2081. @classmethod
  2082. def draw_color_simple(self):
  2083. return self.color_simple
  2084. enumCompareOperations = (('EQUAL', "Equal", "Equal"),
  2085. ('NOT_EQUAL', "Not Equal", "Not Equal"),
  2086. ('GREATER_THAN', "Greater Than", "Greater Than"),
  2087. ('GREATER_THAN_EQUAL', "Greater Than or Equal", "Greater Than or Equal"),
  2088. ('LESS_THAN', "Less Than", "Less Than"),
  2089. ('LESS_THAN_EQUAL', "Equal or Less Than", "Equal or Less Than"),)
  2090. class EnumCompareOperation(MantisSocket):
  2091. """Compare Operation"""
  2092. bl_idname = 'EnumCompareOperation'
  2093. bl_label = "Comparison"
  2094. default_value :bpy.props.EnumProperty(
  2095. name="",
  2096. description="Comparison",
  2097. items=enumCompareOperations,
  2098. default='EQUAL',
  2099. update = update_socket,)
  2100. color_simple = cString
  2101. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2102. input : bpy.props.BoolProperty(default =False,)
  2103. def draw(self, context, layout, node, text):
  2104. ChooseDraw(self, context, layout, node, text)
  2105. def draw_color(self, context, node):
  2106. return self.color
  2107. @classmethod
  2108. def draw_color_simple(self):
  2109. return self.color_simple
  2110. class WildcardSocket(MantisSocket):
  2111. """Some kind of node socket lol I donno"""
  2112. bl_idname = 'WildcardSocket'
  2113. bl_label = ""
  2114. color_simple = (0.0,0.0,0.0,0.0)
  2115. color : bpy.props.FloatVectorProperty(default=(0.0,0.0,0.0,0.0), size=4)
  2116. input : bpy.props.BoolProperty(default =False,)
  2117. def draw(self, context, layout, node, text):
  2118. ChooseDraw(self, context, layout, node, text)
  2119. def draw_color(self, context, node):
  2120. return self.color
  2121. @classmethod
  2122. def draw_color_simple(self):
  2123. return self.color_simple