socket_definitions.py 89 KB

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