socket_definitions.py 90 KB

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