socket_definitions.py 92 KB

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